From bc8295dd69ccaba3b5a83726e6418e0f6051eb90 Mon Sep 17 00:00:00 2001
From: AnnieRuru <jeankofannie2@gmail.com>
Date: Mon, 11 Feb 2019 13:18:34 +0800
Subject: Retarget 10.0.15063.0 into 10.0.17763.0 so we don't have to download
 additional 1.43GB unnecessary

---
 vcproj-15/char-server.vcxproj             | 2 +-
 vcproj-15/login-server.vcxproj            | 2 +-
 vcproj-15/map-server.vcxproj              | 2 +-
 vcproj-15/plugin-HPMHooking_char.vcxproj  | 2 +-
 vcproj-15/plugin-HPMHooking_login.vcxproj | 2 +-
 vcproj-15/plugin-HPMHooking_map.vcxproj   | 2 +-
 vcproj-15/plugin-sample.vcxproj           | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

(limited to 'vcproj-15')

diff --git a/vcproj-15/char-server.vcxproj b/vcproj-15/char-server.vcxproj
index 253437275..6756fc25e 100644
--- a/vcproj-15/char-server.vcxproj
+++ b/vcproj-15/char-server.vcxproj
@@ -14,7 +14,7 @@
     <ProjectGuid>{D356871D-58E1-450B-967A-E4E9646175AF}</ProjectGuid>
     <RootNamespace>char-server</RootNamespace>
     <Keyword>Win32Proj</Keyword>
-    <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
diff --git a/vcproj-15/login-server.vcxproj b/vcproj-15/login-server.vcxproj
index 9f372373b..f045fa290 100644
--- a/vcproj-15/login-server.vcxproj
+++ b/vcproj-15/login-server.vcxproj
@@ -14,7 +14,7 @@
     <ProjectGuid>{D356871D-58E1-450B-967A-E5E9646175AF}</ProjectGuid>
     <RootNamespace>login-server</RootNamespace>
     <Keyword>Win32Proj</Keyword>
-    <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
diff --git a/vcproj-15/map-server.vcxproj b/vcproj-15/map-server.vcxproj
index ac24ce2a2..7009557f5 100644
--- a/vcproj-15/map-server.vcxproj
+++ b/vcproj-15/map-server.vcxproj
@@ -14,7 +14,7 @@
     <ProjectGuid>{D356871D-58E1-450B-967A-E6E9646175AF}</ProjectGuid>
     <RootNamespace>map-server</RootNamespace>
     <Keyword>Win32Proj</Keyword>
-    <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
diff --git a/vcproj-15/plugin-HPMHooking_char.vcxproj b/vcproj-15/plugin-HPMHooking_char.vcxproj
index 9632998d4..454276905 100644
--- a/vcproj-15/plugin-HPMHooking_char.vcxproj
+++ b/vcproj-15/plugin-HPMHooking_char.vcxproj
@@ -15,7 +15,7 @@
     <RootNamespace>plugin-HPMHooking_char</RootNamespace>
     <Keyword>Win32Proj</Keyword>
     <ProjectName>plugin-HPMHooking_char</ProjectName>
-    <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
diff --git a/vcproj-15/plugin-HPMHooking_login.vcxproj b/vcproj-15/plugin-HPMHooking_login.vcxproj
index e496847c1..98079d2be 100644
--- a/vcproj-15/plugin-HPMHooking_login.vcxproj
+++ b/vcproj-15/plugin-HPMHooking_login.vcxproj
@@ -15,7 +15,7 @@
     <RootNamespace>plugin-HPMHooking_login</RootNamespace>
     <Keyword>Win32Proj</Keyword>
     <ProjectName>plugin-HPMHooking_login</ProjectName>
-    <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
diff --git a/vcproj-15/plugin-HPMHooking_map.vcxproj b/vcproj-15/plugin-HPMHooking_map.vcxproj
index 753f1cdbc..c63dcffa4 100644
--- a/vcproj-15/plugin-HPMHooking_map.vcxproj
+++ b/vcproj-15/plugin-HPMHooking_map.vcxproj
@@ -15,7 +15,7 @@
     <RootNamespace>plugin-HPMHooking_map</RootNamespace>
     <Keyword>Win32Proj</Keyword>
     <ProjectName>plugin-HPMHooking_map</ProjectName>
-    <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
diff --git a/vcproj-15/plugin-sample.vcxproj b/vcproj-15/plugin-sample.vcxproj
index 85ceb0e43..3a77c655a 100644
--- a/vcproj-15/plugin-sample.vcxproj
+++ b/vcproj-15/plugin-sample.vcxproj
@@ -15,7 +15,7 @@
     <RootNamespace>plugin-sample</RootNamespace>
     <Keyword>Win32Proj</Keyword>
     <ProjectName>plugin-sample</ProjectName>
-    <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-- 
cgit v1.2.3-70-g09d2


From d452c74d6ec4876cb0938541bafa8f4e8951b9cf Mon Sep 17 00:00:00 2001
From: Asheraf <acheraf1998@gmail.com>
Date: Thu, 7 Mar 2019 01:12:42 +0100
Subject: moving stylist into it's own interface

---
 src/map/HPMmap.c                     |   1 +
 src/map/Makefile.in                  |   4 +-
 src/map/clif.c                       | 192 +++--------------------------
 src/map/clif.h                       |  21 ----
 src/map/itemdb.c                     |   3 -
 src/map/map.c                        |   4 +
 src/map/stylist.c                    | 228 +++++++++++++++++++++++++++++++++++
 src/map/stylist.h                    |  69 +++++++++++
 src/plugins/HPMHooking.c             |   1 +
 vcproj-12/map-server.vcxproj         |   2 +
 vcproj-12/map-server.vcxproj.filters |   6 +
 vcproj-14/map-server.vcxproj         |   2 +
 vcproj-14/map-server.vcxproj.filters |   6 +
 vcproj-15/map-server.vcxproj         |   2 +
 vcproj-15/map-server.vcxproj.filters |   6 +
 15 files changed, 343 insertions(+), 204 deletions(-)
 create mode 100644 src/map/stylist.c
 create mode 100644 src/map/stylist.h

(limited to 'vcproj-15')

diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index 6eff37df8..cbfa8e8c4 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -86,6 +86,7 @@
 #include "map/skill.h"
 #include "map/status.h"
 #include "map/storage.h"
+#include "map/stylist.h"
 #include "map/trade.h"
 #include "map/unit.h"
 #include "map/vending.h"
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index 3705fda0e..edb3fdaad 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -45,7 +45,7 @@ MAP_C = achievement.c atcommand.c battle.c battleground.c buyingstore.c channel.
         instance.c intif.c irc-bot.c itemdb.c log.c mail.c map.c mapreg_sql.c \
         mercenary.c mob.c npc.c npc_chat.c party.c path.c pc.c pc_groups.c \
         pet.c quest.c rodex.c script.c searchstore.c skill.c status.c storage.c \
-        trade.c unit.c vending.c
+        stylist.c trade.c unit.c vending.c
 MAP_OBJ = $(addprefix obj_sql/, $(patsubst %c,%o,$(MAP_C)))
 MAP_H = achievement.h atcommand.h battle.h battleground.h buyingstore.h channel.h chat.h \
         chrif.h clan.h clif.h date.h duel.h elemental.h guild.h homunculus.h HPMmap.h \
@@ -55,7 +55,7 @@ MAP_H = achievement.h atcommand.h battle.h battleground.h buyingstore.h channel.
         packets_keys_zero.h packets_shuffle_main.h packets_shuffle_re.h \
         packets_shuffle_zero.h packets_struct.h party.h path.h pc.h pc_groups.h \
         pet.h quest.h rodex.h script.h searchstore.h skill.h status.h storage.h \
-        trade.h unit.h vending.h
+        stylist.h trade.h unit.h vending.h
 MAP_PH =
 
 HAVE_MYSQL=@HAVE_MYSQL@
diff --git a/src/map/clif.c b/src/map/clif.c
index 86b130e88..3a2b7f8f3 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -52,6 +52,7 @@
 #include "map/script.h"
 #include "map/skill.h"
 #include "map/status.h"
+#include "map/stylist.h"
 #include "map/storage.h"
 #include "map/trade.h"
 #include "map/unit.h"
@@ -21873,162 +21874,23 @@ static void clif_private_airship_response(struct map_session_data *sd, uint32 fl
 #endif
 }
 
-static void clif_stylist_vector_init(void)
-{
-	int i;
-	for (i = 0; i < MAX_STYLIST_TYPE; i++) {
-		VECTOR_INIT(stylist_data[i]);
-	}
-}
-
-static void clif_stylist_vector_clear(void)
-{
-	int i;
-	for (i = 0; i < MAX_STYLIST_TYPE; i++) {
-		VECTOR_CLEAR(stylist_data[i]);
-	}
-}
-
-static bool clif_stylist_read_db_libconfig(void)
-{
-	struct config_t stylist_conf;
-	struct config_setting_t *stylist = NULL, *it = NULL;
-	const char *config_filename = "db/stylist_db.conf"; // FIXME hardcoded name
-	int i = 0;
-
-	if (!libconfig->load_file(&stylist_conf, config_filename))
-		return false;
-
-	if ((stylist = libconfig->setting_get_member(stylist_conf.root, "stylist_db")) == NULL) {
-		ShowError("can't read %s\n", config_filename);
-		return false;
-	}
-
-	clif->stylist_vector_clear();
-
-	while ((it = libconfig->setting_get_elem(stylist, i++))) {
-		clif->stylist_read_db_libconfig_sub(it, i - 1, config_filename);
-	}
-
-	libconfig->destroy(&stylist_conf);
-	ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, config_filename);
-	return true;
-}
-
-static bool clif_stylist_read_db_libconfig_sub(struct config_setting_t *it, int idx, const char *source)
-{
-	struct stylist_data_entry entry = { 0 };
-	int i32 = 0, type = 0;
-	int64 i64 = 0;
-
-	nullpo_ret(it);
-	nullpo_ret(source);
-
-	if (!itemdb->lookup_const(it, "Type", &type) || type >= MAX_STYLIST_TYPE || type < 0) {
-		ShowWarning("clif_stylist_read_db_libconfig_sub: Invalid or missing Type (%d) in \"%s\", entry #%d, skipping.\n", type, source, idx);
-		return false;
-	}
-	if (!itemdb->lookup_const(it, "Id", &i32) || i32 < 0) {
-		ShowWarning("clif_stylist_read_db_libconfig_sub: Invalid or missing Id (%d) in \"%s\", entry #%d, skipping.\n", i32, source, idx);
-		return false;
-	}
-	entry.id = i32;
-
-	if (libconfig->setting_lookup_int64(it, "Zeny", &i64)) {
-		if (i64 > MAX_ZENY) {
-			ShowWarning("clif_stylist_read_db_libconfig_sub: zeny is too big in \"%s\", entry #%d, capping to MAX_ZENY.\n", source, idx);
-			entry.zeny = MAX_ZENY;
-		} else {
-			entry.zeny = (int)i64;
-		}
-	}
-
-	if (itemdb->lookup_const(it, "ItemID", &i32))
-		entry.itemid = i32;
-
-	if (itemdb->lookup_const(it, "BoxItemID", &i32))
-		entry.boxid = i32;
-
-	if (libconfig->setting_lookup_bool(it, "AllowDoram", &i32))
-		entry.allow_doram = (i32 == 0) ? false : true;
-
-	VECTOR_ENSURE(stylist_data[type], 1, 1);
-	VECTOR_PUSH(stylist_data[type], entry);
-	return true;
-}
-
-static bool clif_style_change_validate_requirements(struct map_session_data *sd, int type, int16 idx)
-{
-	struct item it;
-	struct stylist_data_entry *entry;
-
-	nullpo_retr(false, sd);
-	Assert_retr(false, type >= 0 && type < MAX_STYLIST_TYPE);
-	Assert_retr(false, idx >= 0 && idx < VECTOR_LENGTH(stylist_data[type]));
-
-	entry = &VECTOR_INDEX(stylist_data[type], idx);
-
-	if (sd->status.class == JOB_SUMMONER && (entry->allow_doram == false))
-		return false;
-
-	if (entry->id >= 0) {
-		if (entry->zeny != 0) {
-			if (sd->status.zeny < entry->zeny)
-				return false;
-
-			sd->status.zeny -= entry->zeny;
-			clif->updatestatus(sd, SP_ZENY);
-		} else if (entry->itemid != 0) {
-			it.nameid = entry->itemid;
-			it.amount = 1;
-			return script->buildin_delitem_search(sd, &it, false);
-		} else if (entry->boxid != 0) {
-			it.nameid = entry->boxid;
-			it.amount = 1;
-			return script->buildin_delitem_search(sd, &it, false);
-		}
-		return true;
-	}
-	return false;
-}
-static void clif_stylist_send_rodexitem(struct map_session_data *sd, int itemid)
-{
-	struct rodex_message msg = { 0 };
-
-	nullpo_retv(sd);
-
-	msg.receiver_id = sd->status.char_id;
-	msg.items[0].item.nameid = itemid;
-	msg.items[0].item.amount = 1;
-	msg.items[0].item.identify = 1;
-	msg.type = MAIL_TYPE_NPC | MAIL_TYPE_ITEM;
-
-	safestrncpy(msg.sender_name, msg_txt(366), NAME_LENGTH);
-	safestrncpy(msg.title, msg_txt(367), RODEX_TITLE_LENGTH);
-	safestrncpy(msg.body, msg_txt(368), MAIL_BODY_LENGTH);
-	msg.send_date = (int)time(NULL);
-	msg.expire_date = (int)time(NULL) + RODEX_EXPIRE;
-
-	intif->rodex_sendmail(&msg);
-}
-
 static void clif_parse_cz_req_style_change(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
 static void clif_parse_cz_req_style_change(int fd, struct map_session_data *sd)
 {
 	const struct PACKET_CZ_REQ_STYLE_CHANGE *p = RP2PTR(fd);
 
 	if (p->HeadStyle > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HAIR, p->HeadStyle, false);
+		stylist->request_style_change(sd, LOOK_HAIR, p->HeadStyle, false);
 	if (p->HeadPalette > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HAIR_COLOR, p->HeadPalette, false);
+		stylist->request_style_change(sd, LOOK_HAIR_COLOR, p->HeadPalette, false);
 	if (p->BodyPalette > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_CLOTHES_COLOR, p->BodyPalette, false);
+		stylist->request_style_change(sd, LOOK_CLOTHES_COLOR, p->BodyPalette, false);
 	if (p->TopAccessory > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HEAD_TOP, p->TopAccessory, true);
+		stylist->request_style_change(sd, LOOK_HEAD_TOP, p->TopAccessory, true);
 	if (p->MidAccessory > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HEAD_MID, p->MidAccessory, true);
+		stylist->request_style_change(sd, LOOK_HEAD_MID, p->MidAccessory, true);
 	if (p->BottomAccessory > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HEAD_BOTTOM, p->BottomAccessory, true);
+		stylist->request_style_change(sd, LOOK_HEAD_BOTTOM, p->BottomAccessory, true);
 	clif->style_change_response(sd, STYLIST_SHOP_SUCCESS);
 	return;
 }
@@ -22039,45 +21901,26 @@ static void clif_parse_cz_req_style_change2(int fd, struct map_session_data *sd)
 	const struct PACKET_CZ_REQ_STYLE_CHANGE2 *p = RP2PTR(fd);
 
 	if (p->HeadStyle > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HAIR, p->HeadStyle, false);
+		stylist->request_style_change(sd, LOOK_HAIR, p->HeadStyle, false);
 	if (p->HeadPalette > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HAIR_COLOR, p->HeadPalette, false);
+		stylist->request_style_change(sd, LOOK_HAIR_COLOR, p->HeadPalette, false);
 	if (p->BodyPalette > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_CLOTHES_COLOR, p->BodyPalette, false);
+		stylist->request_style_change(sd, LOOK_CLOTHES_COLOR, p->BodyPalette, false);
 	if (p->TopAccessory > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HEAD_TOP, p->TopAccessory, true);
+		stylist->request_style_change(sd, LOOK_HEAD_TOP, p->TopAccessory, true);
 	if (p->MidAccessory > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HEAD_MID, p->MidAccessory, true);
+		stylist->request_style_change(sd, LOOK_HEAD_MID, p->MidAccessory, true);
 	if (p->BottomAccessory > 0)
-		clif->cz_req_style_change_sub(sd, LOOK_HEAD_BOTTOM, p->BottomAccessory, true);
+		stylist->request_style_change(sd, LOOK_HEAD_BOTTOM, p->BottomAccessory, true);
 	if (p->BodyStyle > 0) {
 		if (pc->has_second_costume(sd)) {
-			clif->cz_req_style_change_sub(sd, LOOK_BODY2, p->BodyStyle, false);
+			stylist->request_style_change(sd, LOOK_BODY2, p->BodyStyle, false);
 		}
 	}
 	clif->style_change_response(sd, STYLIST_SHOP_SUCCESS);
 	return;
 }
 
-static void clif_cz_req_style_change_sub(struct map_session_data *sd, int type, int16 idx, bool isitem)
-{
-	struct stylist_data_entry *entry;
-
-	nullpo_retv(sd);
-	Assert_retv(idx > 0);
-	Assert_retv(type >= 0 && type < MAX_STYLIST_TYPE);
-
-	if ((idx - 1) < VECTOR_LENGTH(stylist_data[type])) {
-		entry = &VECTOR_INDEX(stylist_data[type], idx - 1);
-		if (clif->style_change_validate_requirements(sd, type, idx - 1)) {
-			if (isitem == false)
-				pc->changelook(sd, type, entry->id);
-			else
-				clif->stylist_send_rodexitem(sd, entry->id);
-		}
-	}
-}
-
 static void clif_style_change_response(struct map_session_data *sd, enum stylist_shop flag)
 {
 #if PACKETVER >= 20151104
@@ -23459,15 +23302,8 @@ void clif_defaults(void)
 	clif->pPrivateAirshipRequest = clif_parse_private_airship_request;
 	clif->PrivateAirshipResponse = clif_private_airship_response;
 
-	clif->stylist_vector_init = clif_stylist_vector_init;
-	clif->stylist_vector_clear = clif_stylist_vector_clear;
-	clif->stylist_read_db_libconfig = clif_stylist_read_db_libconfig;
-	clif->stylist_read_db_libconfig_sub = clif_stylist_read_db_libconfig_sub;
-	clif->style_change_validate_requirements = clif_style_change_validate_requirements;
-	clif->stylist_send_rodexitem = clif_stylist_send_rodexitem;
 	clif->pReqStyleChange = clif_parse_cz_req_style_change;
 	clif->pReqStyleChange2 = clif_parse_cz_req_style_change2;
-	clif->cz_req_style_change_sub = clif_cz_req_style_change_sub;
 	clif->style_change_response = clif_style_change_response;
 
 	clif->camera_showWindow = clif_camera_showWindow;
diff --git a/src/map/clif.h b/src/map/clif.h
index a7573b56e..23ac7f250 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -71,10 +71,6 @@ enum rodex_get_items;
 #define MAX_ROULETTE_COLUMNS 9 /** client-defined value **/
 #define RGB2BGR(c) (((c) & 0x0000FF) << 16 | ((c) & 0x00FF00) | ((c) & 0xFF0000) >> 16)
 
-#ifndef MAX_STYLIST_TYPE
-#define MAX_STYLIST_TYPE LOOK_MAX
-#endif
-
 #define COLOR_CYAN    0x00ffffU
 #define COLOR_RED     0xff0000U
 #define COLOR_GREEN   0x00ff00U
@@ -655,16 +651,6 @@ struct attendance_entry {
 	int qty;
 };
 
-/* Stylist data [Asheraf/Hercules]*/
-struct stylist_data_entry {
-	int16 id;
-	int32 zeny;
-	int itemid;
-	int boxid;
-	bool allow_doram;
-};
-VECTOR_DECL(struct stylist_data_entry) stylist_data[MAX_STYLIST_TYPE];
-
 struct barter_itemlist_entry {
 	int addId;
 	int addAmount;
@@ -1576,15 +1562,8 @@ struct clif_interface {
 	void (*pPrivateAirshipRequest) (int fd, struct map_session_data *sd);
 	void (*PrivateAirshipResponse) (struct map_session_data *sd, uint32 flag);
 
-	void (*stylist_vector_init) (void);
-	void (*stylist_vector_clear) (void);
-	bool (*stylist_read_db_libconfig) (void);
-	bool (*stylist_read_db_libconfig_sub) (struct config_setting_t *it, int idx, const char *source);
-	bool (*style_change_validate_requirements) (struct map_session_data *sd, int type, int16 idx);
-	void (*stylist_send_rodexitem) (struct map_session_data *sd, int itemid);
 	void (*pReqStyleChange) (int fd, struct map_session_data *sd);
 	void (*pReqStyleChange2) (int fd, struct map_session_data *sd);
-	void (*cz_req_style_change_sub) (struct map_session_data *sd, int type, int16 idx, bool isitem);
 	void (*style_change_response) (struct map_session_data *sd, enum stylist_shop flag);
 	void (*pPetEvolution) (int fd, struct map_session_data *sd);
 	void (*petEvolutionResult) (int fd, enum pet_evolution_result result);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 03f0fdc06..a61bbd008 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -2458,7 +2458,6 @@ static void itemdb_read(bool minimal)
 	itemdb->read_chains();
 	itemdb->read_packages();
 	itemdb->read_options();
-	clif->stylist_read_db_libconfig();
 }
 
 /**
@@ -2707,7 +2706,6 @@ static void do_final_itemdb(void)
 	itemdb->destroy_item_data(&itemdb->dummy, 0);
 	db_destroy(itemdb->names);
 	VECTOR_CLEAR(clif->attendance_data);
-	clif->stylist_vector_clear();
 }
 
 static void do_init_itemdb(bool minimal)
@@ -2717,7 +2715,6 @@ static void do_init_itemdb(bool minimal)
 	itemdb->options = idb_alloc(DB_OPT_RELEASE_DATA);
 	itemdb->names = strdb_alloc(DB_OPT_BASE,ITEM_NAME_LENGTH);
 	itemdb->create_dummy_data(); //Dummy data item.
-	clif->stylist_vector_init();
 	itemdb->read(minimal);
 
 	if (minimal)
diff --git a/src/map/map.c b/src/map/map.c
index 6212493c8..7d2cc87d4 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -56,6 +56,7 @@
 #include "map/skill.h"
 #include "map/status.h"
 #include "map/storage.h"
+#include "map/stylist.h"
 #include "map/rodex.h"
 #include "map/trade.h"
 #include "map/unit.h"
@@ -6197,6 +6198,7 @@ int do_final(void)
 	vending->final();
 	rodex->final();
 	achievement->final();
+	stylist->final();
 
 	HPM_map_do_final();
 
@@ -6404,6 +6406,7 @@ static void map_load_defaults(void)
 	achievement_defaults();
 	npc_chat_defaults();
 	rodex_defaults();
+	stylist_defaults();
 }
 /**
  * --run-once handler
@@ -6724,6 +6727,7 @@ int do_init(int argc, char *argv[])
 	duel->init(minimal);
 	vending->init(minimal);
 	rodex->init(minimal);
+	stylist->init(minimal);
 
 	if (map->scriptcheck) {
 		bool failed = map->extra_scripts_count > 0 ? false : true;
diff --git a/src/map/stylist.c b/src/map/stylist.c
new file mode 100644
index 000000000..7e7c13bf7
--- /dev/null
+++ b/src/map/stylist.c
@@ -0,0 +1,228 @@
+/**
+* This file is part of Hercules.
+* http://herc.ws - http://github.com/HerculesWS/Hercules
+*
+* Copyright (C) 2018-2019  Hercules Dev Team
+*
+* Hercules is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#define HERCULES_CORE
+
+#include "map/stylist.h"
+
+#include "common/conf.h"
+#include "common/db.h"
+#include "common/memmgr.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+
+#include "map/clif.h"
+#include "map/intif.h"
+#include "map/itemdb.h"
+#include "map/pc.h"
+#include "map/script.h"
+
+static struct stylist_interface stylist_s;
+struct stylist_interface *stylist;
+
+static bool stylist_read_db_libconfig(void)
+{
+	struct config_t stylist_conf;
+	struct config_setting_t *stylist_db = NULL, *it = NULL;
+	const char *config_filename = "db/stylist_db.conf"; // FIXME hardcoded name
+	int i = 0;
+
+	if (!libconfig->load_file(&stylist_conf, config_filename))
+		return false;
+
+	if ((stylist_db = libconfig->setting_get_member(stylist_conf.root, "stylist_db")) == NULL) {
+		ShowError("can't read %s\n", config_filename);
+		return false;
+	}
+
+	stylist->vector_clear();
+
+	while ((it = libconfig->setting_get_elem(stylist_db, i++))) {
+		stylist->read_db_libconfig_sub(it, i - 1, config_filename);
+	}
+
+	libconfig->destroy(&stylist_conf);
+	ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, config_filename);
+	return true;
+}
+
+static bool stylist_read_db_libconfig_sub(struct config_setting_t *it, int idx, const char *source)
+{
+	struct stylist_data_entry entry = { 0 };
+	int i32 = 0, type = 0;
+	int64 i64 = 0;
+
+	nullpo_ret(it);
+	nullpo_ret(source);
+
+	if (!itemdb->lookup_const(it, "Type", &type) || type >= MAX_STYLIST_TYPE || type < 0) {
+		ShowWarning("stylist_read_db_libconfig_sub: Invalid or missing Type (%d) in \"%s\", entry #%d, skipping.\n", type, source, idx);
+		return false;
+	}
+	if (!itemdb->lookup_const(it, "Id", &i32) || i32 < 0) {
+		ShowWarning("stylist_read_db_libconfig_sub: Invalid or missing Id (%d) in \"%s\", entry #%d, skipping.\n", i32, source, idx);
+		return false;
+	}
+	entry.id = i32;
+
+	if (libconfig->setting_lookup_int64(it, "Zeny", &i64)) {
+		if (i64 > MAX_ZENY) {
+			ShowWarning("stylist_read_db_libconfig_sub: zeny is too big in \"%s\", entry #%d, capping to MAX_ZENY.\n", source, idx);
+			entry.zeny = MAX_ZENY;
+		} else {
+			entry.zeny = (int)i64;
+		}
+	}
+
+	if (itemdb->lookup_const(it, "ItemID", &i32))
+		entry.itemid = i32;
+
+	if (itemdb->lookup_const(it, "BoxItemID", &i32))
+		entry.boxid = i32;
+
+	if (libconfig->setting_lookup_bool(it, "AllowDoram", &i32))
+		entry.allow_doram = (i32 == 0) ? false : true;
+
+	VECTOR_ENSURE(stylist->data[type], 1, 1);
+	VECTOR_PUSH(stylist->data[type], entry);
+	return true;
+}
+
+static bool stylist_validate_requirements(struct map_session_data *sd, int type, int16 idx)
+{
+	struct item it;
+	struct stylist_data_entry *entry;
+
+	nullpo_retr(false, sd);
+	Assert_retr(false, type >= 0 && type < MAX_STYLIST_TYPE);
+	Assert_retr(false, idx >= 0 && idx < VECTOR_LENGTH(stylist->data[type]));
+
+	entry = &VECTOR_INDEX(stylist->data[type], idx);
+
+	if (sd->status.class == JOB_SUMMONER && (entry->allow_doram == false))
+		return false;
+
+	if (entry->id >= 0) {
+		if (entry->zeny != 0) {
+			if (sd->status.zeny < entry->zeny)
+				return false;
+
+			sd->status.zeny -= entry->zeny;
+			clif->updatestatus(sd, SP_ZENY);
+		} else if (entry->itemid != 0) {
+			it.nameid = entry->itemid;
+			it.amount = 1;
+			return script->buildin_delitem_search(sd, &it, false);
+		} else if (entry->boxid != 0) {
+			it.nameid = entry->boxid;
+			it.amount = 1;
+			return script->buildin_delitem_search(sd, &it, false);
+		}
+		return true;
+	}
+	return false;
+}
+
+static void stylist_send_rodexitem(struct map_session_data *sd, int itemid)
+{
+	struct rodex_message msg = { 0 };
+
+	nullpo_retv(sd);
+
+	msg.receiver_id = sd->status.char_id;
+	msg.items[0].item.nameid = itemid;
+	msg.items[0].item.amount = 1;
+	msg.items[0].item.identify = 1;
+	msg.type = MAIL_TYPE_NPC | MAIL_TYPE_ITEM;
+
+	safestrncpy(msg.sender_name, msg_txt(366), NAME_LENGTH);
+	safestrncpy(msg.title, msg_txt(367), RODEX_TITLE_LENGTH);
+	safestrncpy(msg.body, msg_txt(368), MAIL_BODY_LENGTH);
+	msg.send_date = (int)time(NULL);
+	msg.expire_date = (int)time(NULL) + RODEX_EXPIRE;
+
+	intif->rodex_sendmail(&msg);
+}
+
+static void stylist_request_style_change(struct map_session_data *sd, int type, int16 idx, bool isitem)
+{
+	struct stylist_data_entry *entry;
+
+	nullpo_retv(sd);
+	Assert_retv(idx > 0);
+	Assert_retv(type >= 0 && type < MAX_STYLIST_TYPE);
+
+	if ((idx - 1) < VECTOR_LENGTH(stylist->data[type])) {
+		entry = &VECTOR_INDEX(stylist->data[type], idx - 1);
+		if (stylist->validate_requirements(sd, type, idx - 1)) {
+			if (isitem == false)
+				pc->changelook(sd, type, entry->id);
+			else
+				stylist->send_rodexitem(sd, entry->id);
+		}
+	}
+}
+
+static void stylist_vector_init(void)
+{
+	for (int i = 0; i < MAX_STYLIST_TYPE; i++)
+		VECTOR_INIT(stylist->data[i]);
+}
+static void stylist_vector_clear(void)
+{
+	for (int i = 0; i < MAX_STYLIST_TYPE; i++)
+		VECTOR_CLEAR(stylist->data[i]);
+}
+
+static void do_init_stylist(bool minimal)
+{
+	if (minimal)
+		return;
+
+	// Initialize the db
+	stylist->vector_init();
+
+	// Load the db
+	stylist->read_db_libconfig();
+}
+
+static void do_final_stylist(void)
+{
+	// Clear the db
+	stylist->vector_clear();
+}
+
+void stylist_defaults(void)
+{
+	stylist = &stylist_s;
+
+	/* core */
+	stylist->init = do_init_stylist;
+	stylist->final = do_final_stylist;
+	/* */
+	stylist->vector_init = stylist_vector_init;
+	stylist->vector_clear = stylist_vector_clear;
+	/* database */
+	stylist->read_db_libconfig = stylist_read_db_libconfig;
+	stylist->read_db_libconfig_sub = stylist_read_db_libconfig_sub;
+	/* */
+	stylist->request_style_change = stylist_request_style_change;
+	stylist->validate_requirements = stylist_validate_requirements;
+	stylist->send_rodexitem = stylist_send_rodexitem;
+}
diff --git a/src/map/stylist.h b/src/map/stylist.h
new file mode 100644
index 000000000..5bedfefc7
--- /dev/null
+++ b/src/map/stylist.h
@@ -0,0 +1,69 @@
+/**
+ * This file is part of Hercules.
+ * http://herc.ws - http://github.com/HerculesWS/Hercules
+ *
+ * Copyright (C) 2018-2019  Hercules Dev Team
+ *
+ * Hercules is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef MAP_STYLIST_H
+#define MAP_STYLIST_H
+
+#include "common/hercules.h"
+#include "map/map.h" // LOOK_MAX
+
+struct map_session_data;
+
+/* Maximum available types for stylist */
+#ifndef MAX_STYLIST_TYPE
+#define MAX_STYLIST_TYPE LOOK_MAX
+#endif
+
+/* Stylist data [Asheraf/Hercules]*/
+struct stylist_data_entry {
+	int16 id;
+	int32 zeny;
+	int itemid;
+	int boxid;
+	bool allow_doram;
+};
+
+/**
+ * stylist.c Interface
+ **/
+struct stylist_interface {
+	VECTOR_DECL(struct stylist_data_entry) data[MAX_STYLIST_TYPE];
+
+	void (*init) (bool minimal);
+	void (*final) (void);
+
+	void (*vector_init) (void);
+	void (*vector_clear) (void);
+
+	bool (*read_db_libconfig) (void);
+	bool (*read_db_libconfig_sub) (struct config_setting_t *it, int idx, const char *source);
+
+	void (*request_style_change) (struct map_session_data *sd, int type, int16 idx, bool isitem);
+	bool (*validate_requirements) (struct map_session_data *sd, int type, int16 idx);
+	void (*send_rodexitem) (struct map_session_data *sd, int itemid);
+
+};
+
+#ifdef HERCULES_CORE
+void stylist_defaults(void);
+#endif // HERCULES_CORE
+
+HPShared struct stylist_interface *stylist; ///< Pointer to the stylist interface.
+
+#endif /* MAP_STYLIST_H */
diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c
index aef09d7a7..f95a3a92d 100644
--- a/src/plugins/HPMHooking.c
+++ b/src/plugins/HPMHooking.c
@@ -110,6 +110,7 @@ PRAGMA_GCC5(GCC diagnostic ignored "-Wdiscarded-qualifiers")
 #include "map/skill.h"
 #include "map/status.h"
 #include "map/storage.h"
+#include "map/stylist.h"
 #include "map/trade.h"
 #include "map/unit.h"
 #include "common/grfio.h"
diff --git a/vcproj-12/map-server.vcxproj b/vcproj-12/map-server.vcxproj
index 3435ec4b6..72bae9d97 100644
--- a/vcproj-12/map-server.vcxproj
+++ b/vcproj-12/map-server.vcxproj
@@ -219,6 +219,7 @@
     <ClInclude Include="..\src\map\skill.h" />
     <ClInclude Include="..\src\map\status.h" />
     <ClInclude Include="..\src\map\storage.h" />
+    <ClInclude Include="..\src\map\stylist.h" />
     <ClInclude Include="..\src\map\trade.h" />
     <ClInclude Include="..\src\map\unit.h" />
     <ClInclude Include="..\src\map\vending.h" />
@@ -293,6 +294,7 @@
     <ClCompile Include="..\src\map\skill.c" />
     <ClCompile Include="..\src\map\status.c" />
     <ClCompile Include="..\src\map\storage.c" />
+    <ClCompile Include="..\src\map\stylist.c" />
     <ClCompile Include="..\src\map\trade.c" />
     <ClCompile Include="..\src\map\unit.c" />
     <ClCompile Include="..\src\map\vending.c" />
diff --git a/vcproj-12/map-server.vcxproj.filters b/vcproj-12/map-server.vcxproj.filters
index 8457ddf5f..6734c65bf 100644
--- a/vcproj-12/map-server.vcxproj.filters
+++ b/vcproj-12/map-server.vcxproj.filters
@@ -112,6 +112,9 @@
     <ClCompile Include="..\src\map\storage.c">
       <Filter>map</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\map\stylist.c">
+      <Filter>map</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\map\trade.c">
       <Filter>map</Filter>
     </ClCompile>
@@ -345,6 +348,9 @@
     <ClInclude Include="..\src\map\storage.h">
       <Filter>map</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\map\stylist.h">
+      <Filter>map</Filter>
+    </ClInclude>
     <ClInclude Include="..\src\map\trade.h">
       <Filter>map</Filter>
     </ClInclude>
diff --git a/vcproj-14/map-server.vcxproj b/vcproj-14/map-server.vcxproj
index fca2a7826..b17990588 100644
--- a/vcproj-14/map-server.vcxproj
+++ b/vcproj-14/map-server.vcxproj
@@ -217,6 +217,7 @@
     <ClInclude Include="..\src\map\skill.h" />
     <ClInclude Include="..\src\map\status.h" />
     <ClInclude Include="..\src\map\storage.h" />
+    <ClInclude Include="..\src\map\stylist.h" />
     <ClInclude Include="..\src\map\trade.h" />
     <ClInclude Include="..\src\map\unit.h" />
     <ClInclude Include="..\src\map\vending.h" />
@@ -291,6 +292,7 @@
     <ClCompile Include="..\src\map\skill.c" />
     <ClCompile Include="..\src\map\status.c" />
     <ClCompile Include="..\src\map\storage.c" />
+    <ClCompile Include="..\src\map\stylist.c" />
     <ClCompile Include="..\src\map\trade.c" />
     <ClCompile Include="..\src\map\unit.c" />
     <ClCompile Include="..\src\map\vending.c" />
diff --git a/vcproj-14/map-server.vcxproj.filters b/vcproj-14/map-server.vcxproj.filters
index 49099de50..c8e64d8fd 100644
--- a/vcproj-14/map-server.vcxproj.filters
+++ b/vcproj-14/map-server.vcxproj.filters
@@ -109,6 +109,9 @@
     <ClCompile Include="..\src\map\storage.c">
       <Filter>map</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\map\stylist.c">
+      <Filter>map</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\map\trade.c">
       <Filter>map</Filter>
     </ClCompile>
@@ -342,6 +345,9 @@
     <ClInclude Include="..\src\map\storage.h">
       <Filter>map</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\map\stylist.h">
+      <Filter>map</Filter>
+    </ClInclude>
     <ClInclude Include="..\src\map\trade.h">
       <Filter>map</Filter>
     </ClInclude>
diff --git a/vcproj-15/map-server.vcxproj b/vcproj-15/map-server.vcxproj
index 7009557f5..c7a83fa39 100644
--- a/vcproj-15/map-server.vcxproj
+++ b/vcproj-15/map-server.vcxproj
@@ -218,6 +218,7 @@
     <ClInclude Include="..\src\map\skill.h" />
     <ClInclude Include="..\src\map\status.h" />
     <ClInclude Include="..\src\map\storage.h" />
+    <ClInclude Include="..\src\map\stylist.h" />
     <ClInclude Include="..\src\map\trade.h" />
     <ClInclude Include="..\src\map\unit.h" />
     <ClInclude Include="..\src\map\vending.h" />
@@ -292,6 +293,7 @@
     <ClCompile Include="..\src\map\skill.c" />
     <ClCompile Include="..\src\map\status.c" />
     <ClCompile Include="..\src\map\storage.c" />
+    <ClCompile Include="..\src\map\stylist.c" />
     <ClCompile Include="..\src\map\trade.c" />
     <ClCompile Include="..\src\map\unit.c" />
     <ClCompile Include="..\src\map\vending.c" />
diff --git a/vcproj-15/map-server.vcxproj.filters b/vcproj-15/map-server.vcxproj.filters
index d616f0cbc..2a3d1b489 100644
--- a/vcproj-15/map-server.vcxproj.filters
+++ b/vcproj-15/map-server.vcxproj.filters
@@ -109,6 +109,9 @@
     <ClCompile Include="..\src\map\status.c">
       <Filter>map</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\map\stylist.c">
+      <Filter>map</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\map\storage.c">
       <Filter>map</Filter>
     </ClCompile>
@@ -342,6 +345,9 @@
     <ClInclude Include="..\src\map\status.h">
       <Filter>map</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\map\stylist.h">
+      <Filter>map</Filter>
+    </ClInclude>
     <ClInclude Include="..\src\map\storage.h">
       <Filter>map</Filter>
     </ClInclude>
-- 
cgit v1.2.3-70-g09d2


From bd1c1bb39b3d69fba175bda94af4e9d1149fbbb5 Mon Sep 17 00:00:00 2001
From: Ibrahim Zidan <brahem@aotsw.com>
Date: Sat, 13 Apr 2019 21:11:09 +0200
Subject: Removal of refine database code from status.c and moving it
 respectfully to its own files

Signed-off-by: Ibrahim Zidan <brahem@aotsw.com>
---
 src/map/HPMmap.c                     |   2 +
 src/map/Makefile.in                  |   6 +-
 src/map/atcommand.c                  |   1 +
 src/map/itemdb.c                     |   1 +
 src/map/map.c                        |   3 +
 src/map/refine.c                     | 233 +++++++++++++++++++++++++++++++++++
 src/map/refine.h                     | 107 ++++++++++++++++
 src/map/refine.p.h                   |  58 +++++++++
 src/map/script.c                     |   3 +-
 src/map/skill.c                      |   3 +-
 src/map/status.c                     | 197 +----------------------------
 src/map/status.h                     |  41 ------
 vcproj-12/map-server.vcxproj         |   3 +
 vcproj-12/map-server.vcxproj.filters |   9 ++
 vcproj-14/map-server.vcxproj         |   3 +
 vcproj-14/map-server.vcxproj.filters |   9 ++
 vcproj-15/map-server.vcxproj         |   3 +
 vcproj-15/map-server.vcxproj.filters |  11 +-
 18 files changed, 454 insertions(+), 239 deletions(-)
 create mode 100644 src/map/refine.c
 create mode 100644 src/map/refine.h
 create mode 100644 src/map/refine.p.h

(limited to 'vcproj-15')

diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index cbfa8e8c4..e89f47c12 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -81,6 +81,8 @@
 #include "map/pet.h"
 #include "map/quest.h"
 #include "map/rodex.h"
+#include "map/refine.h"
+#include "map/refine.p.h"
 #include "map/script.h"
 #include "map/searchstore.h"
 #include "map/skill.h"
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index edb3fdaad..f851de756 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -44,7 +44,7 @@ MAP_C = achievement.c atcommand.c battle.c battleground.c buyingstore.c channel.
         chrif.c clan.c clif.c date.c duel.c elemental.c guild.c homunculus.c HPMmap.c \
         instance.c intif.c irc-bot.c itemdb.c log.c mail.c map.c mapreg_sql.c \
         mercenary.c mob.c npc.c npc_chat.c party.c path.c pc.c pc_groups.c \
-        pet.c quest.c rodex.c script.c searchstore.c skill.c status.c storage.c \
+        pet.c quest.c refine.c rodex.c script.c searchstore.c skill.c status.c storage.c \
         stylist.c trade.c unit.c vending.c
 MAP_OBJ = $(addprefix obj_sql/, $(patsubst %c,%o,$(MAP_C)))
 MAP_H = achievement.h atcommand.h battle.h battleground.h buyingstore.h channel.h chat.h \
@@ -54,9 +54,9 @@ MAP_H = achievement.h atcommand.h battle.h battleground.h buyingstore.h channel.
         messages_sak.h messages_zero.h mob.h npc.h packets.h packets_keys_main.h \
         packets_keys_zero.h packets_shuffle_main.h packets_shuffle_re.h \
         packets_shuffle_zero.h packets_struct.h party.h path.h pc.h pc_groups.h \
-        pet.h quest.h rodex.h script.h searchstore.h skill.h status.h storage.h \
+        pet.h quest.h refine.h rodex.h script.h searchstore.h skill.h status.h storage.h \
         stylist.h trade.h unit.h vending.h
-MAP_PH =
+MAP_PH = refine.p.h
 
 HAVE_MYSQL=@HAVE_MYSQL@
 ifeq ($(HAVE_MYSQL),yes)
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 8bca17fa1..e2ba88e64 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -48,6 +48,7 @@
 #include "map/pc_groups.h" // groupid2name
 #include "map/pet.h"
 #include "map/quest.h"
+#include "map/refine.h"
 #include "map/script.h"
 #include "map/searchstore.h"
 #include "map/skill.h"
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index a61bbd008..11d778f8a 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -27,6 +27,7 @@
 #include "map/map.h"
 #include "map/mob.h"    // MAX_MOB_DB
 #include "map/pc.h"     // W_MUSICAL, W_WHIP
+#include "map/refine.h"
 #include "map/script.h" // item script processing
 #include "common/HPM.h"
 #include "common/conf.h"
diff --git a/src/map/map.c b/src/map/map.c
index 7d2cc87d4..d34d421d7 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -58,6 +58,7 @@
 #include "map/storage.h"
 #include "map/stylist.h"
 #include "map/rodex.h"
+#include "map/refine.h"
 #include "map/trade.h"
 #include "map/unit.h"
 #include "map/achievement.h"
@@ -6190,6 +6191,7 @@ int do_final(void)
 	atcommand->final_msg();
 	skill->final();
 	status->final();
+	refine->final();
 	unit->final();
 	bg->final();
 	duel->final();
@@ -6711,6 +6713,7 @@ int do_init(int argc, char *argv[])
 		map->read_zone_db();/* read after item and skill initialization */
 	mob->init(minimal);
 	pc->init(minimal);
+	refine->init(minimal);
 	status->init(minimal);
 	party->init(minimal);
 	guild->init(minimal);
diff --git a/src/map/refine.c b/src/map/refine.c
new file mode 100644
index 000000000..8a172c40b
--- /dev/null
+++ b/src/map/refine.c
@@ -0,0 +1,233 @@
+/**
+* This file is part of Hercules.
+* http://herc.ws - http://github.com/HerculesWS/Hercules
+*
+* Copyright (C) 2019  Hercules Dev Team
+*
+* Hercules is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#define HERCULES_CORE
+
+#include "refine.p.h"
+#include "common/cbasetypes.h"
+#include "common/mmo.h"
+#include "common/nullpo.h"
+#include "common/showmsg.h"
+#include "common/strlib.h"
+#include "map/map.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/** @file
+* Implementation of the refine interface.
+*/
+
+static struct refine_interface refine_s;
+static struct refine_interface_private refine_p;
+static struct refine_interface_dbs refine_dbs;
+struct refine_interface *refine;
+
+/// @copydoc refine_interface::get_refine_chance()
+static int refine_get_refine_chance(enum refine_type wlv, int refine_level, enum refine_chance_type type)
+{
+	Assert_ret((int)wlv >= REFINE_TYPE_ARMOR && wlv < REFINE_TYPE_MAX);
+
+	if (refine_level < 0 || refine_level >= MAX_REFINE)
+		return 0;
+
+	if (type >= REFINE_CHANCE_TYPE_MAX)
+		return 0;
+
+	return refine->dbs->refine_info[wlv].chance[type][refine_level];
+}
+
+/// @copydoc refine_interface_private::readdb_refine_libconfig_sub()
+static int refine_readdb_refine_libconfig_sub(struct config_setting_t *r, const char *name, const char *source)
+{
+	struct config_setting_t *rate = NULL;
+	int type = REFINE_TYPE_ARMOR, bonus_per_level = 0, rnd_bonus_v = 0, rnd_bonus_lv = 0;
+	char lv[4];
+	nullpo_ret(r);
+	nullpo_ret(name);
+	nullpo_ret(source);
+
+	if (strncmp(name, "Armors", 6) == 0) {
+		type = REFINE_TYPE_ARMOR;
+	} else if (strncmp(name, "WeaponLevel", 11) != 0 || !strspn(&name[strlen(name)-1], "0123456789") || (type = atoi(strncpy(lv, name+11, 2))) == REFINE_TYPE_ARMOR) {
+		ShowError("status_readdb_refine_libconfig_sub: Invalid key name for entry '%s' in \"%s\", skipping.\n", name, source);
+		return 0;
+	}
+	if (type < REFINE_TYPE_ARMOR || type >= REFINE_TYPE_MAX) {
+		ShowError("status_readdb_refine_libconfig_sub: Out of range level for entry '%s' in \"%s\", skipping.\n", name, source);
+		return 0;
+	}
+	if (!libconfig->setting_lookup_int(r, "StatsPerLevel", &bonus_per_level)) {
+		ShowWarning("status_readdb_refine_libconfig_sub: Missing StatsPerLevel for entry '%s' in \"%s\", skipping.\n", name, source);
+		return 0;
+	}
+	if (!libconfig->setting_lookup_int(r, "RandomBonusStartLevel", &rnd_bonus_lv)) {
+		ShowWarning("status_readdb_refine_libconfig_sub: Missing RandomBonusStartLevel for entry '%s' in \"%s\", skipping.\n", name, source);
+		return 0;
+	}
+	if (!libconfig->setting_lookup_int(r, "RandomBonusValue", &rnd_bonus_v)) {
+		ShowWarning("status_readdb_refine_libconfig_sub: Missing RandomBonusValue for entry '%s' in \"%s\", skipping.\n", name, source);
+		return 0;
+	}
+
+	if ((rate=libconfig->setting_get_member(r, "Rates")) != NULL && config_setting_is_group(rate)) {
+		struct config_setting_t *t = NULL;
+		bool duplicate[MAX_REFINE];
+		int bonus[MAX_REFINE], rnd_bonus[MAX_REFINE];
+		int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE];
+		int i, j;
+
+		memset(&duplicate, 0, sizeof(duplicate));
+		memset(&bonus, 0, sizeof(bonus));
+		memset(&rnd_bonus, 0, sizeof(rnd_bonus));
+
+		for (i = 0; i < REFINE_CHANCE_TYPE_MAX; i++)
+			for (j = 0; j < MAX_REFINE; j++)
+				chance[i][j] = 100; // default value for all rates.
+
+		i = 0;
+		j = 0;
+		while ((t = libconfig->setting_get_elem(rate,i++)) != NULL && config_setting_is_group(t)) {
+			int level = 0, i32;
+			char *rlvl = config_setting_name(t);
+			memset(&lv, 0, sizeof(lv));
+
+			if (!strspn(&rlvl[strlen(rlvl) - 1], "0123456789") || (level = atoi(strncpy(lv, rlvl + 2, 3))) <= 0) {
+				ShowError("status_readdb_refine_libconfig_sub: Invalid refine level format '%s' for entry %s in \"%s\"... skipping.\n", rlvl, name, source);
+				continue;
+			}
+
+			if (level <= 0 || level > MAX_REFINE) {
+				ShowError("status_readdb_refine_libconfig_sub: Out of range refine level '%s' for entry %s in \"%s\"... skipping.\n", rlvl, name, source);
+				continue;
+			}
+
+			level--;
+
+			if (duplicate[level]) {
+				ShowWarning("status_readdb_refine_libconfig_sub: duplicate rate '%s' for entry %s in \"%s\", overwriting previous entry...\n", rlvl, name, source);
+			} else {
+				duplicate[level] = true;
+			}
+
+			if (libconfig->setting_lookup_int(t, "NormalChance", &i32) != 0)
+				chance[REFINE_CHANCE_TYPE_NORMAL][level] = i32;
+			else
+				chance[REFINE_CHANCE_TYPE_NORMAL][level] = 100;
+
+			if (libconfig->setting_lookup_int(t, "EnrichedChance", &i32) != 0)
+				chance[REFINE_CHANCE_TYPE_ENRICHED][level] = i32;
+			else
+				chance[REFINE_CHANCE_TYPE_ENRICHED][level] = level > 10 ? 0 : 100; // enriched ores up to +10 only.
+
+			if (libconfig->setting_lookup_int(t, "EventNormalChance", &i32) != 0)
+				chance[REFINE_CHANCE_TYPE_E_NORMAL][level] = i32;
+			else
+				chance[REFINE_CHANCE_TYPE_E_NORMAL][level] = 100;
+
+			if (libconfig->setting_lookup_int(t, "EventEnrichedChance", &i32) != 0)
+				chance[REFINE_CHANCE_TYPE_E_ENRICHED][level] = i32;
+			else
+				chance[REFINE_CHANCE_TYPE_E_ENRICHED][level] = level > 10 ? 0 : 100; // enriched ores up to +10 only.
+
+			if (libconfig->setting_lookup_int(t, "Bonus", &i32) != 0)
+				bonus[level] += i32;
+
+			if (level >= rnd_bonus_lv - 1)
+				rnd_bonus[level] = rnd_bonus_v * (level - rnd_bonus_lv + 2);
+		}
+		for (i = 0; i < MAX_REFINE; i++) {
+			refine->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_NORMAL][i] = chance[REFINE_CHANCE_TYPE_NORMAL][i];
+			refine->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_NORMAL][i] = chance[REFINE_CHANCE_TYPE_E_NORMAL][i];
+			refine->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_ENRICHED][i];
+			refine->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_E_ENRICHED][i];
+			refine->dbs->refine_info[type].randombonus_max[i] = rnd_bonus[i];
+			bonus[i] += bonus_per_level + (i > 0 ? bonus[i - 1] : 0);
+			refine->dbs->refine_info[type].bonus[i] = bonus[i];
+		}
+	} else {
+		ShowWarning("status_readdb_refine_libconfig_sub: Missing refine rates for entry '%s' in \"%s\", skipping.\n", name, source);
+		return 0;
+	}
+
+	return type + 1;
+}
+
+/// @copydoc refine_interface_private::readdb_refine_libconfig()
+static int refine_readdb_refine_libconfig(const char *filename)
+{
+	bool duplicate[REFINE_TYPE_MAX];
+	struct config_t refine_db_conf;
+	struct config_setting_t *r;
+	char filepath[256];
+	int i = 0, count = 0;
+
+	safesnprintf(filepath, sizeof(filepath), "%s/%s", map->db_path, filename);
+	if (!libconfig->load_file(&refine_db_conf, filepath))
+		return 0;
+
+	memset(&duplicate, 0, sizeof(duplicate));
+
+	while((r = libconfig->setting_get_elem(refine_db_conf.root, i++))) {
+		char *name = config_setting_name(r);
+		int type = refine->p->readdb_refine_libconfig_sub(r, name, filename);
+		if (type != 0) {
+			if (duplicate[type - 1]) {
+				ShowWarning("status_readdb_refine_libconfig: duplicate entry for %s in \"%s\", overwriting previous entry...\n", name, filename);
+			} else {
+				duplicate[type - 1] = true;
+			}
+			count++;
+		}
+	}
+	libconfig->destroy(&refine_db_conf);
+	ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
+
+	return count;
+}
+
+/// @copydoc refine_interface::init()
+static int refine_init(bool minimal)
+{
+	if (minimal)
+		return 0;
+
+	refine->p->readdb_refine_libconfig(DBPATH"refine_db.conf");
+	return 0;
+}
+
+/// @copydoc refine_interface::final()
+static void refine_final(void)
+{
+}
+
+void refine_defaults(void)
+{
+	refine = &refine_s;
+	refine->p = &refine_p;
+
+	refine->p->readdb_refine_libconfig = refine_readdb_refine_libconfig;
+	refine->p->readdb_refine_libconfig_sub = refine_readdb_refine_libconfig_sub;
+
+	refine->dbs = &refine_dbs;
+	refine->init = refine_init;
+	refine->final = refine_final;
+	refine->get_refine_chance = refine_get_refine_chance;
+}
diff --git a/src/map/refine.h b/src/map/refine.h
new file mode 100644
index 000000000..6e7506be7
--- /dev/null
+++ b/src/map/refine.h
@@ -0,0 +1,107 @@
+/**
+* This file is part of Hercules.
+* http://herc.ws - http://github.com/HerculesWS/Hercules
+*
+* Copyright (C) 2019  Hercules Dev Team
+*
+* Hercules is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef MAP_REFINE_H
+#define MAP_REFINE_H
+
+/** @file
+ * Refine Interface.
+ **/
+#include "common/hercules.h"
+
+/* Defines */
+/**
+* Max Refine available to your server
+* Changing this limit requires edits to refine_db.conf
+**/
+#ifdef RENEWAL
+	#define MAX_REFINE 20
+#else
+	#define MAX_REFINE 10
+#endif
+
+/* Forward Declarations */
+struct refine_interface_private;
+
+/* Enums */
+enum refine_type {
+	REFINE_TYPE_ARMOR   = 0,
+	REFINE_TYPE_WEAPON1 = 1,
+	REFINE_TYPE_WEAPON2 = 2,
+	REFINE_TYPE_WEAPON3 = 3,
+	REFINE_TYPE_WEAPON4 = 4,
+#ifndef REFINE_TYPE_MAX
+	REFINE_TYPE_MAX     = 5
+#endif
+};
+
+enum refine_chance_type {
+	REFINE_CHANCE_TYPE_NORMAL     = 0, // Normal Chance
+	REFINE_CHANCE_TYPE_ENRICHED   = 1, // Enriched Ore Chance
+	REFINE_CHANCE_TYPE_E_NORMAL   = 2, // Event Normal Ore Chance
+	REFINE_CHANCE_TYPE_E_ENRICHED = 3, // Event Enriched Ore Chance
+	REFINE_CHANCE_TYPE_MAX
+};
+
+/* Structures */
+struct s_refine_info {
+	int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; // success chance
+	int bonus[MAX_REFINE];                          // cumulative fixed bonus damage
+	int randombonus_max[MAX_REFINE];                // cumulative maximum random bonus damage
+};
+
+struct refine_interface_dbs {
+	struct s_refine_info refine_info[REFINE_TYPE_MAX];
+};
+
+/**
+ * Refine Interface
+ **/
+struct refine_interface {
+	struct refine_interface_private *p;
+	struct refine_interface_dbs *dbs;
+
+	/**
+	 * Initialize refine system
+	 * @param minimal sets refine system to minimal mode in which it won't load or initialize itself
+	 * @return returns 0 in-case of success 1 otherwise
+	 **/
+	int (*init)(bool minimal);
+
+	/**
+	 * Finalize refine system
+	 **/
+	void (*final)(void);
+
+	/**
+	 * Get the chance to upgrade a piece of equipment.
+	 * @param wlv The weapon type of the item to refine (see see enum refine_type)
+	 * @param refine The target refine level
+	 * @return The chance to refine the item, in percent (0~100)
+	 **/
+	int (*get_refine_chance) (enum refine_type wlv, int refine_level, enum refine_chance_type type);
+};
+
+#ifdef HERCULES_CORE
+void refine_defaults(void);
+#endif
+
+HPShared struct refine_interface *refine;
+#endif
\ No newline at end of file
diff --git a/src/map/refine.p.h b/src/map/refine.p.h
new file mode 100644
index 000000000..4d6f403bb
--- /dev/null
+++ b/src/map/refine.p.h
@@ -0,0 +1,58 @@
+/**
+* This file is part of Hercules.
+* http://herc.ws - http://github.com/HerculesWS/Hercules
+*
+* Copyright (C) 2019  Hercules Dev Team
+*
+* Hercules is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef MAP_REFINE_P_H
+#define MAP_REFINE_P_H
+
+/** @file
+ * Private header for the refine interface.
+ **/
+
+#include "refine.h"
+#include "common/conf.h"
+
+/**
+ * Refine Private Interface
+ **/
+struct refine_interface_private {
+	/**
+	 * Processes a refine_db.conf entry.
+	 *
+	 * @param r      Libconfig setting entry. It is expected to be valid and it
+	 *               won't be freed (it is care of the caller to do so if
+	 *               necessary)
+	 * @param n      Ordinal number of the entry, to be displayed in case of
+	 *               validation errors.
+	 * @param source Source of the entry (file name), to be displayed in case of
+	 *               validation errors.
+	 * @return # of the validated entry, or 0 in case of failure.
+	 **/
+	int (*readdb_refine_libconfig_sub) (struct config_setting_t *r, const char *name, const char *source);
+
+	/**
+	 * Reads from a libconfig-formatted refine_db.conf file.
+	 *
+	 * @param *filename File name, relative to the database path.
+	 * @return The number of found entries.
+	 **/
+	int (*readdb_refine_libconfig) (const char *filename);
+};
+
+#endif
diff --git a/src/map/script.c b/src/map/script.c
index 4fb24708b..1cc1d3ad2 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -52,6 +52,7 @@
 #include "map/pet.h"
 #include "map/pet.h"
 #include "map/quest.h"
+#include "map/refine.h"
 #include "map/skill.h"
 #include "map/status.h"
 #include "map/status.h"
@@ -9505,7 +9506,7 @@ static BUILDIN(getequippercentrefinery)
 
 	if (i >= 0 && sd->status.inventory[i].nameid != 0 && sd->status.inventory[i].refine < MAX_REFINE)
 		script_pushint(st,
-			status->get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int) sd->status.inventory[i].refine, (enum refine_chance_type) type));
+			refine->get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int) sd->status.inventory[i].refine, (enum refine_chance_type) type));
 	else
 		script_pushint(st, 0);
 
diff --git a/src/map/skill.c b/src/map/skill.c
index 633a73d67..2b2c2b6f1 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -44,6 +44,7 @@
 #include "map/path.h"
 #include "map/pc.h"
 #include "map/pet.h"
+#include "map/refine.h"
 #include "map/script.h"
 #include "map/status.h"
 #include "map/unit.h"
@@ -16204,7 +16205,7 @@ static void skill_weaponrefine(struct map_session_data *sd, int idx)
 				return;
 			}
 
-			per = status->get_refine_chance(ditem->wlv, (int)item->refine, REFINE_CHANCE_TYPE_NORMAL) * 10;
+			per = refine->get_refine_chance(ditem->wlv, (int)item->refine, REFINE_CHANCE_TYPE_NORMAL) * 10;
 
 			// Aegis leaked formula. [malufett]
 			if (sd->status.class == JOB_MECHANIC_T)
diff --git a/src/map/status.c b/src/map/status.c
index f06bb0330..085e951b6 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -38,6 +38,7 @@
 #include "map/path.h"
 #include "map/pc.h"
 #include "map/pet.h"
+#include "map/refine.h"
 #include "map/script.h"
 #include "map/skill.h"
 #include "map/skill.h"
@@ -2577,18 +2578,18 @@ static int status_calc_pc_(struct map_session_data *sd, enum e_status_calc_opt o
 				r = 0;
 
 			if (r)
-				wa->atk2 = status->dbs->refine_info[wlv].bonus[r-1] / 100;
+				wa->atk2 = refine->dbs->refine_info[wlv].bonus[r-1] / 100;
 
 #ifdef RENEWAL
 			wa->matk += sd->inventory_data[index]->matk;
 			wa->wlv = wlv;
 			if( r && sd->weapontype1 != W_BOW ) // renewal magic attack refine bonus
-				wa->matk += status->dbs->refine_info[wlv].bonus[r-1] / 100;
+				wa->matk += refine->dbs->refine_info[wlv].bonus[r-1] / 100;
 #endif
 
 			//Overrefined bonus.
 			if (r)
-				wd->overrefine = status->dbs->refine_info[wlv].randombonus_max[r-1] / 100;
+				wd->overrefine = refine->dbs->refine_info[wlv].randombonus_max[r-1] / 100;
 
 			wa->range += sd->inventory_data[index]->range;
 			if(sd->inventory_data[index]->script) {
@@ -2623,7 +2624,7 @@ static int status_calc_pc_(struct map_session_data *sd, enum e_status_calc_opt o
 				r = 0;
 
 			if (r)
-				refinedef += status->dbs->refine_info[REFINE_TYPE_ARMOR].bonus[r-1];
+				refinedef += refine->dbs->refine_info[REFINE_TYPE_ARMOR].bonus[r-1];
 
 			if(sd->inventory_data[index]->script) {
 				if( i == EQI_HAND_L ) //Shield
@@ -13076,25 +13077,6 @@ static int status_natural_heal_timer(int tid, int64 tick, int id, intptr_t data)
 	return 0;
 }
 
-/**
- * Get the chance to upgrade a piece of equipment.
- * @param wlv The weapon type of the item to refine (see see enum refine_type)
- * @param refine The target refine level
- * @return The chance to refine the item, in percent (0~100)
- */
-static int status_get_refine_chance(enum refine_type wlv, int refine, enum refine_chance_type type)
-{
-	Assert_ret((int)wlv >= REFINE_TYPE_ARMOR && wlv < REFINE_TYPE_MAX);
-
-	if (refine < 0 || refine >= MAX_REFINE)
-		return 0;
-
-	if (type >= REFINE_CHANCE_TYPE_MAX)
-		return 0;
-
-	return status->dbs->refine_info[wlv].chance[type][refine];
-}
-
 static int status_get_sc_type(sc_type type)
 {
 
@@ -13405,171 +13387,6 @@ static bool status_readdb_sizefix(char *fields[], int columns, int current)
 	return true;
 }
 
-/**
- * Processes a refine_db.conf entry.
- *
- * @param r      Libconfig setting entry. It is expected to be valid and it
- *               won't be freed (it is care of the caller to do so if
- *               necessary)
- * @param n      Ordinal number of the entry, to be displayed in case of
- *               validation errors.
- * @param source Source of the entry (file name), to be displayed in case of
- *               validation errors.
- * @return # of the validated entry, or 0 in case of failure.
- */
-static int status_readdb_refine_libconfig_sub(struct config_setting_t *r, const char *name, const char *source)
-{
-	struct config_setting_t *rate = NULL;
-	int type = REFINE_TYPE_ARMOR, bonus_per_level = 0, rnd_bonus_v = 0, rnd_bonus_lv = 0;
-	char lv[4];
-	nullpo_ret(r);
-	nullpo_ret(name);
-	nullpo_ret(source);
-
-	if (strncmp(name, "Armors", 6) == 0) {
-		type = REFINE_TYPE_ARMOR;
-	} else if (strncmp(name, "WeaponLevel", 11) != 0 || !strspn(&name[strlen(name)-1], "0123456789") || (type = atoi(strncpy(lv, name+11, 2))) == REFINE_TYPE_ARMOR) {
-		ShowError("status_readdb_refine_libconfig_sub: Invalid key name for entry '%s' in \"%s\", skipping.\n", name, source);
-		return 0;
-	}
-	if (type < REFINE_TYPE_ARMOR || type >= REFINE_TYPE_MAX) {
-		ShowError("status_readdb_refine_libconfig_sub: Out of range level for entry '%s' in \"%s\", skipping.\n", name, source);
-		return 0;
-	}
-	if (!libconfig->setting_lookup_int(r, "StatsPerLevel", &bonus_per_level)) {
-		ShowWarning("status_readdb_refine_libconfig_sub: Missing StatsPerLevel for entry '%s' in \"%s\", skipping.\n", name, source);
-		return 0;
-	}
-	if (!libconfig->setting_lookup_int(r, "RandomBonusStartLevel", &rnd_bonus_lv)) {
-		ShowWarning("status_readdb_refine_libconfig_sub: Missing RandomBonusStartLevel for entry '%s' in \"%s\", skipping.\n", name, source);
-		return 0;
-	}
-	if (!libconfig->setting_lookup_int(r, "RandomBonusValue", &rnd_bonus_v)) {
-		ShowWarning("status_readdb_refine_libconfig_sub: Missing RandomBonusValue for entry '%s' in \"%s\", skipping.\n", name, source);
-		return 0;
-	}
-
-	if ((rate=libconfig->setting_get_member(r, "Rates")) != NULL && config_setting_is_group(rate)) {
-		struct config_setting_t *t = NULL;
-		bool duplicate[MAX_REFINE];
-		int bonus[MAX_REFINE], rnd_bonus[MAX_REFINE];
-		int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE];
-		int i, j;
-
-		memset(&duplicate, 0, sizeof(duplicate));
-		memset(&bonus, 0, sizeof(bonus));
-		memset(&rnd_bonus, 0, sizeof(rnd_bonus));
-
-		for (i = 0; i < REFINE_CHANCE_TYPE_MAX; i++)
-			for (j = 0; j < MAX_REFINE; j++)
-				chance[i][j] = 100; // default value for all rates.
-
-		i = 0;
-		j = 0;
-		while ((t = libconfig->setting_get_elem(rate,i++)) != NULL && config_setting_is_group(t)) {
-			int level = 0, i32;
-			char *rlvl = config_setting_name(t);
-			memset(&lv, 0, sizeof(lv));
-
-			if (!strspn(&rlvl[strlen(rlvl) - 1], "0123456789") || (level = atoi(strncpy(lv, rlvl + 2, 3))) <= 0) {
-				ShowError("status_readdb_refine_libconfig_sub: Invalid refine level format '%s' for entry %s in \"%s\"... skipping.\n", rlvl, name, source);
-				continue;
-			}
-
-			if (level <= 0 || level > MAX_REFINE) {
-				ShowError("status_readdb_refine_libconfig_sub: Out of range refine level '%s' for entry %s in \"%s\"... skipping.\n", rlvl, name, source);
-				continue;
-			}
-
-			level--;
-
-			if (duplicate[level]) {
-				ShowWarning("status_readdb_refine_libconfig_sub: duplicate rate '%s' for entry %s in \"%s\", overwriting previous entry...\n", rlvl, name, source);
-			} else {
-				duplicate[level] = true;
-			}
-
-			if (libconfig->setting_lookup_int(t, "NormalChance", &i32) != 0)
-				chance[REFINE_CHANCE_TYPE_NORMAL][level] = i32;
-			else
-				chance[REFINE_CHANCE_TYPE_NORMAL][level] = 100;
-
-			if (libconfig->setting_lookup_int(t, "EnrichedChance", &i32) != 0)
-				chance[REFINE_CHANCE_TYPE_ENRICHED][level] = i32;
-			else
-				chance[REFINE_CHANCE_TYPE_ENRICHED][level] = level > 10 ? 0 : 100; // enriched ores up to +10 only.
-
-			if (libconfig->setting_lookup_int(t, "EventNormalChance", &i32) != 0)
-				chance[REFINE_CHANCE_TYPE_E_NORMAL][level] = i32;
-			else
-				chance[REFINE_CHANCE_TYPE_E_NORMAL][level] = 100;
-
-			if (libconfig->setting_lookup_int(t, "EventEnrichedChance", &i32) != 0)
-				chance[REFINE_CHANCE_TYPE_E_ENRICHED][level] = i32;
-			else
-				chance[REFINE_CHANCE_TYPE_E_ENRICHED][level] = level > 10 ? 0 : 100; // enriched ores up to +10 only.
-
-			if (libconfig->setting_lookup_int(t, "Bonus", &i32) != 0)
-				bonus[level] += i32;
-
-			if (level >= rnd_bonus_lv - 1)
-				rnd_bonus[level] = rnd_bonus_v * (level - rnd_bonus_lv + 2);
-		}
-		for (i = 0; i < MAX_REFINE; i++) {
-			status->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_NORMAL][i] = chance[REFINE_CHANCE_TYPE_NORMAL][i];
-			status->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_NORMAL][i] = chance[REFINE_CHANCE_TYPE_E_NORMAL][i];
-			status->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_ENRICHED][i];
-			status->dbs->refine_info[type].chance[REFINE_CHANCE_TYPE_E_ENRICHED][i] = chance[REFINE_CHANCE_TYPE_E_ENRICHED][i];
-			status->dbs->refine_info[type].randombonus_max[i] = rnd_bonus[i];
-			bonus[i] += bonus_per_level + (i > 0 ? bonus[i - 1] : 0);
-			status->dbs->refine_info[type].bonus[i] = bonus[i];
-		}
-	} else {
-		ShowWarning("status_readdb_refine_libconfig_sub: Missing refine rates for entry '%s' in \"%s\", skipping.\n", name, source);
-		return 0;
-	}
-
-	return type + 1;
-}
-
-/**
- * Reads from a libconfig-formatted refine_db.conf file.
- *
- * @param *filename File name, relative to the database path.
- * @return The number of found entries.
- */
-static int status_readdb_refine_libconfig(const char *filename)
-{
-	bool duplicate[REFINE_TYPE_MAX];
-	struct config_t refine_db_conf;
-	struct config_setting_t *r;
-	char filepath[256];
-	int i = 0, count = 0;
-
-	safesnprintf(filepath, sizeof(filepath), "%s/%s", map->db_path, filename);
-	if (!libconfig->load_file(&refine_db_conf, filepath))
-		return 0;
-
-	memset(&duplicate,0,sizeof(duplicate));
-
-	while((r = libconfig->setting_get_elem(refine_db_conf.root,i++))) {
-		char *name = config_setting_name(r);
-		int type = status->readdb_refine_libconfig_sub(r, name, filename);
-		if (type != 0) {
-			if (duplicate[type-1]) {
-				ShowWarning("status_readdb_refine_libconfig: duplicate entry for %s in \"%s\", overwriting previous entry...\n", name, filename);
-			} else {
-				duplicate[type-1] = true;
-			}
-			count++;
-		}
-	}
-	libconfig->destroy(&refine_db_conf);
-	ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
-
-	return count;
-}
-
 static bool status_readdb_scconfig(char *fields[], int columns, int current)
 {
 	int val = 0;
@@ -13627,7 +13444,6 @@ static int status_readdb(void)
 	//
 	sv->readdb(map->db_path, "job_db2.txt",         ',', 1,                 1+MAX_LEVEL,       -1,                       status->readdb_job2);
 	sv->readdb(map->db_path, DBPATH"size_fix.txt", ',', MAX_SINGLE_WEAPON_TYPE, MAX_SINGLE_WEAPON_TYPE, ARRAYLENGTH(status->dbs->atkmods), status->readdb_sizefix);
-	status->readdb_refine_libconfig(DBPATH"refine_db.conf");
 	sv->readdb(map->db_path, "sc_config.txt",       ',', 2,                 2,                 SC_MAX,                   status->readdb_scconfig);
 	status->read_job_db();
 
@@ -13685,7 +13501,6 @@ void status_defaults(void)
 	status->natural_heal_prev_tick = 0;
 	status->natural_heal_diff_tick = 0;
 	/* funcs */
-	status->get_refine_chance = status_get_refine_chance;
 	// for looking up associated data
 	status->skill2sc = status_skill2sc;
 	status->sc2skill = status_sc2skill;
@@ -13819,8 +13634,6 @@ void status_defaults(void)
 	status->natural_heal_timer = status_natural_heal_timer;
 	status->readdb_job2 = status_readdb_job2;
 	status->readdb_sizefix = status_readdb_sizefix;
-	status->readdb_refine_libconfig = status_readdb_refine_libconfig;
-	status->readdb_refine_libconfig_sub = status_readdb_refine_libconfig_sub;
 	status->readdb_scconfig = status_readdb_scconfig;
 	status->read_job_db = status_read_job_db;
 	status->read_job_db_sub = status_read_job_db_sub;
diff --git a/src/map/status.h b/src/map/status.h
index 17af22703..79aaca95f 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -48,27 +48,6 @@ struct pet_data;
 	) \
 )
 
-/**
- * Max Refine available to your server
- * Changing this limit requires edits to refine_db.txt
- **/
-#ifdef RENEWAL
-	#define MAX_REFINE 20
-#else
-	#define MAX_REFINE 10
-#endif
-
-enum refine_type {
-	REFINE_TYPE_ARMOR   = 0,
-	REFINE_TYPE_WEAPON1 = 1,
-	REFINE_TYPE_WEAPON2 = 2,
-	REFINE_TYPE_WEAPON3 = 3,
-	REFINE_TYPE_WEAPON4 = 4,
-#ifndef REFINE_TYPE_MAX
-	REFINE_TYPE_MAX     = 5
-#endif
-};
-
 /**
  * SC configuration type
  * @see db/sc_config.txt for more information
@@ -2249,21 +2228,6 @@ struct status_change {
 #define status_calc_elemental(ed, opt)  (status->calc_bl_(&(ed)->bl, SCB_ALL, (opt)))
 #define status_calc_npc(nd, opt)        (status->calc_bl_(&(nd)->bl, SCB_ALL, (opt)))
 
-enum refine_chance_type {
-	REFINE_CHANCE_TYPE_NORMAL     = 0, // Normal Chance
-	REFINE_CHANCE_TYPE_ENRICHED   = 1, // Enriched Ore Chance
-	REFINE_CHANCE_TYPE_E_NORMAL   = 2, // Event Normal Ore Chance
-	REFINE_CHANCE_TYPE_E_ENRICHED = 3, // Event Enriched Ore Chance
-	REFINE_CHANCE_TYPE_MAX
-};
-
-// bonus values and upgrade chances for refining equipment
-struct s_refine_info {
-	int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; // success chance
-	int bonus[MAX_REFINE]; // cumulative fixed bonus damage
-	int randombonus_max[MAX_REFINE]; // cumulative maximum random bonus damage
-};
-
 struct s_status_dbs {
 BEGIN_ZEROED_BLOCK; /* Everything within this block will be memset to 0 when status_defaults() is executed */
 	int max_weight_base[CLASS_COUNT];
@@ -2277,8 +2241,6 @@ BEGIN_ZEROED_BLOCK; /* Everything within this block will be memset to 0 when sta
 	int RelevantBLTypes[SI_MAX];          // "icon" -> enum bl_type (for clif->status_change to identify for which bl types to send packets)
 	bool DisplayType[SC_MAX];
 	/* */
-	struct s_refine_info refine_info[REFINE_TYPE_MAX];
-	/* */
 	int atkmods[3][MAX_SINGLE_WEAPON_TYPE];//ATK weapon modification for size (size_fix.txt)
 	char job_bonus[CLASS_COUNT][MAX_LEVEL];
 	sc_conf_type sc_conf[SC_MAX];
@@ -2307,7 +2269,6 @@ struct status_interface {
 	int (*init) (bool minimal);
 	void (*final) (void);
 	/* funcs */
-	int (*get_refine_chance) (enum refine_type wlv, int refine, enum refine_chance_type type);
 	// for looking up associated data
 	sc_type (*skill2sc) (int skill_id);
 	int (*sc2skill) (sc_type sc);
@@ -2427,8 +2388,6 @@ struct status_interface {
 	int (*natural_heal_timer) (int tid, int64 tick, int id, intptr_t data);
 	bool (*readdb_job2) (char *fields[], int columns, int current);
 	bool (*readdb_sizefix) (char *fields[], int columns, int current);
-	int (*readdb_refine_libconfig) (const char *filename);
-	int (*readdb_refine_libconfig_sub) (struct config_setting_t *r, const char *name, const char *source);
 	bool (*readdb_scconfig) (char *fields[], int columns, int current);
 	void (*read_job_db) (void);
 	void (*read_job_db_sub) (int idx, const char *name, struct config_setting_t *jdb);
diff --git a/vcproj-12/map-server.vcxproj b/vcproj-12/map-server.vcxproj
index 72bae9d97..34f55be49 100644
--- a/vcproj-12/map-server.vcxproj
+++ b/vcproj-12/map-server.vcxproj
@@ -213,6 +213,8 @@
     <ClInclude Include="..\src\config\renewal.h" />
     <ClInclude Include="..\src\config\secure.h" />
     <ClInclude Include="..\src\config\classes\general.h" />
+    <ClInclude Include="..\src\map\refine.h" />
+    <ClInclude Include="..\src\map\refine.p.h" />
     <ClInclude Include="..\src\map\rodex.h" />
     <ClInclude Include="..\src\map\script.h" />
     <ClInclude Include="..\src\map\searchstore.h" />
@@ -288,6 +290,7 @@
     <ClCompile Include="..\src\map\pc_groups.c" />
     <ClCompile Include="..\src\map\pet.c" />
     <ClCompile Include="..\src\map\quest.c" />
+    <ClCompile Include="..\src\map\refine.c" />
     <ClCompile Include="..\src\map\rodex.c" />
     <ClCompile Include="..\src\map\script.c" />
     <ClCompile Include="..\src\map\searchstore.c" />
diff --git a/vcproj-12/map-server.vcxproj.filters b/vcproj-12/map-server.vcxproj.filters
index 6734c65bf..aae670525 100644
--- a/vcproj-12/map-server.vcxproj.filters
+++ b/vcproj-12/map-server.vcxproj.filters
@@ -220,6 +220,9 @@
     <ClCompile Include="..\src\map\rodex.c">
       <Filter>map</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\map\refine.c">
+      <Filter>map</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\src\map\achievement.h">
@@ -501,6 +504,12 @@
     <ClInclude Include="..\src\map\rodex.h">
       <Filter>map</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\map\refine.p.h">
+      <Filter>map</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\map\refine.h">
+      <Filter>map</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Filter Include="common">
diff --git a/vcproj-14/map-server.vcxproj b/vcproj-14/map-server.vcxproj
index b17990588..ed91f231d 100644
--- a/vcproj-14/map-server.vcxproj
+++ b/vcproj-14/map-server.vcxproj
@@ -211,6 +211,8 @@
     <ClInclude Include="..\src\config\renewal.h" />
     <ClInclude Include="..\src\config\secure.h" />
     <ClInclude Include="..\src\config\classes\general.h" />
+    <ClInclude Include="..\src\map\refine.h" />
+    <ClInclude Include="..\src\map\refine.p.h" />
     <ClInclude Include="..\src\map\rodex.h" />
     <ClInclude Include="..\src\map\script.h" />
     <ClInclude Include="..\src\map\searchstore.h" />
@@ -286,6 +288,7 @@
     <ClCompile Include="..\src\map\pc_groups.c" />
     <ClCompile Include="..\src\map\pet.c" />
     <ClCompile Include="..\src\map\quest.c" />
+    <ClCompile Include="..\src\map\refine.c" />
     <ClCompile Include="..\src\map\rodex.c" />
     <ClCompile Include="..\src\map\script.c" />
     <ClCompile Include="..\src\map\searchstore.c" />
diff --git a/vcproj-14/map-server.vcxproj.filters b/vcproj-14/map-server.vcxproj.filters
index c8e64d8fd..3f1b6ca4b 100644
--- a/vcproj-14/map-server.vcxproj.filters
+++ b/vcproj-14/map-server.vcxproj.filters
@@ -220,6 +220,9 @@
     <ClCompile Include="..\src\map\clan.c">
       <Filter>map</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\map\refine.c">
+      <Filter>map</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\src\map\achievement.h">
@@ -501,6 +504,12 @@
     <ClInclude Include="..\src\map\clan.h">
       <Filter>map</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\map\refine.h">
+      <Filter>map</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\map\refine.p.h">
+      <Filter>map</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Filter Include="common">
diff --git a/vcproj-15/map-server.vcxproj b/vcproj-15/map-server.vcxproj
index c7a83fa39..8becb90cc 100644
--- a/vcproj-15/map-server.vcxproj
+++ b/vcproj-15/map-server.vcxproj
@@ -212,6 +212,8 @@
     <ClInclude Include="..\src\config\renewal.h" />
     <ClInclude Include="..\src\config\secure.h" />
     <ClInclude Include="..\src\config\classes\general.h" />
+    <ClInclude Include="..\src\map\refine.h" />
+    <ClInclude Include="..\src\map\refine.p.h" />
     <ClInclude Include="..\src\map\rodex.h" />
     <ClInclude Include="..\src\map\script.h" />
     <ClInclude Include="..\src\map\searchstore.h" />
@@ -287,6 +289,7 @@
     <ClCompile Include="..\src\map\pc_groups.c" />
     <ClCompile Include="..\src\map\pet.c" />
     <ClCompile Include="..\src\map\quest.c" />
+    <ClCompile Include="..\src\map\refine.c" />
     <ClCompile Include="..\src\map\rodex.c" />
     <ClCompile Include="..\src\map\script.c" />
     <ClCompile Include="..\src\map\searchstore.c" />
diff --git a/vcproj-15/map-server.vcxproj.filters b/vcproj-15/map-server.vcxproj.filters
index 2a3d1b489..087a700e9 100644
--- a/vcproj-15/map-server.vcxproj.filters
+++ b/vcproj-15/map-server.vcxproj.filters
@@ -2,7 +2,7 @@
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
     <ClCompile Include="..\src\map\achievement.c">
-  	  <Filter>map</Filter>
+      <Filter>map</Filter>
     </ClCompile>
     <ClCompile Include="..\src\map\atcommand.c">
       <Filter>map</Filter>
@@ -220,6 +220,9 @@
     <ClCompile Include="..\src\map\rodex.c">
       <Filter>map</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\map\refine.c">
+      <Filter>map</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\src\map\achievement.h">
@@ -501,6 +504,12 @@
     <ClInclude Include="..\src\map\rodex.h">
       <Filter>map</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\map\refine.p.h">
+      <Filter>map</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\map\refine.h">
+      <Filter>map</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Filter Include="common">
-- 
cgit v1.2.3-70-g09d2


From 7c7ec206678d2a7f22cfc3566fe8bdddae965e41 Mon Sep 17 00:00:00 2001
From: Asheraf <acheraf1998@gmail.com>
Date: Sat, 16 Nov 2019 19:04:36 +0100
Subject: Replace the windows mysql connector with MariaDB C Connector 3.1.5 /
 Client Lib 10.4.3

---
 3rdparty/mariadb/include/client_plugin.h           |  244 ++++
 3rdparty/mariadb/include/errmsg.h                  |  107 ++
 3rdparty/mariadb/include/ma_io.h                   |   55 +
 3rdparty/mariadb/include/ma_list.h                 |   47 +
 3rdparty/mariadb/include/ma_pvio.h                 |  133 ++
 3rdparty/mariadb/include/ma_tls.h                  |  161 +++
 3rdparty/mariadb/include/mariadb_com.h             |  457 +++++++
 3rdparty/mariadb/include/mariadb_ctype.h           |   76 ++
 3rdparty/mariadb/include/mariadb_dyncol.h          |  256 ++++
 3rdparty/mariadb/include/mariadb_rpl.h             |  305 +++++
 3rdparty/mariadb/include/mariadb_stmt.h            |  298 +++++
 3rdparty/mariadb/include/mariadb_version.h         |   38 +
 3rdparty/mariadb/include/mysql.h                   |  868 +++++++++++++
 3rdparty/mariadb/include/mysqld_error.h            | 1126 +++++++++++++++++
 3rdparty/mariadb/include/plugin_auth.h             |  107 ++
 3rdparty/mariadb/include/plugin_auth_common.h      |  110 ++
 3rdparty/mariadb/lib/libmariadb.lib                |  Bin 0 -> 53148 bytes
 3rdparty/mariadb/lib/plugin/auth_gssapi_client.dll |  Bin 0 -> 402856 bytes
 .../mariadb/lib/plugin/caching_sha2_password.dll   |  Bin 0 -> 423336 bytes
 3rdparty/mariadb/lib/plugin/client_ed25519.dll     |  Bin 0 -> 477096 bytes
 3rdparty/mariadb/lib/plugin/dialog.dll             |  Bin 0 -> 406440 bytes
 .../mariadb/lib/plugin/mysql_clear_password.dll    |  Bin 0 -> 397736 bytes
 3rdparty/mariadb/lib/plugin/pvio_npipe.dll         |  Bin 0 -> 399272 bytes
 3rdparty/mariadb/lib/plugin/pvio_shmem.dll         |  Bin 0 -> 400808 bytes
 3rdparty/mariadb/lib/plugin/sha256_password.dll    |  Bin 0 -> 421800 bytes
 3rdparty/mysql/include/config-win.h                |  470 -------
 3rdparty/mysql/include/m_ctype.h                   |  493 --------
 3rdparty/mysql/include/my_alloc.h                  |   52 -
 3rdparty/mysql/include/my_dbug.h                   |  101 --
 3rdparty/mysql/include/my_global.h                 | 1306 --------------------
 3rdparty/mysql/include/my_list.h                   |   46 -
 3rdparty/mysql/include/my_pthread.h                |  717 -----------
 3rdparty/mysql/include/my_sys.h                    |  904 --------------
 3rdparty/mysql/include/mysql.h                     |  847 -------------
 3rdparty/mysql/include/mysql_com.h                 |  452 -------
 3rdparty/mysql/include/mysql_time.h                |   56 -
 3rdparty/mysql/include/mysql_version.h             |   29 -
 3rdparty/mysql/include/raid.h                      |  159 ---
 3rdparty/mysql/include/typelib.h                   |   34 -
 3rdparty/mysql/lib/libmysql.lib                    |  Bin 34900 -> 0 bytes
 3rdparty/mysql/mysql-5.0.20                        |    0
 libmariadb.dll                                     |  Bin 0 -> 530432 bytes
 libmysql.dll                                       |  Bin 1449984 -> 0 bytes
 src/common/sql.c                                   |    3 +
 vcproj-14/char-server.vcxproj                      |   12 +-
 vcproj-14/login-server.vcxproj                     |   12 +-
 vcproj-14/map-server.vcxproj                       |   12 +-
 vcproj-15/char-server.vcxproj                      |   12 +-
 vcproj-15/login-server.vcxproj                     |   12 +-
 vcproj-15/map-server.vcxproj                       |   12 +-
 vcproj-16/char-server.vcxproj                      |   12 +-
 vcproj-16/login-server.vcxproj                     |   12 +-
 vcproj-16/map-server.vcxproj                       |   12 +-
 53 files changed, 4445 insertions(+), 5720 deletions(-)
 create mode 100644 3rdparty/mariadb/include/client_plugin.h
 create mode 100644 3rdparty/mariadb/include/errmsg.h
 create mode 100644 3rdparty/mariadb/include/ma_io.h
 create mode 100644 3rdparty/mariadb/include/ma_list.h
 create mode 100644 3rdparty/mariadb/include/ma_pvio.h
 create mode 100644 3rdparty/mariadb/include/ma_tls.h
 create mode 100644 3rdparty/mariadb/include/mariadb_com.h
 create mode 100644 3rdparty/mariadb/include/mariadb_ctype.h
 create mode 100644 3rdparty/mariadb/include/mariadb_dyncol.h
 create mode 100644 3rdparty/mariadb/include/mariadb_rpl.h
 create mode 100644 3rdparty/mariadb/include/mariadb_stmt.h
 create mode 100644 3rdparty/mariadb/include/mariadb_version.h
 create mode 100644 3rdparty/mariadb/include/mysql.h
 create mode 100644 3rdparty/mariadb/include/mysqld_error.h
 create mode 100644 3rdparty/mariadb/include/plugin_auth.h
 create mode 100644 3rdparty/mariadb/include/plugin_auth_common.h
 create mode 100644 3rdparty/mariadb/lib/libmariadb.lib
 create mode 100644 3rdparty/mariadb/lib/plugin/auth_gssapi_client.dll
 create mode 100644 3rdparty/mariadb/lib/plugin/caching_sha2_password.dll
 create mode 100644 3rdparty/mariadb/lib/plugin/client_ed25519.dll
 create mode 100644 3rdparty/mariadb/lib/plugin/dialog.dll
 create mode 100644 3rdparty/mariadb/lib/plugin/mysql_clear_password.dll
 create mode 100644 3rdparty/mariadb/lib/plugin/pvio_npipe.dll
 create mode 100644 3rdparty/mariadb/lib/plugin/pvio_shmem.dll
 create mode 100644 3rdparty/mariadb/lib/plugin/sha256_password.dll
 delete mode 100644 3rdparty/mysql/include/config-win.h
 delete mode 100644 3rdparty/mysql/include/m_ctype.h
 delete mode 100644 3rdparty/mysql/include/my_alloc.h
 delete mode 100644 3rdparty/mysql/include/my_dbug.h
 delete mode 100644 3rdparty/mysql/include/my_global.h
 delete mode 100644 3rdparty/mysql/include/my_list.h
 delete mode 100644 3rdparty/mysql/include/my_pthread.h
 delete mode 100644 3rdparty/mysql/include/my_sys.h
 delete mode 100644 3rdparty/mysql/include/mysql.h
 delete mode 100644 3rdparty/mysql/include/mysql_com.h
 delete mode 100644 3rdparty/mysql/include/mysql_time.h
 delete mode 100644 3rdparty/mysql/include/mysql_version.h
 delete mode 100644 3rdparty/mysql/include/raid.h
 delete mode 100644 3rdparty/mysql/include/typelib.h
 delete mode 100644 3rdparty/mysql/lib/libmysql.lib
 delete mode 100644 3rdparty/mysql/mysql-5.0.20
 create mode 100644 libmariadb.dll
 delete mode 100644 libmysql.dll

(limited to 'vcproj-15')

diff --git a/3rdparty/mariadb/include/client_plugin.h b/3rdparty/mariadb/include/client_plugin.h
new file mode 100644
index 000000000..ac29afd6f
--- /dev/null
+++ b/3rdparty/mariadb/include/client_plugin.h
@@ -0,0 +1,244 @@
+/* Copyright (C) 2010 - 2012 Sergei Golubchik and Monty Program Ab
+                 2014 MariaDB Corporation AB
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not see <http://www.gnu.org/licenses>
+   or write to the Free Software Foundation, Inc., 
+   51 Franklin St., Fifth Floor, Boston, MA 02110, USA */
+
+/**
+  @file
+
+  MySQL Client Plugin API
+
+  This file defines the API for plugins that work on the client side
+*/
+#ifndef MYSQL_CLIENT_PLUGIN_INCLUDED
+#define MYSQL_CLIENT_PLUGIN_INCLUDED
+
+#ifndef MYSQL_ABI_CHECK
+#include <stdarg.h>
+#include <stdlib.h>
+#endif
+
+
+#ifndef PLUGINDIR
+#define PLUGINDIR "lib/plugin"
+#endif
+
+#define plugin_declarations_sym "_mysql_client_plugin_declaration_"
+
+/* known plugin types */
+#define MYSQL_CLIENT_PLUGIN_RESERVED         0 
+#define MYSQL_CLIENT_PLUGIN_RESERVED2        1
+#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN   2 /* authentication   */
+
+#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION  0x0100
+#define MYSQL_CLIENT_MAX_PLUGINS             3
+
+/* Connector/C specific plugin types */
+#define MARIADB_CLIENT_REMOTEIO_PLUGIN       100 /* communication IO */
+#define MARIADB_CLIENT_PVIO_PLUGIN           101
+#define MARIADB_CLIENT_TRACE_PLUGIN          102
+#define MARIADB_CLIENT_CONNECTION_PLUGIN     103
+
+#define MARIADB_CLIENT_REMOTEIO_PLUGIN_INTERFACE_VERSION 0x0100
+#define MARIADB_CLIENT_PVIO_PLUGIN_INTERFACE_VERSION 0x0100
+#define MARIADB_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION 0x0100
+#define MARIADB_CLIENT_CONNECTION_PLUGIN_INTERFACE_VERSION 0x0100
+
+#define MARIADB_CLIENT_MAX_PLUGINS             4
+
+#define mysql_declare_client_plugin(X)          \
+     struct st_mysql_client_plugin_ ## X        \
+        _mysql_client_plugin_declaration_ = {   \
+          MYSQL_CLIENT_ ## X ## _PLUGIN,        \
+          MYSQL_CLIENT_ ## X ## _PLUGIN_INTERFACE_VERSION,
+#define mysql_end_client_plugin             }
+
+/* generic plugin header structure */
+#ifndef MYSQL_CLIENT_PLUGIN_HEADER
+#define MYSQL_CLIENT_PLUGIN_HEADER                      \
+  int type;                                             \
+  unsigned int interface_version;                       \
+  const char *name;                                     \
+  const char *author;                                   \
+  const char *desc;                                     \
+  unsigned int version[3];                              \
+  const char *license;                                  \
+  void *mysql_api;                                      \
+  int (*init)(char *, size_t, int, va_list);            \
+  int (*deinit)();                                      \
+  int (*options)(const char *option, const void *);
+struct st_mysql_client_plugin
+{
+  MYSQL_CLIENT_PLUGIN_HEADER
+};
+#endif
+
+struct st_mysql;
+
+/********* connection handler plugin specific declarations **********/
+
+typedef struct st_ma_connection_plugin
+{
+  MYSQL_CLIENT_PLUGIN_HEADER
+  /* functions */
+  MYSQL *(*connect)(MYSQL *mysql, const char *host,
+                    const char *user, const char *passwd,
+		                const char *db, unsigned int port,
+                    const char *unix_socket, unsigned long clientflag);
+  void (*close)(MYSQL *mysql);
+  int (*set_optionsv)(MYSQL *mysql, unsigned int option, ...);
+  int (*set_connection)(MYSQL *mysql,enum enum_server_command command,
+                        const char *arg,
+                        size_t length, my_bool skipp_check, void *opt_arg);
+  my_bool (*reconnect)(MYSQL *mysql);
+  int (*reset)(MYSQL *mysql);
+} MARIADB_CONNECTION_PLUGIN;
+
+#define MARIADB_DB_DRIVER(a) ((a)->ext_db)
+
+/*******************  Communication IO plugin *****************/
+#include <ma_pvio.h>
+
+typedef struct st_mariadb_client_plugin_PVIO
+{
+  MYSQL_CLIENT_PLUGIN_HEADER
+  struct st_ma_pvio_methods *methods;
+} MARIADB_PVIO_PLUGIN;
+
+/******** authentication plugin specific declarations *********/
+#include <mysql/plugin_auth_common.h>
+
+struct st_mysql_client_plugin_AUTHENTICATION
+{
+  MYSQL_CLIENT_PLUGIN_HEADER
+  int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql);
+};
+
+/******** trace plugin *******/
+struct st_mysql_client_plugin_TRACE
+{
+  MYSQL_CLIENT_PLUGIN_HEADER
+};
+
+/**
+  type of the mysql_authentication_dialog_ask function
+
+  @param mysql          mysql
+  @param type           type of the input
+                        1 - ordinary string input
+                        2 - password string
+  @param prompt         prompt
+  @param buf            a buffer to store the use input
+  @param buf_len        the length of the buffer
+
+  @retval               a pointer to the user input string.
+                        It may be equal to 'buf' or to 'mysql->password'.
+                        In all other cases it is assumed to be an allocated
+                        string, and the "dialog" plugin will free() it.
+*/
+typedef char *(*mysql_authentication_dialog_ask_t)(struct st_mysql *mysql,
+                      int type, const char *prompt, char *buf, int buf_len);
+
+/********************** remote IO plugin **********************/
+#ifdef HAVE_REMOTEIO
+#include <mariadb/ma_io.h>
+
+/* Remote IO plugin */
+typedef struct st_mysql_client_plugin_REMOTEIO
+{
+  MYSQL_CLIENT_PLUGIN_HEADER
+  struct st_rio_methods *methods;
+} MARIADB_REMOTEIO_PLUGIN;
+#endif
+
+/******** using plugins ************/
+
+/**
+  loads a plugin and initializes it
+
+  @param mysql  MYSQL structure. only MYSQL_PLUGIN_DIR option value is used,
+                and last_errno/last_error, for error reporting
+  @param name   a name of the plugin to load
+  @param type   type of plugin that should be loaded, -1 to disable type check
+  @param argc   number of arguments to pass to the plugin initialization
+                function
+  @param ...    arguments for the plugin initialization function
+
+  @retval
+  a pointer to the loaded plugin, or NULL in case of a failure
+*/
+struct st_mysql_client_plugin *
+mysql_load_plugin(struct st_mysql *mysql, const char *name, int type,
+                  int argc, ...);
+
+/**
+  loads a plugin and initializes it, taking va_list as an argument
+
+  This is the same as mysql_load_plugin, but take va_list instead of
+  a list of arguments.
+
+  @param mysql  MYSQL structure. only MYSQL_PLUGIN_DIR option value is used,
+                and last_errno/last_error, for error reporting
+  @param name   a name of the plugin to load
+  @param type   type of plugin that should be loaded, -1 to disable type check
+  @param argc   number of arguments to pass to the plugin initialization
+                function
+  @param args   arguments for the plugin initialization function
+
+  @retval
+  a pointer to the loaded plugin, or NULL in case of a failure
+*/
+struct st_mysql_client_plugin * STDCALL
+mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type,
+                    int argc, va_list args);
+
+/**
+  finds an already loaded plugin by name, or loads it, if necessary
+
+  @param mysql  MYSQL structure. only MYSQL_PLUGIN_DIR option value is used,
+                and last_errno/last_error, for error reporting
+  @param name   a name of the plugin to load
+  @param type   type of plugin that should be loaded
+
+  @retval
+  a pointer to the plugin, or NULL in case of a failure
+*/
+struct st_mysql_client_plugin * STDCALL
+mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type);
+
+/**
+  adds a plugin structure to the list of loaded plugins
+
+  This is useful if an application has the necessary functionality
+  (for example, a special load data handler) statically linked into
+  the application binary. It can use this function to register the plugin
+  directly, avoiding the need to factor it out into a shared object.
+
+  @param mysql  MYSQL structure. It is only used for error reporting
+  @param plugin an st_mysql_client_plugin structure to register
+
+  @retval
+  a pointer to the plugin, or NULL in case of a failure
+*/
+struct st_mysql_client_plugin * STDCALL
+mysql_client_register_plugin(struct st_mysql *mysql,
+                             struct st_mysql_client_plugin *plugin);
+
+extern struct st_mysql_client_plugin *mysql_client_builtins[];
+
+#endif
+
+
diff --git a/3rdparty/mariadb/include/errmsg.h b/3rdparty/mariadb/include/errmsg.h
new file mode 100644
index 000000000..04c7e5e05
--- /dev/null
+++ b/3rdparty/mariadb/include/errmsg.h
@@ -0,0 +1,107 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+                 2012-2016 SkySQL AB, MariaDB Corporation AB
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02111-1301, USA */
+
+/* Error messages for mysql clients */
+/* error messages for the demon is in share/language/errmsg.sys */
+#ifndef _errmsg_h_
+#define _errmsg_h_
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+void	init_client_errs(void);
+extern const char *client_errors[];	/* Error messages */
+extern const char *mariadb_client_errors[];	/* Error messages */
+#ifdef	__cplusplus
+}
+#endif
+
+
+
+#define CR_MIN_ERROR		2000	/* For easier client code */
+#define CR_MAX_ERROR		2999
+#define CER_MIN_ERROR           5000
+#define CER_MAX_ERROR           5999
+#define CER(X) mariadb_client_errors[(X)-CER_MIN_ERROR]
+#define ER(X) client_errors[(X)-CR_MIN_ERROR]
+#define CLIENT_ERRMAP		2	/* Errormap used by ma_error() */
+
+#define CR_UNKNOWN_ERROR	2000
+#define CR_SOCKET_CREATE_ERROR	2001
+#define CR_CONNECTION_ERROR	2002
+#define CR_CONN_HOST_ERROR	2003 /* never sent to a client, message only */
+#define CR_IPSOCK_ERROR		2004
+#define CR_UNKNOWN_HOST		2005
+#define CR_SERVER_GONE_ERROR	2006 /* disappeared _between_ queries */
+#define CR_VERSION_ERROR	2007
+#define CR_OUT_OF_MEMORY	2008
+#define CR_WRONG_HOST_INFO	2009
+#define CR_LOCALHOST_CONNECTION 2010
+#define CR_TCP_CONNECTION	2011
+#define CR_SERVER_HANDSHAKE_ERR 2012
+#define CR_SERVER_LOST		2013 /* disappeared _during_ a query */
+#define CR_COMMANDS_OUT_OF_SYNC 2014
+#define CR_NAMEDPIPE_CONNECTION 2015
+#define CR_NAMEDPIPEWAIT_ERROR 2016
+#define CR_NAMEDPIPEOPEN_ERROR 2017
+#define CR_NAMEDPIPESETSTATE_ERROR 2018
+#define CR_CANT_READ_CHARSET	2019
+#define CR_NET_PACKET_TOO_LARGE 2020
+#define CR_SSL_CONNECTION_ERROR 2026
+#define CR_MALFORMED_PACKET     2027
+#define CR_NO_PREPARE_STMT      2030
+#define CR_PARAMS_NOT_BOUND     2031
+#define CR_INVALID_PARAMETER_NO  2034
+#define CR_INVALID_BUFFER_USE    2035
+#define CR_UNSUPPORTED_PARAM_TYPE 2036
+
+#define CR_SHARED_MEMORY_CONNECTION 2037
+#define CR_SHARED_MEMORY_CONNECT_ERROR 2038
+
+#define CR_CONN_UNKNOWN_PROTOCOL 2047
+#define CR_SECURE_AUTH          2049
+#define CR_NO_DATA              2051
+#define CR_NO_STMT_METADATA     2052
+#define CR_NOT_IMPLEMENTED      2054
+#define CR_SERVER_LOST_EXTENDED 2055 /* never sent to a client, message only */
+#define CR_STMT_CLOSED          2056
+#define CR_NEW_STMT_METADATA    2057
+#define CR_ALREADY_CONNECTED    2058
+#define CR_AUTH_PLUGIN_CANNOT_LOAD 2059
+#define CR_DUPLICATE_CONNECTION_ATTR 2060
+#define CR_AUTH_PLUGIN_ERR 2061
+/* Always last, if you add new error codes please update the
+   value for CR_MYSQL_LAST_ERROR */
+#define CR_MYSQL_LAST_ERROR CR_AUTH_PLUGIN_ERR
+
+/* 
+ * MariaDB Connector/C errors: 
+ */
+#define CR_EVENT_CREATE_FAILED 5000
+#define CR_BIND_ADDR_FAILED    5001
+#define CR_ASYNC_NOT_SUPPORTED 5002
+#define CR_FUNCTION_NOT_SUPPORTED 5003
+#define CR_FILE_NOT_FOUND 5004
+#define CR_FILE_READ 5005
+#define CR_BULK_WITHOUT_PARAMETERS 5006
+#define CR_INVALID_STMT 5007
+#define CR_VERSION_MISMATCH 5008
+/* Always last, if you add new error codes please update the
+   value for CR_MARIADB_LAST_ERROR */
+#define CR_MARIADB_LAST_ERROR CR_INVALID_STMT
+#endif
diff --git a/3rdparty/mariadb/include/ma_io.h b/3rdparty/mariadb/include/ma_io.h
new file mode 100644
index 000000000..d39fc06e3
--- /dev/null
+++ b/3rdparty/mariadb/include/ma_io.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 2015 MariaDB Corporation AB
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02111-1301, USA */
+
+#ifndef _ma_io_h_
+#define _ma_io_h_
+
+
+#ifdef HAVE_REMOTEIO
+#include <curl/curl.h>
+#endif
+
+enum enum_file_type {
+  MA_FILE_NONE=0,
+  MA_FILE_LOCAL=1,
+  MA_FILE_REMOTE=2
+};
+
+typedef struct
+{
+  enum enum_file_type type;
+  void *ptr;
+} MA_FILE;
+
+#ifdef HAVE_REMOTEIO
+struct st_rio_methods {
+  MA_FILE *(*mopen)(const char *url, const char *mode);
+  int (*mclose)(MA_FILE *ptr);
+  int (*mfeof)(MA_FILE *file);
+  size_t (*mread)(void *ptr, size_t size, size_t nmemb, MA_FILE *file);
+  char * (*mgets)(char *ptr, size_t size, MA_FILE *file);
+};
+#endif
+
+/* function prototypes */
+MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql);
+int ma_close(MA_FILE *file);
+int ma_feof(MA_FILE *file);
+size_t ma_read(void *ptr, size_t size, size_t nmemb, MA_FILE *file);
+char *ma_gets(char *ptr, size_t size, MA_FILE *file);
+
+#endif
diff --git a/3rdparty/mariadb/include/ma_list.h b/3rdparty/mariadb/include/ma_list.h
new file mode 100644
index 000000000..549280d61
--- /dev/null
+++ b/3rdparty/mariadb/include/ma_list.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02111-1301, USA */
+
+#ifndef _list_h_
+#define _list_h_
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+typedef struct st_list {
+  struct st_list *prev,*next;
+  void *data;
+} LIST;
+
+typedef int (*list_walk_action)(void *,void *);
+
+extern LIST *list_add(LIST *root,LIST *element);
+extern LIST *list_delete(LIST *root,LIST *element);
+extern LIST *list_cons(void *data,LIST *root);
+extern LIST *list_reverse(LIST *root);
+extern void list_free(LIST *root,unsigned int free_data);
+extern unsigned int list_length(LIST *list);
+extern int list_walk(LIST *list,list_walk_action action,char * argument);
+
+#define list_rest(a) ((a)->next)
+#define list_push(a,b) (a)=list_cons((b),(a))
+#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; ma_free((char *) old,MYF(MY_FAE)); }
+
+#ifdef	__cplusplus
+}
+#endif
+#endif
diff --git a/3rdparty/mariadb/include/ma_pvio.h b/3rdparty/mariadb/include/ma_pvio.h
new file mode 100644
index 000000000..7e300fee5
--- /dev/null
+++ b/3rdparty/mariadb/include/ma_pvio.h
@@ -0,0 +1,133 @@
+#ifndef _ma_pvio_h_
+#define _ma_pvio_h_
+#define cio_defined
+
+#ifdef HAVE_TLS
+#include <ma_tls.h>
+#else
+#define MARIADB_TLS void
+#endif
+
+#define PVIO_SET_ERROR if (pvio->set_error) \
+                        pvio->set_error
+
+#define PVIO_READ_AHEAD_CACHE_SIZE 16384
+#define PVIO_READ_AHEAD_CACHE_MIN_SIZE 2048
+#define PVIO_EINTR_TRIES 2
+
+struct st_ma_pvio_methods;
+typedef struct st_ma_pvio_methods PVIO_METHODS;
+
+#define IS_PVIO_ASYNC(a) \
+  ((a)->mysql && (a)->mysql->options.extension && (a)->mysql->options.extension->async_context)
+
+#define IS_PVIO_ASYNC_ACTIVE(a) \
+  (IS_PVIO_ASYNC(a)&& (a)->mysql->options.extension->async_context->active)
+
+#define IS_MYSQL_ASYNC(a) \
+  ((a)->options.extension && (a)->options.extension->async_context)
+
+#define IS_MYSQL_ASYNC_ACTIVE(a) \
+  (IS_MYSQL_ASYNC(a)&& (a)->options.extension->async_context->active)
+
+enum enum_pvio_timeout {
+  PVIO_CONNECT_TIMEOUT= 0,
+  PVIO_READ_TIMEOUT,
+  PVIO_WRITE_TIMEOUT 
+};
+
+enum enum_pvio_io_event
+{
+  VIO_IO_EVENT_READ,
+  VIO_IO_EVENT_WRITE,
+  VIO_IO_EVENT_CONNECT
+};
+
+enum enum_pvio_type {
+  PVIO_TYPE_UNIXSOCKET= 0,
+  PVIO_TYPE_SOCKET,
+  PVIO_TYPE_NAMEDPIPE,
+  PVIO_TYPE_SHAREDMEM,
+};
+
+enum enum_pvio_operation {
+  PVIO_READ= 0,
+  PVIO_WRITE=1
+};
+
+#define SHM_DEFAULT_NAME "MYSQL"
+
+struct st_pvio_callback;
+
+typedef struct st_pvio_callback {
+  void (*callback)(MYSQL *mysql, uchar *buffer, size_t size);
+  struct st_pvio_callback *next;
+} PVIO_CALLBACK;
+
+struct st_ma_pvio {
+  void *data;
+  /* read ahead cache */
+  uchar *cache;
+  uchar *cache_pos;
+  size_t cache_size;
+  enum enum_pvio_type type;
+  int timeout[3];
+  int ssl_type;  /* todo: change to enum (ssl plugins) */
+  MARIADB_TLS *ctls;
+  MYSQL *mysql;
+  PVIO_METHODS *methods;
+  void (*set_error)(MYSQL *mysql, unsigned int error_nr, const char *sqlstate, const char *format, ...);
+  void (*callback)(MARIADB_PVIO *pvio, my_bool is_read, const uchar *buffer, size_t length);
+};
+
+typedef struct st_ma_pvio_cinfo
+{
+  const char *host;
+  const char *unix_socket;
+  int port;
+  enum enum_pvio_type type;
+  MYSQL *mysql;
+} MA_PVIO_CINFO;
+
+struct st_ma_pvio_methods
+{
+  my_bool (*set_timeout)(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout);
+  int (*get_timeout)(MARIADB_PVIO *pvio, enum enum_pvio_timeout type);
+  ssize_t (*read)(MARIADB_PVIO *pvio, uchar *buffer, size_t length);
+  ssize_t (*async_read)(MARIADB_PVIO *pvio, uchar *buffer, size_t length);
+  ssize_t (*write)(MARIADB_PVIO *pvio, const uchar *buffer, size_t length);
+  ssize_t (*async_write)(MARIADB_PVIO *pvio, const uchar *buffer, size_t length);
+  int (*wait_io_or_timeout)(MARIADB_PVIO *pvio, my_bool is_read, int timeout);
+  int (*blocking)(MARIADB_PVIO *pvio, my_bool value, my_bool *old_value);
+  my_bool (*connect)(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo);
+  my_bool (*close)(MARIADB_PVIO *pvio);
+  int (*fast_send)(MARIADB_PVIO *pvio);
+  int (*keepalive)(MARIADB_PVIO *pvio);
+  my_bool (*get_handle)(MARIADB_PVIO *pvio, void *handle);
+  my_bool (*is_blocking)(MARIADB_PVIO *pvio);
+  my_bool (*is_alive)(MARIADB_PVIO *pvio);
+  my_bool (*has_data)(MARIADB_PVIO *pvio, ssize_t *data_len);
+  int(*shutdown)(MARIADB_PVIO *pvio);
+};
+
+/* Function prototypes */
+MARIADB_PVIO *ma_pvio_init(MA_PVIO_CINFO *cinfo);
+void ma_pvio_close(MARIADB_PVIO *pvio);
+ssize_t ma_pvio_cache_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length);
+ssize_t ma_pvio_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length);
+ssize_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length);
+int ma_pvio_get_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type);
+my_bool ma_pvio_set_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout);
+int ma_pvio_fast_send(MARIADB_PVIO *pvio);
+int ma_pvio_keepalive(MARIADB_PVIO *pvio);
+my_socket ma_pvio_get_socket(MARIADB_PVIO *pvio);
+my_bool ma_pvio_is_blocking(MARIADB_PVIO *pvio);
+my_bool ma_pvio_blocking(MARIADB_PVIO *pvio, my_bool block, my_bool *previous_mode);
+my_bool ma_pvio_is_blocking(MARIADB_PVIO *pvio);
+int ma_pvio_wait_io_or_timeout(MARIADB_PVIO *pvio, my_bool is_read, int timeout);
+my_bool ma_pvio_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo);
+my_bool ma_pvio_is_alive(MARIADB_PVIO *pvio);
+my_bool ma_pvio_get_handle(MARIADB_PVIO *pvio, void *handle);
+my_bool ma_pvio_has_data(MARIADB_PVIO *pvio, ssize_t *length);
+
+#endif /* _ma_pvio_h_ */
diff --git a/3rdparty/mariadb/include/ma_tls.h b/3rdparty/mariadb/include/ma_tls.h
new file mode 100644
index 000000000..9ce49e7c9
--- /dev/null
+++ b/3rdparty/mariadb/include/ma_tls.h
@@ -0,0 +1,161 @@
+#ifndef _ma_tls_h_
+#define _ma_tls_h_
+
+enum enum_pvio_tls_type {
+  SSL_TYPE_DEFAULT=0,
+#ifdef _WIN32
+  SSL_TYPE_SCHANNEL,
+#endif
+  SSL_TYPE_OPENSSL,
+  SSL_TYPE_GNUTLS
+};
+
+#define PROTOCOL_SSLV3    0
+#define PROTOCOL_TLS_1_0  1
+#define PROTOCOL_TLS_1_1  2
+#define PROTOCOL_TLS_1_2  3
+#define PROTOCOL_TLS_1_3  4
+#define PROTOCOL_UNKNOWN  5
+#define PROTOCOL_MAX PROTOCOL_TLS_1_3
+
+#define TLS_VERSION_LENGTH 64
+extern char tls_library_version[TLS_VERSION_LENGTH];
+
+typedef struct st_ma_pvio_tls {
+  void *data;
+  MARIADB_PVIO *pvio;
+  void *ssl;
+} MARIADB_TLS;
+
+/* Function prototypes */
+
+/* ma_tls_start
+   initializes the ssl library
+   Parameter:
+     errmsg      pointer to error message buffer
+     errmsg_len  length of error message buffer
+   Returns:
+     0           success
+     1           if an error occurred
+   Notes:
+     On success the global variable ma_tls_initialized will be set to 1
+*/
+int ma_tls_start(char *errmsg, size_t errmsg_len);
+
+/* ma_tls_end
+   unloads/deinitializes ssl library and unsets global variable
+   ma_tls_initialized
+*/
+void ma_tls_end(void);
+
+/* ma_tls_init
+   creates a new SSL structure for a SSL connection and loads
+   client certificates
+
+   Parameters:
+     MYSQL        a mysql structure
+   Returns:
+     void *       a pointer to internal SSL structure
+*/
+void * ma_tls_init(MYSQL *mysql);
+
+/* ma_tls_connect
+   performs SSL handshake
+   Parameters:
+     MARIADB_TLS   MariaDB SSL container
+   Returns:
+     0             success
+     1             error
+*/
+my_bool ma_tls_connect(MARIADB_TLS *ctls);
+
+/* ma_tls_read
+   reads up to length bytes from socket
+   Parameters:
+     ctls         MariaDB SSL container
+     buffer       read buffer
+     length       buffer length
+   Returns:
+     0-n          bytes read
+     -1           if an error occurred
+*/
+ssize_t ma_tls_read(MARIADB_TLS *ctls, const uchar* buffer, size_t length);
+
+/* ma_tls_write
+   write buffer to socket
+   Parameters:
+     ctls         MariaDB SSL container
+     buffer       write buffer
+     length       buffer length
+   Returns:
+     0-n          bytes written
+     -1           if an error occurred
+*/
+ssize_t ma_tls_write(MARIADB_TLS *ctls, const uchar* buffer, size_t length);
+
+/* ma_tls_close
+   closes SSL connection and frees SSL structure which was previously
+   created by ma_tls_init call
+   Parameters:
+     MARIADB_TLS  MariaDB SSL container
+   Returns:
+     0            success
+     1            error
+*/
+my_bool ma_tls_close(MARIADB_TLS *ctls);
+
+/* ma_tls_verify_server_cert
+   validation check of server certificate
+   Parameter:
+     MARIADB_TLS  MariaDB SSL container
+   Returns:
+     ß            success
+     1            error
+*/
+int ma_tls_verify_server_cert(MARIADB_TLS *ctls);
+
+/* ma_tls_get_cipher
+   returns cipher for current ssl connection
+   Parameter:
+     MARIADB_TLS  MariaDB SSL container
+   Returns: 
+     cipher in use or
+     NULL on error
+*/
+const char *ma_tls_get_cipher(MARIADB_TLS *ssl);
+
+/* ma_tls_get_finger_print
+   returns SHA1 finger print of server certificate
+   Parameter:
+     MARIADB_TLS  MariaDB SSL container
+     fp           buffer for fingerprint
+     fp_len       buffer length
+   Returns:
+     actual size of finger print
+*/
+unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, char *fp, unsigned int fp_len);
+
+/* ma_tls_get_protocol_version 
+   returns protocol version number in use
+   Parameter:
+     MARIADB_TLS    MariaDB SSL container
+   Returns:
+     protocol number
+*/
+int ma_tls_get_protocol_version(MARIADB_TLS *ctls);
+const char *ma_pvio_tls_get_protocol_version(MARIADB_TLS *ctls);
+int ma_pvio_tls_get_protocol_version_id(MARIADB_TLS *ctls);
+
+/* Function prototypes */
+MARIADB_TLS *ma_pvio_tls_init(MYSQL *mysql);
+my_bool ma_pvio_tls_connect(MARIADB_TLS *ctls);
+ssize_t ma_pvio_tls_read(MARIADB_TLS *ctls, const uchar *buffer, size_t length);
+ssize_t ma_pvio_tls_write(MARIADB_TLS *ctls, const uchar *buffer, size_t length);
+my_bool ma_pvio_tls_close(MARIADB_TLS *ctls);
+int ma_pvio_tls_verify_server_cert(MARIADB_TLS *ctls);
+const char *ma_pvio_tls_cipher(MARIADB_TLS *ctls);
+my_bool ma_pvio_tls_check_fp(MARIADB_TLS *ctls, const char *fp, const char *fp_list);
+my_bool ma_pvio_start_ssl(MARIADB_PVIO *pvio);
+void ma_pvio_tls_end();
+
+#endif /* _ma_tls_h_ */
diff --git a/3rdparty/mariadb/include/mariadb_com.h b/3rdparty/mariadb/include/mariadb_com.h
new file mode 100644
index 000000000..9a5da28dd
--- /dev/null
+++ b/3rdparty/mariadb/include/mariadb_com.h
@@ -0,0 +1,457 @@
+/************************************************************************************
+    Copyright (C) 2000, 2012 MySQL AB & MySQL Finland AB & TCX DataKonsult AB,
+                 Monty Program AB
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not see <http://www.gnu.org/licenses>
+   or write to the Free Software Foundation, Inc., 
+   51 Franklin St., Fifth Floor, Boston, MA 02110, USA
+
+   Part of this code includes code from the PHP project which
+   is freely available from http://www.php.net
+*************************************************************************************/
+
+/*
+** Common definition between mysql server & client
+*/
+
+#ifndef _mysql_com_h
+#define _mysql_com_h
+
+
+#define NAME_CHAR_LEN   64
+#define NAME_LEN	256		/* Field/table name length */
+#define HOSTNAME_LENGTH 60
+#define SYSTEM_MB_MAX_CHAR_LENGTH 4
+#define USERNAME_CHAR_LENGTH 128
+#define USERNAME_LENGTH USERNAME_CHAR_LENGTH * SYSTEM_MB_MAX_CHAR_LENGTH
+#define SERVER_VERSION_LENGTH 60
+#define SQLSTATE_LENGTH 5
+#define SCRAMBLE_LENGTH 20
+#define SCRAMBLE_LENGTH_323 8
+
+#define LOCAL_HOST	"localhost"
+#define LOCAL_HOST_NAMEDPIPE "."
+
+#if defined(_WIN32) && !defined( _CUSTOMCONFIG_)
+#define MARIADB_NAMEDPIPE "MySQL"
+#define MYSQL_SERVICENAME "MySql"
+#endif /* _WIN32 */
+
+/* for use in mysql client tools only */
+#define MYSQL_AUTODETECT_CHARSET_NAME "auto"
+#define BINCMP_FLAG       131072
+
+enum mysql_enum_shutdown_level
+{
+  SHUTDOWN_DEFAULT = 0,
+  KILL_QUERY= 254,
+  KILL_CONNECTION= 255
+};
+
+enum enum_server_command
+{
+  COM_SLEEP = 0,
+  COM_QUIT,
+  COM_INIT_DB,
+  COM_QUERY,
+  COM_FIELD_LIST,
+  COM_CREATE_DB,
+  COM_DROP_DB,
+  COM_REFRESH,
+  COM_SHUTDOWN,
+  COM_STATISTICS,
+  COM_PROCESS_INFO,
+  COM_CONNECT,
+  COM_PROCESS_KILL,
+  COM_DEBUG,
+  COM_PING,
+  COM_TIME = 15,
+  COM_DELAYED_INSERT,
+  COM_CHANGE_USER,
+  COM_BINLOG_DUMP,
+  COM_TABLE_DUMP,
+  COM_CONNECT_OUT = 20,
+  COM_REGISTER_SLAVE,
+  COM_STMT_PREPARE = 22,
+  COM_STMT_EXECUTE = 23,
+  COM_STMT_SEND_LONG_DATA = 24,
+  COM_STMT_CLOSE = 25,
+  COM_STMT_RESET = 26,
+  COM_SET_OPTION = 27,
+  COM_STMT_FETCH = 28,
+  COM_DAEMON= 29,
+  COM_UNSUPPORTED= 30,
+  COM_RESET_CONNECTION = 31,
+  COM_STMT_BULK_EXECUTE = 250,
+  COM_MULTI = 254,
+  COM_END
+};
+
+
+#define NOT_NULL_FLAG	1		/* Field can't be NULL */
+#define PRI_KEY_FLAG	2		/* Field is part of a primary key */
+#define UNIQUE_KEY_FLAG 4		/* Field is part of a unique key */
+#define MULTIPLE_KEY_FLAG 8		/* Field is part of a key */
+#define BLOB_FLAG	16		/* Field is a blob */
+#define UNSIGNED_FLAG	32		/* Field is unsigned */
+#define ZEROFILL_FLAG	64		/* Field is zerofill */
+#define BINARY_FLAG	128
+/* The following are only sent to new clients */
+#define ENUM_FLAG	256		/* field is an enum */
+#define AUTO_INCREMENT_FLAG 512		/* field is a autoincrement field */
+#define TIMESTAMP_FLAG	1024		/* Field is a timestamp */
+#define SET_FLAG	2048		/* field is a set */
+/* new since 3.23.58 */
+#define NO_DEFAULT_VALUE_FLAG 4096	/* Field doesn't have default value */
+#define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
+/* end new */
+#define NUM_FLAG	32768		/* Field is num (for clients) */
+#define PART_KEY_FLAG	16384		/* Intern; Part of some key */
+#define GROUP_FLAG	32768		/* Intern: Group field */
+#define UNIQUE_FLAG	65536		/* Intern: Used by sql_yacc */
+
+#define REFRESH_GRANT		1	/* Refresh grant tables */
+#define REFRESH_LOG		2	/* Start on new log file */
+#define REFRESH_TABLES		4	/* close all tables */
+#define REFRESH_HOSTS		8	/* Flush host cache */
+#define REFRESH_STATUS		16	/* Flush status variables */
+#define REFRESH_THREADS		32	/* Flush thread cache */
+#define REFRESH_SLAVE           64      /* Reset master info and restart slave
+					   thread */
+#define REFRESH_MASTER          128     /* Remove all bin logs in the index
+					   and truncate the index */
+
+/* The following can't be set with mysql_refresh() */
+#define REFRESH_READ_LOCK	16384	/* Lock tables for read */
+#define REFRESH_FAST		32768	/* Intern flag */
+
+#define CLIENT_MYSQL          1
+#define CLIENT_FOUND_ROWS	    2	/* Found instead of affected rows */
+#define CLIENT_LONG_FLAG	    4	/* Get all column flags */
+#define CLIENT_CONNECT_WITH_DB	    8	/* One can specify db on connect */
+#define CLIENT_NO_SCHEMA	   16	/* Don't allow database.table.column */
+#define CLIENT_COMPRESS		   32	/* Can use compression protocol */
+#define CLIENT_ODBC		   64	/* Odbc client */
+#define CLIENT_LOCAL_FILES	  128	/* Can use LOAD DATA LOCAL */
+#define CLIENT_IGNORE_SPACE	  256	/* Ignore spaces before '(' */
+#define CLIENT_INTERACTIVE	  1024	/* This is an interactive client */
+#define CLIENT_SSL                2048     /* Switch to SSL after handshake */
+#define CLIENT_IGNORE_SIGPIPE     4096     /* IGNORE sigpipes */
+#define CLIENT_TRANSACTIONS	  8192	/* Client knows about transactions */
+/* added in 4.x */
+#define CLIENT_PROTOCOL_41         512
+#define CLIENT_RESERVED          16384
+#define CLIENT_SECURE_CONNECTION 32768  
+#define CLIENT_MULTI_STATEMENTS  (1UL << 16)
+#define CLIENT_MULTI_RESULTS     (1UL << 17)
+#define CLIENT_PS_MULTI_RESULTS  (1UL << 18)
+#define CLIENT_PLUGIN_AUTH       (1UL << 19)
+#define CLIENT_CONNECT_ATTRS     (1UL << 20)
+#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22)
+#define CLIENT_SESSION_TRACKING  (1UL << 23)
+#define CLIENT_PROGRESS          (1UL << 29) /* client supports progress indicator */
+#define CLIENT_PROGRESS_OBSOLETE  CLIENT_PROGRESS 
+#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
+#define CLIENT_REMEMBER_OPTIONS  (1UL << 31)
+
+/* MariaDB specific capabilities */
+#define MARIADB_CLIENT_FLAGS 0xFFFFFFFF00000000ULL
+#define MARIADB_CLIENT_PROGRESS (1ULL << 32)
+#define MARIADB_CLIENT_COM_MULTI (1ULL << 33)
+#define MARIADB_CLIENT_STMT_BULK_OPERATIONS (1ULL << 34)
+
+#define IS_MARIADB_EXTENDED_SERVER(mysql)\
+        !(mysql->server_capabilities & CLIENT_MYSQL)
+
+#define MARIADB_CLIENT_SUPPORTED_FLAGS (MARIADB_CLIENT_PROGRESS |\
+                                       MARIADB_CLIENT_COM_MULTI |\
+                                       MARIADB_CLIENT_STMT_BULK_OPERATIONS)
+
+#define CLIENT_SUPPORTED_FLAGS  (CLIENT_MYSQL |\
+                                 CLIENT_FOUND_ROWS |\
+                                 CLIENT_LONG_FLAG |\
+                                 CLIENT_CONNECT_WITH_DB |\
+                                 CLIENT_NO_SCHEMA |\
+                                 CLIENT_COMPRESS |\
+                                 CLIENT_ODBC |\
+                                 CLIENT_LOCAL_FILES |\
+                                 CLIENT_IGNORE_SPACE |\
+                                 CLIENT_INTERACTIVE |\
+                                 CLIENT_SSL |\
+                                 CLIENT_IGNORE_SIGPIPE |\
+                                 CLIENT_TRANSACTIONS |\
+                                 CLIENT_PROTOCOL_41 |\
+                                 CLIENT_RESERVED |\
+                                 CLIENT_SECURE_CONNECTION |\
+                                 CLIENT_MULTI_STATEMENTS |\
+                                 CLIENT_MULTI_RESULTS |\
+                                 CLIENT_PROGRESS |\
+		                 CLIENT_SSL_VERIFY_SERVER_CERT |\
+                                 CLIENT_REMEMBER_OPTIONS |\
+                                 CLIENT_PLUGIN_AUTH |\
+                                 CLIENT_SESSION_TRACKING |\
+                                 CLIENT_CONNECT_ATTRS)
+
+#define CLIENT_CAPABILITIES	(CLIENT_MYSQL | \
+                                 CLIENT_LONG_FLAG |\
+                                 CLIENT_TRANSACTIONS |\
+                                 CLIENT_SECURE_CONNECTION |\
+                                 CLIENT_MULTI_RESULTS | \
+                                 CLIENT_PS_MULTI_RESULTS |\
+                                 CLIENT_PROTOCOL_41 |\
+                                 CLIENT_PLUGIN_AUTH |\
+                                 CLIENT_SESSION_TRACKING |\
+                                 CLIENT_CONNECT_ATTRS)
+
+#define CLIENT_DEFAULT_FLAGS ((CLIENT_SUPPORTED_FLAGS & ~CLIENT_COMPRESS)\
+                                                      & ~CLIENT_SSL)
+
+#define SERVER_STATUS_IN_TRANS               1	/* Transaction has started */
+#define SERVER_STATUS_AUTOCOMMIT             2	/* Server in auto_commit mode */
+#define SERVER_MORE_RESULTS_EXIST            8
+#define SERVER_QUERY_NO_GOOD_INDEX_USED     16
+#define SERVER_QUERY_NO_INDEX_USED          32
+#define SERVER_STATUS_CURSOR_EXISTS         64
+#define SERVER_STATUS_LAST_ROW_SENT        128
+#define SERVER_STATUS_DB_DROPPED           256 
+#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
+#define SERVER_STATUS_METADATA_CHANGED    1024
+#define SERVER_QUERY_WAS_SLOW             2048
+#define SERVER_PS_OUT_PARAMS              4096
+#define SERVER_STATUS_IN_TRANS_READONLY   8192
+#define SERVER_SESSION_STATE_CHANGED     16384
+#define SERVER_STATUS_ANSI_QUOTES        32768
+
+#define MYSQL_ERRMSG_SIZE	512
+#define NET_READ_TIMEOUT	30		/* Timeout on read */
+#define NET_WRITE_TIMEOUT	60		/* Timeout on write */
+#define NET_WAIT_TIMEOUT	8*60*60		/* Wait for new query */
+
+/* for server integration (mysqlbinlog) */
+#define LIST_PROCESS_HOST_LEN 64
+#define MYSQL50_TABLE_NAME_PREFIX         "#mysql50#"
+#define MYSQL50_TABLE_NAME_PREFIX_LENGTH  (sizeof(MYSQL50_TABLE_NAME_PREFIX)-1)
+#define SAFE_NAME_LEN (NAME_LEN + MYSQL50_TABLE_NAME_PREFIX_LENGTH)
+
+struct st_ma_pvio;
+typedef struct st_ma_pvio MARIADB_PVIO;
+
+#define MAX_CHAR_WIDTH		255	/* Max length for a CHAR column */
+#define MAX_BLOB_WIDTH		8192	/* Default width for blob */
+
+/* the following defines were added for PHP's mysqli and pdo extensions: 
+   see: CONC-56
+*/
+#define MAX_TINYINT_WIDTH     3
+#define MAX_SMALLINT_WIDTH    5
+#define MAX_MEDIUMINT_WIDTH   8
+#define MAX_INT_WIDTH        10
+#define MAX_BIGINT_WIDTH     20
+
+struct st_ma_connection_plugin;
+
+
+typedef struct st_net {
+  MARIADB_PVIO *pvio;
+  unsigned char *buff;
+  unsigned char *buff_end,*write_pos,*read_pos;
+  my_socket fd;					/* For Perl DBI/dbd */
+  unsigned long remain_in_buf,length;
+  unsigned long buf_length, where_b;
+  unsigned long max_packet, max_packet_size;
+  unsigned int pkt_nr, compress_pkt_nr;
+  unsigned int write_timeout, read_timeout, retry_count;
+  int fcntl;
+  unsigned int *return_status;
+  unsigned char reading_or_writing;
+  char save_char;
+  char unused_1;
+  my_bool unused_2;
+  my_bool compress;
+  my_bool unused_3;
+  void *unused_4;
+  unsigned int last_errno;
+  unsigned char error;
+  my_bool unused_5;
+  my_bool unused_6;
+  char last_error[MYSQL_ERRMSG_SIZE];
+  char sqlstate[SQLSTATE_LENGTH+1];
+  struct st_mariadb_net_extension *extension;
+} NET;
+
+#define packet_error ((unsigned int) -1)
+
+/* used by mysql_set_server_option */
+enum enum_mysql_set_option
+{
+  MYSQL_OPTION_MULTI_STATEMENTS_ON,
+  MYSQL_OPTION_MULTI_STATEMENTS_OFF
+};
+
+enum enum_session_state_type
+{
+  SESSION_TRACK_SYSTEM_VARIABLES= 0,
+  SESSION_TRACK_SCHEMA,
+  SESSION_TRACK_STATE_CHANGE,
+  /* currently not supported by MariaDB Server */
+  SESSION_TRACK_GTIDS,
+  SESSION_TRACK_TRANSACTION_CHARACTERISTICS,
+  SESSION_TRACK_TRANSACTION_TYPE /* make sure that SESSION_TRACK_END always points
+                                    to last element of enum !! */
+};
+
+#define SESSION_TRACK_BEGIN 0
+#define SESSION_TRACK_END SESSION_TRACK_TRANSACTION_TYPE
+#define SESSION_TRACK_TYPES SESSION_TRACK_END + 1
+
+enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
+                        MYSQL_TYPE_SHORT,  MYSQL_TYPE_LONG,
+                        MYSQL_TYPE_FLOAT,  MYSQL_TYPE_DOUBLE,
+                        MYSQL_TYPE_NULL,   MYSQL_TYPE_TIMESTAMP,
+                        MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
+                        MYSQL_TYPE_DATE,   MYSQL_TYPE_TIME,
+                        MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
+                        MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
+                        MYSQL_TYPE_BIT,
+                        /*
+                          the following types are not used by client,
+                          only for mysqlbinlog!!
+                        */
+                        MYSQL_TYPE_TIMESTAMP2,
+                        MYSQL_TYPE_DATETIME2,
+                        MYSQL_TYPE_TIME2,
+                        /* --------------------------------------------- */
+                        MYSQL_TYPE_JSON=245,
+                        MYSQL_TYPE_NEWDECIMAL=246,
+                        MYSQL_TYPE_ENUM=247,
+                        MYSQL_TYPE_SET=248,
+                        MYSQL_TYPE_TINY_BLOB=249,
+                        MYSQL_TYPE_MEDIUM_BLOB=250,
+                        MYSQL_TYPE_LONG_BLOB=251,
+                        MYSQL_TYPE_BLOB=252,
+                        MYSQL_TYPE_VAR_STRING=253,
+                        MYSQL_TYPE_STRING=254,
+                        MYSQL_TYPE_GEOMETRY=255,
+                        MAX_NO_FIELD_TYPES };
+
+#define FIELD_TYPE_CHAR FIELD_TYPE_TINY		/* For compatibility */
+#define FIELD_TYPE_INTERVAL FIELD_TYPE_ENUM	/* For compatibility */
+#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
+#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
+#define FIELD_TYPE_TINY MYSQL_TYPE_TINY
+#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
+#define FIELD_TYPE_LONG MYSQL_TYPE_LONG
+#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
+#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
+#define FIELD_TYPE_NULL MYSQL_TYPE_NULL
+#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
+#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
+#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
+#define FIELD_TYPE_DATE MYSQL_TYPE_DATE
+#define FIELD_TYPE_TIME MYSQL_TYPE_TIME
+#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
+#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
+#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
+#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
+#define FIELD_TYPE_SET MYSQL_TYPE_SET
+#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
+#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
+#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
+#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
+#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
+#define FIELD_TYPE_STRING MYSQL_TYPE_STRING
+#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
+#define FIELD_TYPE_BIT MYSQL_TYPE_BIT
+
+extern unsigned long max_allowed_packet;
+extern unsigned long net_buffer_length;
+
+#define net_new_transaction(net) ((net)->pkt_nr=0)
+
+int	ma_net_init(NET *net, MARIADB_PVIO *pvio);
+void	ma_net_end(NET *net);
+void	ma_net_clear(NET *net);
+int	ma_net_flush(NET *net);
+int	ma_net_write(NET *net,const unsigned char *packet, size_t len);
+int	ma_net_write_command(NET *net,unsigned char command,const char *packet,
+			  size_t len, my_bool disable_flush);
+int	ma_net_real_write(NET *net,const char *packet, size_t len);
+extern unsigned long ma_net_read(NET *net);
+
+struct rand_struct {
+  unsigned long seed1,seed2,max_value;
+  double max_value_dbl;
+};
+
+  /* The following is for user defined functions */
+
+enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT,ROW_RESULT,DECIMAL_RESULT};
+
+typedef struct st_udf_args
+{
+  unsigned int arg_count;		/* Number of arguments */
+  enum Item_result *arg_type;		/* Pointer to item_results */
+  char **args;				/* Pointer to argument */
+  unsigned long *lengths;		/* Length of string arguments */
+  char *maybe_null;			/* Set to 1 for all maybe_null args */
+} UDF_ARGS;
+
+  /* This holds information about the result */
+
+typedef struct st_udf_init
+{
+  my_bool maybe_null;			/* 1 if function can return NULL */
+  unsigned int decimals;		/* for real functions */
+  unsigned int max_length;		/* For string functions */
+  char	  *ptr;				/* free pointer for function data */
+  my_bool const_item;			/* 0 if result is independent of arguments */
+} UDF_INIT;
+
+/* Connection types */
+#define MARIADB_CONNECTION_UNIXSOCKET   0
+#define MARIADB_CONNECTION_TCP          1
+#define MARIADB_CONNECTION_NAMEDPIPE    2
+#define MARIADB_CONNECTION_SHAREDMEM    3
+
+  /* Constants when using compression */
+#define NET_HEADER_SIZE 4		/* standard header size */
+#define COMP_HEADER_SIZE 3		/* compression header extra size */
+
+  /* Prototypes to password functions */
+#define native_password_plugin_name "mysql_native_password"
+#define old_password_plugin_name    "mysql_old_password"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+  
+char *ma_scramble_323(char *to,const char *message,const char *password);
+void ma_scramble_41(const unsigned char *buffer, const char *scramble, const char *password);
+void ma_hash_password(unsigned long *result, const char *password, size_t len);
+void ma_make_scrambled_password(char *to,const char *password);
+
+/* Some other useful functions */
+
+void mariadb_load_defaults(const char *conf_file, const char **groups,
+		   int *argc, char ***argv);
+my_bool ma_thread_init(void);
+void ma_thread_end(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
+
+#endif
diff --git a/3rdparty/mariadb/include/mariadb_ctype.h b/3rdparty/mariadb/include/mariadb_ctype.h
new file mode 100644
index 000000000..bc65fcdc2
--- /dev/null
+++ b/3rdparty/mariadb/include/mariadb_ctype.h
@@ -0,0 +1,76 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02111-1301, USA */
+
+/*
+  A better inplementation of the UNIX ctype(3) library.
+  Notes:   my_global.h should be included before ctype.h
+*/
+
+#ifndef _mariadb_ctype_h
+#define _mariadb_ctype_h
+
+#include <ctype.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#define CHARSET_DIR	"charsets/"
+#define MY_CS_NAME_SIZE 32
+
+#define MADB_DEFAULT_CHARSET_NAME "latin1"
+#define MADB_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
+#define MADB_AUTODETECT_CHARSET_NAME "auto"
+
+/* we use the mysqlnd implementation */
+typedef struct ma_charset_info_st
+{
+  unsigned int	nr; /* so far only 1 byte for charset */
+  unsigned int  state;
+  const char	*csname;
+  const char	*name;
+  const char  *dir;
+  unsigned int codepage;
+  const char  *encoding;
+  unsigned int	char_minlen;
+  unsigned int	char_maxlen;
+  unsigned int 	(*mb_charlen)(unsigned int c);
+  unsigned int 	(*mb_valid)(const char *start, const char *end);
+} MARIADB_CHARSET_INFO;
+
+extern const MARIADB_CHARSET_INFO  mariadb_compiled_charsets[];
+extern MARIADB_CHARSET_INFO *ma_default_charset_info;
+extern MARIADB_CHARSET_INFO *ma_charset_bin;
+extern MARIADB_CHARSET_INFO *ma_charset_latin1;
+extern MARIADB_CHARSET_INFO *ma_charset_utf8_general_ci;
+extern MARIADB_CHARSET_INFO *ma_charset_utf16le_general_ci;
+
+MARIADB_CHARSET_INFO *find_compiled_charset(unsigned int cs_number);
+MARIADB_CHARSET_INFO *find_compiled_charset_by_name(const char *name);
+
+size_t mysql_cset_escape_quotes(const MARIADB_CHARSET_INFO *cset, char *newstr,  const char *escapestr, size_t escapestr_len);
+size_t mysql_cset_escape_slashes(const MARIADB_CHARSET_INFO *cset, char *newstr, const char *escapestr, size_t escapestr_len);
+const char* madb_get_os_character_set(void);
+#ifdef _WIN32
+int madb_get_windows_cp(const char *charset);
+#endif
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif
diff --git a/3rdparty/mariadb/include/mariadb_dyncol.h b/3rdparty/mariadb/include/mariadb_dyncol.h
new file mode 100644
index 000000000..a6084fd92
--- /dev/null
+++ b/3rdparty/mariadb/include/mariadb_dyncol.h
@@ -0,0 +1,256 @@
+/* Copyright (c) 2011, Monty Program Ab
+   Copyright (c) 2011, Oleksandr Byelkin
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+
+   1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must the following disclaimer in
+     the documentation and/or other materials provided with the
+     distribution.
+
+   THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+   EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+   SUCH DAMAGE.
+*/
+
+#ifndef ma_dyncol_h
+#define ma_dyncol_h
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#ifndef LIBMARIADB
+#include <decimal.h>
+#include <my_decimal_limits.h>
+#endif
+#include <mysql.h>
+
+#ifndef longlong_defined
+#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8
+typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
+typedef long long int longlong;
+#else
+typedef unsigned long	ulonglong;	/* ulong or unsigned long long */
+typedef long		longlong;
+#endif
+#define longlong_defined
+#endif
+
+
+#ifndef _my_sys_h
+typedef struct st_dynamic_string
+{
+  char *str;
+  size_t length,max_length,alloc_increment;
+} DYNAMIC_STRING;
+#endif
+
+struct st_mysql_lex_string
+{
+  char *str;
+  size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+typedef struct st_mysql_lex_string LEX_STRING;
+/*
+  Limits of implementation
+*/
+#define MAX_TOTAL_NAME_LENGTH 65535
+#define MAX_NAME_LENGTH (MAX_TOTAL_NAME_LENGTH/4)
+
+/* NO and OK is the same used just to show semantics */
+#define ER_DYNCOL_NO ER_DYNCOL_OK
+
+enum enum_dyncol_func_result
+{
+  ER_DYNCOL_OK= 0,
+  ER_DYNCOL_YES= 1,                /* For functions returning 0/1 */
+  ER_DYNCOL_FORMAT= -1,            /* Wrong format of the encoded string */
+  ER_DYNCOL_LIMIT=  -2,            /* Some limit reached */
+  ER_DYNCOL_RESOURCE= -3,          /* Out of resourses */
+  ER_DYNCOL_DATA= -4,              /* Incorrect input data */
+  ER_DYNCOL_UNKNOWN_CHARSET= -5,   /* Unknown character set */
+  ER_DYNCOL_TRUNCATED= 2           /* OK, but data was truncated */
+};
+
+typedef DYNAMIC_STRING DYNAMIC_COLUMN;
+
+enum enum_dynamic_column_type
+{
+  DYN_COL_NULL= 0,
+  DYN_COL_INT,
+  DYN_COL_UINT,
+  DYN_COL_DOUBLE,
+  DYN_COL_STRING,
+  DYN_COL_DECIMAL,
+  DYN_COL_DATETIME,
+  DYN_COL_DATE,
+  DYN_COL_TIME,
+  DYN_COL_DYNCOL
+};
+
+typedef enum enum_dynamic_column_type DYNAMIC_COLUMN_TYPE;
+
+struct st_dynamic_column_value
+{
+  DYNAMIC_COLUMN_TYPE type;
+  union
+  {
+    long long long_value;
+    unsigned long long ulong_value;
+    double double_value;
+    struct {
+      MYSQL_LEX_STRING value;
+      MARIADB_CHARSET_INFO *charset;
+    } string;
+#ifndef LIBMARIADB
+    struct {
+      decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
+      decimal_t value;
+    } decimal;
+#endif
+    MYSQL_TIME time_value;
+  } x;
+};
+
+typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE;
+
+#ifdef MADYNCOL_DEPRECATED
+enum enum_dyncol_func_result
+dynamic_column_create(DYNAMIC_COLUMN *str,
+                      uint column_nr, DYNAMIC_COLUMN_VALUE *value);
+
+enum enum_dyncol_func_result
+dynamic_column_create_many(DYNAMIC_COLUMN *str,
+                           uint column_count,
+                           uint *column_numbers,
+                           DYNAMIC_COLUMN_VALUE *values);
+enum enum_dyncol_func_result
+dynamic_column_update(DYNAMIC_COLUMN *org, uint column_nr,
+                      DYNAMIC_COLUMN_VALUE *value);
+enum enum_dyncol_func_result
+dynamic_column_update_many(DYNAMIC_COLUMN *str,
+                           uint add_column_count,
+                           uint *column_numbers,
+                           DYNAMIC_COLUMN_VALUE *values);
+
+enum enum_dyncol_func_result
+dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr);
+
+enum enum_dyncol_func_result
+dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint);
+
+enum enum_dyncol_func_result
+dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr,
+                   DYNAMIC_COLUMN_VALUE *store_it_here);
+#endif
+
+/* new functions */
+enum enum_dyncol_func_result
+mariadb_dyncol_create_many_num(DYNAMIC_COLUMN *str,
+                               uint column_count,
+                               uint *column_numbers,
+                               DYNAMIC_COLUMN_VALUE *values,
+                               my_bool new_string);
+enum enum_dyncol_func_result
+mariadb_dyncol_create_many_named(DYNAMIC_COLUMN *str,
+                                 uint column_count,
+                                 MYSQL_LEX_STRING *column_keys,
+                                 DYNAMIC_COLUMN_VALUE *values,
+                                 my_bool new_string);
+
+
+enum enum_dyncol_func_result
+mariadb_dyncol_update_many_num(DYNAMIC_COLUMN *str,
+                               uint add_column_count,
+                               uint *column_keys,
+                               DYNAMIC_COLUMN_VALUE *values);
+enum enum_dyncol_func_result
+mariadb_dyncol_update_many_named(DYNAMIC_COLUMN *str,
+                                 uint add_column_count,
+                                 MYSQL_LEX_STRING *column_keys,
+                                 DYNAMIC_COLUMN_VALUE *values);
+
+
+enum enum_dyncol_func_result
+mariadb_dyncol_exists_num(DYNAMIC_COLUMN *org, uint column_nr);
+enum enum_dyncol_func_result
+mariadb_dyncol_exists_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name);
+
+/* List of not NULL columns */
+enum enum_dyncol_func_result
+mariadb_dyncol_list_num(DYNAMIC_COLUMN *str, uint *count, uint **nums);
+enum enum_dyncol_func_result
+mariadb_dyncol_list_named(DYNAMIC_COLUMN *str, uint *count,
+                          MYSQL_LEX_STRING **names);
+
+/*
+   if the column do not exists it is NULL
+*/
+enum enum_dyncol_func_result
+mariadb_dyncol_get_num(DYNAMIC_COLUMN *org, uint column_nr,
+                       DYNAMIC_COLUMN_VALUE *store_it_here);
+enum enum_dyncol_func_result
+mariadb_dyncol_get_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name,
+                         DYNAMIC_COLUMN_VALUE *store_it_here);
+
+my_bool mariadb_dyncol_has_names(DYNAMIC_COLUMN *str);
+
+enum enum_dyncol_func_result
+mariadb_dyncol_check(DYNAMIC_COLUMN *str);
+
+enum enum_dyncol_func_result
+mariadb_dyncol_json(DYNAMIC_COLUMN *str, DYNAMIC_STRING *json);
+
+void mariadb_dyncol_free(DYNAMIC_COLUMN *str);
+
+#define mariadb_dyncol_init(A) memset((A), 0, sizeof(DYNAMIC_COLUMN))
+#define dynamic_column_initialize(A) mariadb_dyncol_init((A))
+#define dynamic_column_column_free(A) mariadb_dyncol_free((A))
+
+/* conversion of values to 3 base types */
+enum enum_dyncol_func_result
+mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val,
+                       MARIADB_CHARSET_INFO *cs, char quote);
+enum enum_dyncol_func_result
+mariadb_dyncol_val_long(longlong *ll, DYNAMIC_COLUMN_VALUE *val);
+enum enum_dyncol_func_result
+mariadb_dyncol_val_double(double *dbl, DYNAMIC_COLUMN_VALUE *val);
+
+enum enum_dyncol_func_result
+mariadb_dyncol_unpack(DYNAMIC_COLUMN *str,
+                      uint *count,
+                      MYSQL_LEX_STRING **names, DYNAMIC_COLUMN_VALUE **vals);
+
+int mariadb_dyncol_column_cmp_named(const MYSQL_LEX_STRING *s1,
+                                    const MYSQL_LEX_STRING *s2);
+
+enum enum_dyncol_func_result
+mariadb_dyncol_column_count(DYNAMIC_COLUMN *str, uint *column_count);
+
+#define mariadb_dyncol_value_init(V) (V)->type= DYN_COL_NULL
+
+/*
+  Prepare value for using as decimal
+*/
+void mariadb_dyncol_prepare_decimal(DYNAMIC_COLUMN_VALUE *value);
+
+
+#ifdef	__cplusplus
+}
+#endif
+#endif
diff --git a/3rdparty/mariadb/include/mariadb_rpl.h b/3rdparty/mariadb/include/mariadb_rpl.h
new file mode 100644
index 000000000..96b3aba04
--- /dev/null
+++ b/3rdparty/mariadb/include/mariadb_rpl.h
@@ -0,0 +1,305 @@
+/* Copyright (C) 2018 MariaDB Corporation AB 
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+ 
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+ 
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02111-1301, USA */
+#ifndef _mariadb_rpl_h_
+#define _mariadb_rpl_h_
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#define MARIADB_RPL_VERSION 0x0001
+#define MARIADB_RPL_REQUIRED_VERSION 0x0001
+
+/* Protocol flags */
+#define MARIADB_RPL_BINLOG_DUMP_NON_BLOCK 1
+#define MARIADB_RPL_BINLOG_SEND_ANNOTATE_ROWS 2
+#define MARIADB_RPL_IGNORE_HEARTBEAT (1 << 17)
+
+#define EVENT_HEADER_OFS 20
+
+#define FL_GROUP_COMMIT_ID 2
+#define FL_STMT_END 1
+
+#define LOG_EVENT_ARTIFICIAL_F 0x20
+
+
+/* Options */
+enum mariadb_rpl_option {
+  MARIADB_RPL_FILENAME,       /* Filename and length */
+  MARIADB_RPL_START,          /* Start position */
+  MARIADB_RPL_SERVER_ID,      /* Server ID */
+  MARIADB_RPL_FLAGS,          /* Protocol flags */
+  MARIADB_RPL_GTID_CALLBACK,  /* GTID callback function */
+  MARIADB_RPL_GTID_DATA,      /* GTID data */
+  MARIADB_RPL_BUFFER
+};
+
+/* Event types: From MariaDB Server sql/log_event.h */
+enum mariadb_rpl_event {
+  UNKNOWN_EVENT= 0,
+  START_EVENT_V3= 1,
+  QUERY_EVENT= 2,
+  STOP_EVENT= 3,
+  ROTATE_EVENT= 4,
+  INTVAR_EVENT= 5,
+  LOAD_EVENT= 6,
+  SLAVE_EVENT= 7,
+  CREATE_FILE_EVENT= 8,
+  APPEND_BLOCK_EVENT= 9,
+  EXEC_LOAD_EVENT= 10,
+  DELETE_FILE_EVENT= 11,
+  NEW_LOAD_EVENT= 12,
+  RAND_EVENT= 13,
+  USER_VAR_EVENT= 14,
+  FORMAT_DESCRIPTION_EVENT= 15,
+  XID_EVENT= 16,
+  BEGIN_LOAD_QUERY_EVENT= 17,
+  EXECUTE_LOAD_QUERY_EVENT= 18,
+  TABLE_MAP_EVENT = 19,
+
+  PRE_GA_WRITE_ROWS_EVENT = 20, /* deprecated */
+  PRE_GA_UPDATE_ROWS_EVENT = 21, /* deprecated */
+  PRE_GA_DELETE_ROWS_EVENT = 22, /* deprecated */
+
+  WRITE_ROWS_EVENT_V1 = 23,
+  UPDATE_ROWS_EVENT_V1 = 24,
+  DELETE_ROWS_EVENT_V1 = 25,
+  INCIDENT_EVENT= 26,
+  HEARTBEAT_LOG_EVENT= 27,
+  IGNORABLE_LOG_EVENT= 28,
+  ROWS_QUERY_LOG_EVENT= 29,
+  WRITE_ROWS_EVENT = 30,
+  UPDATE_ROWS_EVENT = 31,
+  DELETE_ROWS_EVENT = 32,
+  GTID_LOG_EVENT= 33,
+  ANONYMOUS_GTID_LOG_EVENT= 34,
+  PREVIOUS_GTIDS_LOG_EVENT= 35,
+  TRANSACTION_CONTEXT_EVENT= 36,
+  VIEW_CHANGE_EVENT= 37,
+  XA_PREPARE_LOG_EVENT= 38,
+
+  /*
+    Add new events here - right above this comment!
+    Existing events (except ENUM_END_EVENT) should never change their numbers
+  */
+
+  /* New MySQL/Sun events are to be added right above this comment */
+  MYSQL_EVENTS_END,
+
+  MARIA_EVENTS_BEGIN= 160,
+  ANNOTATE_ROWS_EVENT= 160,
+  BINLOG_CHECKPOINT_EVENT= 161,
+  GTID_EVENT= 162,
+  GTID_LIST_EVENT= 163,
+  START_ENCRYPTION_EVENT= 164,
+  QUERY_COMPRESSED_EVENT = 165,
+  WRITE_ROWS_COMPRESSED_EVENT_V1 = 166,
+  UPDATE_ROWS_COMPRESSED_EVENT_V1 = 167,
+  DELETE_ROWS_COMPRESSED_EVENT_V1 = 168,
+  WRITE_ROWS_COMPRESSED_EVENT = 169,
+  UPDATE_ROWS_COMPRESSED_EVENT = 170,
+  DELETE_ROWS_COMPRESSED_EVENT = 171,
+
+  /* Add new MariaDB events here - right above this comment!  */
+
+  ENUM_END_EVENT /* end marker */
+};
+
+typedef struct {
+  char *str;
+  size_t length;
+} MARIADB_STRING;
+
+enum mariadb_row_event_type {
+  WRITE_ROWS= 0,
+  UPDATE_ROWS= 1,
+  DELETE_ROWS= 2
+};
+
+/* Global transaction id */
+typedef struct st_mariadb_gtid {
+  unsigned int domain_id;
+  unsigned int server_id;
+  unsigned long long sequence_nr;
+} MARIADB_GTID;
+
+/* Generic replication handle */
+typedef struct st_mariadb_rpl {
+  unsigned int version;
+  MYSQL *mysql;
+  char *filename;
+  uint32_t filename_length;
+  unsigned char *buffer;
+  unsigned long buffer_size;
+  uint32_t server_id;
+  unsigned long start_position;
+  uint32_t flags;
+  uint8_t fd_header_len; /* header len from last format description event */
+  uint8_t use_checksum;
+} MARIADB_RPL;
+
+/* Event header */
+struct st_mariadb_rpl_rotate_event {
+  unsigned long long position;
+  MARIADB_STRING filename;
+};
+
+struct st_mariadb_rpl_query_event {
+  uint32_t thread_id;
+  uint32_t seconds;
+  MARIADB_STRING database;
+  uint32_t errornr;
+  MARIADB_STRING status;
+  MARIADB_STRING statement;
+};
+
+struct st_mariadb_rpl_gtid_list_event {
+  uint32_t gtid_cnt;
+  MARIADB_GTID *gtid;
+};
+
+struct st_mariadb_rpl_format_description_event
+{
+  uint16_t format;
+  char *server_version;
+  uint32_t timestamp;
+  uint8_t header_len;
+};
+
+struct st_mariadb_rpl_checkpoint_event {
+  MARIADB_STRING filename;
+};
+
+struct st_mariadb_rpl_xid_event {
+  uint64_t transaction_nr;
+};
+
+struct st_mariadb_rpl_gtid_event {
+  uint64_t sequence_nr;
+  uint32_t domain_id;
+  uint8_t flags;
+  uint64_t commit_id;
+};
+
+struct st_mariadb_rpl_annotate_rows_event {
+  MARIADB_STRING statement;
+};
+
+struct st_mariadb_rpl_table_map_event {
+  unsigned long long table_id;
+  MARIADB_STRING database;
+  MARIADB_STRING table;
+  unsigned int column_count;
+  MARIADB_STRING column_types;
+  MARIADB_STRING metadata;
+  char *null_indicator;
+};
+
+struct st_mariadb_rpl_rand_event {
+  unsigned long long first_seed;
+  unsigned long long second_seed;
+};
+
+struct st_mariadb_rpl_encryption_event {
+  char scheme;
+  unsigned int key_version;
+  char *nonce;
+};
+
+struct st_mariadb_rpl_intvar_event {
+  char type;
+  unsigned long long value;
+};
+
+struct st_mariadb_rpl_uservar_event {
+  MARIADB_STRING name;
+  uint8_t is_null;
+  uint8_t type;
+  uint32_t charset_nr;
+  MARIADB_STRING value;
+  uint8_t flags;
+};
+
+struct st_mariadb_rpl_rows_event {
+  enum mariadb_row_event_type type;
+  uint64_t table_id;
+  uint16_t flags;
+  uint32_t column_count;
+  char *column_bitmap;
+  char *column_update_bitmap;
+  size_t row_data_size;
+  void *row_data;
+};
+
+struct st_mariadb_rpl_heartbeat_event {
+  uint32_t timestamp;
+  uint32_t next_position;
+  uint8_t type;
+  uint16_t flags;
+};
+
+typedef struct st_mariadb_rpl_event
+{
+  /* common header */
+  MA_MEM_ROOT memroot;
+  unsigned int checksum;
+  char ok;
+  enum mariadb_rpl_event event_type;
+  unsigned int timestamp;
+  unsigned int server_id;
+  unsigned int event_length;
+  unsigned int next_event_pos;
+  unsigned short flags;
+  /****************/
+  union {
+    struct st_mariadb_rpl_rotate_event rotate;
+    struct st_mariadb_rpl_query_event query;
+    struct st_mariadb_rpl_format_description_event format_description;
+    struct st_mariadb_rpl_gtid_list_event gtid_list;
+    struct st_mariadb_rpl_checkpoint_event checkpoint;
+    struct st_mariadb_rpl_xid_event xid;
+    struct st_mariadb_rpl_gtid_event gtid;
+    struct st_mariadb_rpl_annotate_rows_event annotate_rows;
+    struct st_mariadb_rpl_table_map_event table_map;
+    struct st_mariadb_rpl_rand_event rand;
+    struct st_mariadb_rpl_encryption_event encryption;
+    struct st_mariadb_rpl_intvar_event intvar;
+    struct st_mariadb_rpl_uservar_event uservar;
+    struct st_mariadb_rpl_rows_event rows;
+    struct st_mariadb_rpl_heartbeat_event heartbeat;
+  } event;
+} MARIADB_RPL_EVENT;
+
+#define mariadb_rpl_init(a) mariadb_rpl_init_ex((a), MARIADB_RPL_VERSION)
+
+/* Function prototypes */
+MARIADB_RPL * STDCALL mariadb_rpl_init_ex(MYSQL *mysql, unsigned int version);
+
+int STDCALL mariadb_rpl_optionsv(MARIADB_RPL *rpl, enum mariadb_rpl_option, ...);
+int STDCALL mariadb_rpl_get_optionsv(MARIADB_RPL *rpl, enum mariadb_rpl_option, ...);
+
+int STDCALL mariadb_rpl_open(MARIADB_RPL *rpl);
+void STDCALL mariadb_rpl_close(MARIADB_RPL *rpl);
+MARIADB_RPL_EVENT * STDCALL mariadb_rpl_fetch(MARIADB_RPL *rpl, MARIADB_RPL_EVENT *event);
+void STDCALL mariadb_free_rpl_event(MARIADB_RPL_EVENT *event);
+
+#ifdef	__cplusplus
+}
+#endif
+#endif
diff --git a/3rdparty/mariadb/include/mariadb_stmt.h b/3rdparty/mariadb/include/mariadb_stmt.h
new file mode 100644
index 000000000..0aa14362a
--- /dev/null
+++ b/3rdparty/mariadb/include/mariadb_stmt.h
@@ -0,0 +1,298 @@
+/************************************************************************
+  
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02111-1301, USA 
+
+   Part of this code includes code from PHP's mysqlnd extension
+   (written by Andrey Hristov, Georg Richter and Ulf Wendel), freely
+   available from http://www.php.net/software
+
+*************************************************************************/
+
+#define MYSQL_NO_DATA 100
+#define MYSQL_DATA_TRUNCATED 101
+#define MYSQL_DEFAULT_PREFETCH_ROWS (unsigned long) 1
+
+/* Bind flags */
+#define MADB_BIND_DUMMY 1
+
+#define MARIADB_STMT_BULK_SUPPORTED(stmt)\
+  ((stmt)->mysql && \
+  (!((stmt)->mysql->server_capabilities & CLIENT_MYSQL) &&\
+    ((stmt)->mysql->extension->mariadb_server_capabilities & \
+    (MARIADB_CLIENT_STMT_BULK_OPERATIONS >> 32))))
+
+#define SET_CLIENT_STMT_ERROR(a, b, c, d) \
+{ \
+  (a)->last_errno= (b);\
+  strncpy((a)->sqlstate, (c), SQLSTATE_LENGTH);\
+  (a)->sqlstate[SQLSTATE_LENGTH]= 0;\
+  strncpy((a)->last_error, (d) ? (d) : ER((b)), MYSQL_ERRMSG_SIZE);\
+  (a)->last_error[MYSQL_ERRMSG_SIZE - 1]= 0;\
+}
+
+#define CLEAR_CLIENT_STMT_ERROR(a) \
+{ \
+  (a)->last_errno= 0;\
+  strcpy((a)->sqlstate, "00000");\
+  (a)->last_error[0]= 0;\
+}
+
+#define MYSQL_PS_SKIP_RESULT_W_LEN  -1
+#define MYSQL_PS_SKIP_RESULT_STR    -2
+#define STMT_ID_LENGTH 4
+
+
+typedef struct st_mysql_stmt MYSQL_STMT;
+
+typedef MYSQL_RES* (*mysql_stmt_use_or_store_func)(MYSQL_STMT *);
+
+enum enum_stmt_attr_type
+{
+  STMT_ATTR_UPDATE_MAX_LENGTH,
+  STMT_ATTR_CURSOR_TYPE,
+  STMT_ATTR_PREFETCH_ROWS,
+
+  /* MariaDB only */
+  STMT_ATTR_PREBIND_PARAMS=200,
+  STMT_ATTR_ARRAY_SIZE,
+  STMT_ATTR_ROW_SIZE,
+  STMT_ATTR_STATE,
+  STMT_ATTR_CB_USER_DATA,
+  STMT_ATTR_CB_PARAM,
+  STMT_ATTR_CB_RESULT
+};
+
+enum enum_cursor_type
+{
+  CURSOR_TYPE_NO_CURSOR= 0,
+  CURSOR_TYPE_READ_ONLY= 1,
+  CURSOR_TYPE_FOR_UPDATE= 2,
+  CURSOR_TYPE_SCROLLABLE= 4
+};
+
+enum enum_indicator_type
+{
+  STMT_INDICATOR_NTS=-1,
+  STMT_INDICATOR_NONE=0,
+  STMT_INDICATOR_NULL=1,
+  STMT_INDICATOR_DEFAULT=2,
+  STMT_INDICATOR_IGNORE=3,
+  STMT_INDICATOR_IGNORE_ROW=4
+};
+
+/*
+  bulk PS flags
+*/
+#define STMT_BULK_FLAG_CLIENT_SEND_TYPES 128
+#define STMT_BULK_FLAG_INSERT_ID_REQUEST 64
+
+typedef enum mysql_stmt_state
+{
+  MYSQL_STMT_INITTED = 0,
+  MYSQL_STMT_PREPARED,
+  MYSQL_STMT_EXECUTED,
+  MYSQL_STMT_WAITING_USE_OR_STORE,
+  MYSQL_STMT_USE_OR_STORE_CALLED,
+  MYSQL_STMT_USER_FETCHING, /* fetch_row_buff or fetch_row_unbuf */
+  MYSQL_STMT_FETCH_DONE
+} enum_mysqlnd_stmt_state;
+
+typedef struct st_mysql_bind
+{
+  unsigned long  *length;          /* output length pointer */
+  my_bool        *is_null;         /* Pointer to null indicator */
+  void           *buffer;          /* buffer to get/put data */
+  /* set this if you want to track data truncations happened during fetch */
+  my_bool        *error;
+  union {
+    unsigned char *row_ptr;        /* for the current data position */
+    char *indicator;               /* indicator variable */
+  } u;
+  void (*store_param_func)(NET *net, struct st_mysql_bind *param);
+  void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *,
+                       unsigned char **row);
+  void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *,
+          unsigned char **row);
+  /* output buffer length, must be set when fetching str/binary */
+  unsigned long  buffer_length;
+  unsigned long  offset;           /* offset position for char/binary fetch */
+  unsigned long  length_value;     /* Used if length is 0 */
+  unsigned int   flags;            /* special flags, e.g. for dummy bind  */
+  unsigned int   pack_length;      /* Internal length for packed data */
+  enum enum_field_types buffer_type;  /* buffer type */
+  my_bool        error_value;      /* used if error is 0 */
+  my_bool        is_unsigned;      /* set if integer type is unsigned */
+  my_bool        long_data_used;   /* If used with mysql_send_long_data */
+  my_bool        is_null_value;    /* Used if is_null is 0 */
+  void           *extension;
+} MYSQL_BIND;
+
+typedef struct st_mysqlnd_upsert_result
+{
+  unsigned int  warning_count;
+  unsigned int  server_status;
+  unsigned long long affected_rows;
+  unsigned long long last_insert_id;
+} mysql_upsert_status;
+
+typedef struct st_mysql_cmd_buffer
+{
+  unsigned char   *buffer;
+  size_t     length;
+} MYSQL_CMD_BUFFER;
+
+typedef struct st_mysql_error_info
+{
+  unsigned int error_no;
+  char error[MYSQL_ERRMSG_SIZE+1];
+  char sqlstate[SQLSTATE_LENGTH + 1];
+} mysql_error_info;
+
+
+struct st_mysqlnd_stmt_methods
+{
+  my_bool (*prepare)(const MYSQL_STMT * stmt, const char * const query, size_t query_len);
+  my_bool (*execute)(const MYSQL_STMT * stmt);
+  MYSQL_RES * (*use_result)(const MYSQL_STMT * stmt);
+  MYSQL_RES * (*store_result)(const MYSQL_STMT * stmt);
+  MYSQL_RES * (*get_result)(const MYSQL_STMT * stmt);
+  my_bool (*free_result)(const MYSQL_STMT * stmt);
+  my_bool (*seek_data)(const MYSQL_STMT * stmt, unsigned long long row);
+  my_bool (*reset)(const MYSQL_STMT * stmt);
+  my_bool (*close)(const MYSQL_STMT * stmt); /* private */
+  my_bool (*dtor)(const MYSQL_STMT * stmt); /* use this for mysqlnd_stmt_close */
+
+  my_bool (*fetch)(const MYSQL_STMT * stmt, my_bool * const fetched_anything);
+
+  my_bool (*bind_param)(const MYSQL_STMT * stmt, const MYSQL_BIND bind);
+  my_bool (*refresh_bind_param)(const MYSQL_STMT * stmt);
+  my_bool (*bind_result)(const MYSQL_STMT * stmt, const MYSQL_BIND *bind);
+  my_bool (*send_long_data)(const MYSQL_STMT * stmt, unsigned int param_num,
+                            const char * const data, size_t length);
+  MYSQL_RES *(*get_parameter_metadata)(const MYSQL_STMT * stmt);
+  MYSQL_RES *(*get_result_metadata)(const MYSQL_STMT * stmt);
+  unsigned long long (*get_last_insert_id)(const MYSQL_STMT * stmt);
+  unsigned long long (*get_affected_rows)(const MYSQL_STMT * stmt);
+  unsigned long long (*get_num_rows)(const MYSQL_STMT * stmt);
+
+  unsigned int (*get_param_count)(const MYSQL_STMT * stmt);
+  unsigned int (*get_field_count)(const MYSQL_STMT * stmt);
+  unsigned int (*get_warning_count)(const MYSQL_STMT * stmt);
+
+  unsigned int (*get_error_no)(const MYSQL_STMT * stmt);
+  const char * (*get_error_str)(const MYSQL_STMT * stmt);
+  const char * (*get_sqlstate)(const MYSQL_STMT * stmt);
+
+  my_bool (*get_attribute)(const MYSQL_STMT * stmt, enum enum_stmt_attr_type attr_type, const void * value);
+  my_bool (*set_attribute)(const MYSQL_STMT * stmt, enum enum_stmt_attr_type attr_type, const void * value);
+  void (*set_error)(MYSQL_STMT *stmt, unsigned int error_nr, const char *sqlstate, const char *format, ...);
+};
+
+typedef int  (*mysql_stmt_fetch_row_func)(MYSQL_STMT *stmt, unsigned char **row);
+typedef void (*ps_result_callback)(void *data, unsigned int column, unsigned char **row);
+typedef my_bool *(*ps_param_callback)(void *data, MYSQL_BIND *bind, unsigned int row_nr);
+
+struct st_mysql_stmt
+{
+  MA_MEM_ROOT              mem_root;
+  MYSQL                    *mysql;
+  unsigned long            stmt_id;
+  unsigned long            flags;/* cursor is set here */
+  enum_mysqlnd_stmt_state  state;
+  MYSQL_FIELD              *fields;
+  unsigned int             field_count;
+  unsigned int             param_count;
+  unsigned char            send_types_to_server;
+  MYSQL_BIND               *params;
+  MYSQL_BIND               *bind;
+  MYSQL_DATA               result;  /* we don't use mysqlnd's result set logic */
+  MYSQL_ROWS               *result_cursor;
+  my_bool                  bind_result_done;
+  my_bool                  bind_param_done;
+
+  mysql_upsert_status      upsert_status;
+
+  unsigned int last_errno;
+  char last_error[MYSQL_ERRMSG_SIZE+1];
+  char sqlstate[SQLSTATE_LENGTH + 1];
+
+  my_bool                  update_max_length;
+  unsigned long            prefetch_rows;
+  LIST                     list;
+
+  my_bool                  cursor_exists;
+
+  void                     *extension;
+  mysql_stmt_fetch_row_func fetch_row_func;
+  unsigned int             execute_count;/* count how many times the stmt was executed */
+  mysql_stmt_use_or_store_func default_rset_handler;
+  struct st_mysqlnd_stmt_methods  *m;
+  unsigned int             array_size;
+  size_t row_size;
+  unsigned int prebind_params;
+  void *user_data;
+  ps_result_callback result_callback;
+  ps_param_callback param_callback;
+};
+
+typedef void (*ps_field_fetch_func)(MYSQL_BIND *r_param, const MYSQL_FIELD * field, unsigned char **row);
+typedef struct st_mysql_perm_bind {
+  ps_field_fetch_func func;
+  /* should be signed int */
+  int pack_len;
+  unsigned long max_len;
+} MYSQL_PS_CONVERSION;
+
+extern MYSQL_PS_CONVERSION mysql_ps_fetch_functions[MYSQL_TYPE_GEOMETRY + 1];
+unsigned long ma_net_safe_read(MYSQL *mysql);
+void mysql_init_ps_subsystem(void);
+unsigned long net_field_length(unsigned char **packet);
+int ma_simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
+          	       size_t length, my_bool skipp_check, void *opt_arg);
+/*
+ *  function prototypes
+ */
+MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql);
+int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, unsigned long length);
+int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg, unsigned int column, unsigned long offset);
+int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
+unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt);
+my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, const void *attr);
+my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, void *attr);
+my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
+my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
+my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
+my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt);
+my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);
+my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, unsigned int param_number, const char *data, unsigned long length);
+MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt);
+MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt);
+unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt);
+const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt);
+const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt);
+MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset);
+MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt);
+void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, unsigned long long offset);
+unsigned long long STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt);
+unsigned long long STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
+unsigned long long STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt);
+unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt);
+my_bool STDCALL mysql_stmt_more_results(MYSQL_STMT *stmt);
+int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt, const char *stmt_str, size_t length);
+MYSQL_FIELD * STDCALL mariadb_stmt_fetch_fields(MYSQL_STMT *stmt);
diff --git a/3rdparty/mariadb/include/mariadb_version.h b/3rdparty/mariadb/include/mariadb_version.h
new file mode 100644
index 000000000..0fd2da691
--- /dev/null
+++ b/3rdparty/mariadb/include/mariadb_version.h
@@ -0,0 +1,38 @@
+/* Copyright Abandoned 1996, 1999, 2001 MySQL AB
+   This file is public domain and comes with NO WARRANTY of any kind */
+
+/* Version numbers for protocol & mysqld */
+
+#ifndef _mariadb_version_h_
+#define _mariadb_version_h_
+
+#ifdef _CUSTOMCONFIG_
+#include <custom_conf.h>
+#else
+#define PROTOCOL_VERSION		10
+#define MARIADB_CLIENT_VERSION_STR	"10.4.3"
+#define MARIADB_BASE_VERSION		"mariadb-10.4"
+#define MARIADB_VERSION_ID		100403
+#define MARIADB_PORT	        	3306
+#define MARIADB_UNIX_ADDR               "/tmp/mysql.sock"
+
+#define MYSQL_CONFIG_NAME               "my"
+#define MYSQL_VERSION_ID                100403
+#define MYSQL_SERVER_VERSION            "10.4.3-MariaDB"
+
+#define MARIADB_PACKAGE_VERSION "3.1.5"
+#define MARIADB_PACKAGE_VERSION_ID 30105
+#define MARIADB_SYSTEM_TYPE "Windows"
+#define MARIADB_MACHINE_TYPE "AMD64"
+#define MARIADB_PLUGINDIR "./3rdparty/mariadb/lib/plugin"
+
+/* mysqld compile time options */
+#ifndef MYSQL_CHARSET
+#define MYSQL_CHARSET			""
+#endif
+#endif
+
+/* Source information */
+#define CC_SOURCE_REVISION "980f2dbea6586091333057bb2994b18747466942"
+
+#endif /* _mariadb_version_h_ */
diff --git a/3rdparty/mariadb/include/mysql.h b/3rdparty/mariadb/include/mysql.h
new file mode 100644
index 000000000..dcaf316de
--- /dev/null
+++ b/3rdparty/mariadb/include/mysql.h
@@ -0,0 +1,868 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+                 2012 by MontyProgram AB
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02111-1301, USA */
+
+/* defines for the libmariadb library */
+
+#ifndef _mysql_h
+#define _mysql_h
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#ifndef LIBMARIADB
+#define LIBMARIADB
+#endif
+#ifndef MYSQL_CLIENT
+#define MYSQL_CLIENT
+#endif
+
+#include <stdarg.h>
+
+#if !defined (_global_h) && !defined (MY_GLOBAL_INCLUDED) /* If not standard header */
+#include <sys/types.h>
+typedef char my_bool;
+typedef unsigned long long my_ulonglong;
+
+#if !defined(_WIN32)
+#define STDCALL
+#else
+#define STDCALL __stdcall
+#endif
+
+#ifndef my_socket_defined
+#define my_socket_defined
+#if defined(_WIN64)
+#define my_socket unsigned long long
+#elif defined(_WIN32)
+#define my_socket unsigned int
+#else
+typedef int my_socket;
+#endif
+#endif
+#endif
+#include "mariadb_com.h"
+#include "mariadb_version.h"
+#include "ma_list.h"
+#include "mariadb_ctype.h"
+
+#ifndef ST_MA_USED_MEM_DEFINED
+#define ST_MA_USED_MEM_DEFINED
+  typedef struct st_ma_used_mem {   /* struct for once_alloc */
+    struct st_ma_used_mem *next;    /* Next block in use */
+    size_t left;                 /* memory left in block  */
+    size_t size;                 /* Size of block */
+  } MA_USED_MEM;
+
+  typedef struct st_ma_mem_root {
+    MA_USED_MEM *free;
+    MA_USED_MEM *used;
+    MA_USED_MEM *pre_alloc;
+    size_t min_malloc;
+    size_t block_size;
+    unsigned int block_num;
+    unsigned int first_block_usage;
+    void (*error_handler)(void);
+  } MA_MEM_ROOT;
+#endif
+
+extern unsigned int mysql_port;
+extern char *mysql_unix_port;
+extern unsigned int mariadb_deinitialize_ssl;
+
+#define IS_PRI_KEY(n)	((n) & PRI_KEY_FLAG)
+#define IS_NOT_NULL(n)	((n) & NOT_NULL_FLAG)
+#define IS_BLOB(n)	((n) & BLOB_FLAG)
+#define IS_NUM(t)	(((t) <= MYSQL_TYPE_INT24 && (t) != MYSQL_TYPE_TIMESTAMP) || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
+#define IS_NUM_FIELD(f)	 ((f)->flags & NUM_FLAG)
+#define INTERNAL_NUM_FIELD(f) (((f)->type <= MYSQL_TYPE_INT24 && ((f)->type != MYSQL_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == MYSQL_TYPE_YEAR || (f)->type == MYSQL_TYPE_NEWDECIMAL || (f)->type == MYSQL_TYPE_DECIMAL)
+
+  typedef struct st_mysql_field {
+    char *name;			/* Name of column */
+    char *org_name;		/* Name of original column (added after 3.23.58) */
+    char *table;			/* Table of column if column was a field */
+    char *org_table;		/* Name of original table (added after 3.23.58 */
+    char *db;                     /* table schema (added after 3.23.58) */
+    char *catalog;                /* table catalog (added after 3.23.58) */
+    char *def;			/* Default value (set by mysql_list_fields) */
+    unsigned long length;		/* Width of column */
+    unsigned long max_length;	/* Max width of selected set */
+  /* added after 3.23.58 */
+    unsigned int name_length;
+    unsigned int org_name_length;
+    unsigned int table_length;
+    unsigned int org_table_length;
+    unsigned int db_length;
+    unsigned int catalog_length;
+    unsigned int def_length;
+  /***********************/
+    unsigned int flags;		/* Div flags */
+    unsigned int decimals;	/* Number of decimals in field */
+    unsigned int charsetnr;       /* char set number (added in 4.1) */
+    enum enum_field_types type;	/* Type of field. Se mysql_com.h for types */
+    void *extension;              /* added in 4.1 */
+  } MYSQL_FIELD;
+
+  typedef char **MYSQL_ROW;		/* return data as array of strings */
+  typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
+
+#define SET_CLIENT_ERROR(a, b, c, d) \
+  { \
+    (a)->net.last_errno= (b);\
+    strncpy((a)->net.sqlstate, (c), SQLSTATE_LENGTH);\
+    (a)->net.sqlstate[SQLSTATE_LENGTH]= 0;\
+    strncpy((a)->net.last_error, (d) ? (d) : ER((b)), MYSQL_ERRMSG_SIZE - 1);\
+    (a)->net.last_error[MYSQL_ERRMSG_SIZE - 1]= 0;\
+  }
+
+/* For mysql_async.c */
+#define set_mariadb_error(A,B,C) SET_CLIENT_ERROR((A),(B),(C),0)
+extern const char *SQLSTATE_UNKNOWN;
+#define unknown_sqlstate SQLSTATE_UNKNOWN
+
+#define CLEAR_CLIENT_ERROR(a) \
+  { \
+    (a)->net.last_errno= 0;\
+    strcpy((a)->net.sqlstate, "00000");\
+    (a)->net.last_error[0]= '\0';\
+    (a)->net.extension->extended_errno= 0;\
+  }
+
+#define MYSQL_COUNT_ERROR (~(unsigned long long) 0)
+
+
+  typedef struct st_mysql_rows {
+    struct st_mysql_rows *next;		/* list of rows */
+    MYSQL_ROW data;
+    unsigned long length;
+  } MYSQL_ROWS;
+
+  typedef MYSQL_ROWS *MYSQL_ROW_OFFSET;	/* offset to current row */
+
+  typedef struct st_mysql_data {
+    MYSQL_ROWS *data;
+    void *embedded_info;
+    MA_MEM_ROOT alloc;
+    unsigned long long rows;
+    unsigned int fields;
+    void *extension;
+  } MYSQL_DATA;
+
+  enum mysql_option 
+  {
+    MYSQL_OPT_CONNECT_TIMEOUT, 
+    MYSQL_OPT_COMPRESS,
+    MYSQL_OPT_NAMED_PIPE,
+    MYSQL_INIT_COMMAND,
+    MYSQL_READ_DEFAULT_FILE,
+    MYSQL_READ_DEFAULT_GROUP,
+    MYSQL_SET_CHARSET_DIR,
+    MYSQL_SET_CHARSET_NAME,
+    MYSQL_OPT_LOCAL_INFILE,
+    MYSQL_OPT_PROTOCOL,
+    MYSQL_SHARED_MEMORY_BASE_NAME,
+    MYSQL_OPT_READ_TIMEOUT,
+    MYSQL_OPT_WRITE_TIMEOUT,
+    MYSQL_OPT_USE_RESULT,
+    MYSQL_OPT_USE_REMOTE_CONNECTION,
+    MYSQL_OPT_USE_EMBEDDED_CONNECTION,
+    MYSQL_OPT_GUESS_CONNECTION,
+    MYSQL_SET_CLIENT_IP,
+    MYSQL_SECURE_AUTH,
+    MYSQL_REPORT_DATA_TRUNCATION,
+    MYSQL_OPT_RECONNECT,
+    MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
+    MYSQL_PLUGIN_DIR,
+    MYSQL_DEFAULT_AUTH,
+    MYSQL_OPT_BIND,
+    MYSQL_OPT_SSL_KEY,
+    MYSQL_OPT_SSL_CERT,
+    MYSQL_OPT_SSL_CA,
+    MYSQL_OPT_SSL_CAPATH,
+    MYSQL_OPT_SSL_CIPHER,
+    MYSQL_OPT_SSL_CRL,
+    MYSQL_OPT_SSL_CRLPATH,
+    /* Connection attribute options */
+    MYSQL_OPT_CONNECT_ATTR_RESET,
+    MYSQL_OPT_CONNECT_ATTR_ADD,
+    MYSQL_OPT_CONNECT_ATTR_DELETE,
+    MYSQL_SERVER_PUBLIC_KEY,
+    MYSQL_ENABLE_CLEARTEXT_PLUGIN,
+    MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,
+    MYSQL_OPT_SSL_ENFORCE,
+    MYSQL_OPT_MAX_ALLOWED_PACKET,
+    MYSQL_OPT_NET_BUFFER_LENGTH,
+    MYSQL_OPT_TLS_VERSION,
+
+    /* MariaDB specific */
+    MYSQL_PROGRESS_CALLBACK=5999,
+    MYSQL_OPT_NONBLOCK,
+    /* MariaDB Connector/C specific */
+    MYSQL_DATABASE_DRIVER=7000,
+    MARIADB_OPT_SSL_FP,             /* deprecated, use MARIADB_OPT_TLS_PEER_FP instead */
+    MARIADB_OPT_SSL_FP_LIST,        /* deprecated, use MARIADB_OPT_TLS_PEER_FP_LIST instead */
+    MARIADB_OPT_TLS_PASSPHRASE,     /* passphrase for encrypted certificates */
+    MARIADB_OPT_TLS_CIPHER_STRENGTH,
+    MARIADB_OPT_TLS_VERSION,
+    MARIADB_OPT_TLS_PEER_FP,            /* single finger print for server certificate verification */
+    MARIADB_OPT_TLS_PEER_FP_LIST,       /* finger print white list for server certificate verification */
+    MARIADB_OPT_CONNECTION_READ_ONLY,
+    MYSQL_OPT_CONNECT_ATTRS,        /* for mysql_get_optionv */
+    MARIADB_OPT_USERDATA,
+    MARIADB_OPT_CONNECTION_HANDLER,
+    MARIADB_OPT_PORT,
+    MARIADB_OPT_UNIXSOCKET,
+    MARIADB_OPT_PASSWORD,
+    MARIADB_OPT_HOST,
+    MARIADB_OPT_USER,
+    MARIADB_OPT_SCHEMA,
+    MARIADB_OPT_DEBUG,
+    MARIADB_OPT_FOUND_ROWS,
+    MARIADB_OPT_MULTI_RESULTS,
+    MARIADB_OPT_MULTI_STATEMENTS,
+    MARIADB_OPT_INTERACTIVE,
+    MARIADB_OPT_PROXY_HEADER,
+    MARIADB_OPT_IO_WAIT
+  };
+
+  enum mariadb_value {
+    MARIADB_CHARSET_ID,
+    MARIADB_CHARSET_NAME,
+    MARIADB_CLIENT_ERRORS,
+    MARIADB_CLIENT_VERSION,
+    MARIADB_CLIENT_VERSION_ID,
+    MARIADB_CONNECTION_ASYNC_TIMEOUT,
+    MARIADB_CONNECTION_ASYNC_TIMEOUT_MS,
+    MARIADB_CONNECTION_MARIADB_CHARSET_INFO,
+    MARIADB_CONNECTION_ERROR,
+    MARIADB_CONNECTION_ERROR_ID,
+    MARIADB_CONNECTION_HOST,
+    MARIADB_CONNECTION_INFO,
+    MARIADB_CONNECTION_PORT,
+    MARIADB_CONNECTION_PROTOCOL_VERSION_ID,
+    MARIADB_CONNECTION_PVIO_TYPE,
+    MARIADB_CONNECTION_SCHEMA,
+    MARIADB_CONNECTION_SERVER_TYPE,
+    MARIADB_CONNECTION_SERVER_VERSION,
+    MARIADB_CONNECTION_SERVER_VERSION_ID,
+    MARIADB_CONNECTION_SOCKET,
+    MARIADB_CONNECTION_SQLSTATE,
+    MARIADB_CONNECTION_SSL_CIPHER,
+    MARIADB_TLS_LIBRARY,
+    MARIADB_CONNECTION_TLS_VERSION,
+    MARIADB_CONNECTION_TLS_VERSION_ID,
+    MARIADB_CONNECTION_TYPE,
+    MARIADB_CONNECTION_UNIX_SOCKET,
+    MARIADB_CONNECTION_USER,
+    MARIADB_MAX_ALLOWED_PACKET,
+    MARIADB_NET_BUFFER_LENGTH,
+    MARIADB_CONNECTION_SERVER_STATUS,
+    MARIADB_CONNECTION_SERVER_CAPABILITIES,
+    MARIADB_CONNECTION_EXTENDED_SERVER_CAPABILITIES,
+    MARIADB_CONNECTION_CLIENT_CAPABILITIES
+  };
+
+  enum mysql_status { MYSQL_STATUS_READY,
+                      MYSQL_STATUS_GET_RESULT,
+                      MYSQL_STATUS_USE_RESULT,
+                      MYSQL_STATUS_QUERY_SENT,
+                      MYSQL_STATUS_SENDING_LOAD_DATA,
+                      MYSQL_STATUS_FETCHING_DATA,
+                      MYSQL_STATUS_NEXT_RESULT_PENDING,
+                      MYSQL_STATUS_QUIT_SENT, /* object is "destroyed" at this stage */
+                      MYSQL_STATUS_STMT_RESULT
+  };
+
+  enum mysql_protocol_type
+  {
+    MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
+    MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
+  };
+
+struct st_mysql_options {
+    unsigned int connect_timeout, read_timeout, write_timeout;
+    unsigned int port, protocol;
+    unsigned long client_flag;
+    char *host,*user,*password,*unix_socket,*db;
+    struct st_dynamic_array *init_command;
+    char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
+    char *ssl_key;				/* PEM key file */
+    char *ssl_cert;				/* PEM cert file */
+    char *ssl_ca;					/* PEM CA file */
+    char *ssl_capath;				/* PEM directory of CA-s? */
+    char *ssl_cipher;
+    char *shared_memory_base_name;
+    unsigned long max_allowed_packet;
+    my_bool use_ssl;				/* if to use SSL or not */
+    my_bool compress,named_pipe;
+    my_bool reconnect, unused_1, unused_2, unused_3;
+    enum mysql_option methods_to_use;
+    char *bind_address;
+    my_bool secure_auth;
+    my_bool report_data_truncation; 
+    /* function pointers for local infile support */
+    int (*local_infile_init)(void **, const char *, void *);
+    int (*local_infile_read)(void *, char *, unsigned int);
+    void (*local_infile_end)(void *);
+    int (*local_infile_error)(void *, char *, unsigned int);
+    void *local_infile_userdata;
+    struct st_mysql_options_extension *extension;
+};
+
+  typedef struct st_mysql {
+    NET		net;			/* Communication parameters */
+    void  *unused_0;
+    char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
+    char *info,*db;
+    const struct ma_charset_info_st *charset;      /* character set */
+    MYSQL_FIELD *fields;
+    MA_MEM_ROOT field_alloc;
+    unsigned long long affected_rows;
+    unsigned long long insert_id;		/* id if insert on table with NEXTNR */
+    unsigned long long extra_info;		/* Used by mysqlshow */
+    unsigned long thread_id;		/* Id for connection in server */
+    unsigned long packet_length;
+    unsigned int port;
+    unsigned long client_flag;
+    unsigned long server_capabilities;
+    unsigned int protocol_version;
+    unsigned int field_count;
+    unsigned int server_status;
+    unsigned int server_language;
+    unsigned int warning_count;          /* warning count, added in 4.1 protocol */
+    struct st_mysql_options options;
+    enum mysql_status status;
+    my_bool	free_me;		/* If free in mysql_close */
+    my_bool	unused_1;
+    char	        scramble_buff[20+ 1];
+    /* madded after 3.23.58 */
+    my_bool       unused_2;
+    void          *unused_3, *unused_4, *unused_5, *unused_6;
+    LIST          *stmts;
+    const struct  st_mariadb_methods *methods;
+    void          *thd;
+    my_bool       *unbuffered_fetch_owner;
+    char          *info_buffer;
+    struct st_mariadb_extension *extension;
+} MYSQL;
+
+typedef struct st_mysql_res {
+  unsigned long long  row_count;
+  unsigned int	field_count, current_field;
+  MYSQL_FIELD	*fields;
+  MYSQL_DATA	*data;
+  MYSQL_ROWS	*data_cursor;
+  MA_MEM_ROOT	field_alloc;
+  MYSQL_ROW	row;			/* If unbuffered read */
+  MYSQL_ROW	current_row;		/* buffer to current row */
+  unsigned long *lengths;		/* column lengths of current row */
+  MYSQL		*handle;		/* for unbuffered reads */
+  my_bool	eof;			/* Used my mysql_fetch_row */
+  my_bool       is_ps;
+} MYSQL_RES;
+
+typedef struct
+{
+  unsigned long *p_max_allowed_packet;
+  unsigned long *p_net_buffer_length;
+  void *extension;
+} MYSQL_PARAMETERS;
+
+#ifndef _mysql_time_h_
+enum enum_mysql_timestamp_type
+{
+  MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+  MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+
+typedef struct st_mysql_time
+{
+  unsigned int  year, month, day, hour, minute, second;
+  unsigned long second_part;
+  my_bool       neg;
+  enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+#define AUTO_SEC_PART_DIGITS 39
+#endif
+
+#define SEC_PART_DIGITS 6
+#define MARIADB_INVALID_SOCKET -1
+
+/* Ansynchronous API constants */
+#define MYSQL_WAIT_READ      1
+#define MYSQL_WAIT_WRITE     2
+#define MYSQL_WAIT_EXCEPT    4
+#define MYSQL_WAIT_TIMEOUT   8
+
+typedef struct character_set
+{
+  unsigned int      number;     /* character set number              */
+  unsigned int      state;      /* character set state               */
+  const char        *csname;    /* character set name                */
+  const char        *name;      /* collation name                    */
+  const char        *comment;   /* comment                           */
+  const char        *dir;       /* character set directory           */
+  unsigned int      mbminlen;   /* min. length for multibyte strings */
+  unsigned int      mbmaxlen;   /* max. length for multibyte strings */
+} MY_CHARSET_INFO;
+
+/* Local infile support functions */
+#define LOCAL_INFILE_ERROR_LEN 512
+
+#include "mariadb_stmt.h"
+
+#ifndef MYSQL_CLIENT_PLUGIN_HEADER
+#define MYSQL_CLIENT_PLUGIN_HEADER                      \
+  int type;                                             \
+  unsigned int interface_version;                       \
+  const char *name;                                     \
+  const char *author;                                   \
+  const char *desc;                                     \
+  unsigned int version[3];                              \
+  const char *license;                                  \
+  void *mariadb_api;                                    \
+  int (*init)(char *, size_t, int, va_list);            \
+  int (*deinit)();                                      \
+  int (*options)(const char *option, const void *);
+struct st_mysql_client_plugin
+{
+  MYSQL_CLIENT_PLUGIN_HEADER
+};
+
+struct st_mysql_client_plugin *
+mysql_load_plugin(struct st_mysql *mysql, const char *name, int type,
+                  int argc, ...);
+struct st_mysql_client_plugin * STDCALL
+mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type,
+                    int argc, va_list args);
+struct st_mysql_client_plugin * STDCALL
+mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type);
+struct st_mysql_client_plugin * STDCALL
+mysql_client_register_plugin(struct st_mysql *mysql,
+                             struct st_mysql_client_plugin *plugin);
+#endif
+
+
+void STDCALL mysql_set_local_infile_handler(MYSQL *mysql,
+        int (*local_infile_init)(void **, const char *, void *),
+        int (*local_infile_read)(void *, char *, unsigned int),
+        void (*local_infile_end)(void *),
+        int (*local_infile_error)(void *, char*, unsigned int),
+        void *);
+
+void mysql_set_local_infile_default(MYSQL *mysql);
+
+void my_set_error(MYSQL *mysql, unsigned int error_nr, 
+                  const char *sqlstate, const char *format, ...);
+/* Functions to get information from the MYSQL and MYSQL_RES structures */
+/* Should definitely be used if one uses shared libraries */
+
+my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res);
+unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
+my_bool STDCALL mysql_eof(MYSQL_RES *res);
+MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res,
+					      unsigned int fieldnr);
+MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
+MYSQL_ROWS * STDCALL mysql_row_tell(MYSQL_RES *res);
+unsigned int STDCALL mysql_field_tell(MYSQL_RES *res);
+
+unsigned int STDCALL mysql_field_count(MYSQL *mysql);
+my_bool STDCALL mysql_more_results(MYSQL *mysql);
+int STDCALL mysql_next_result(MYSQL *mysql);
+my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
+my_bool STDCALL mysql_autocommit(MYSQL *mysql, my_bool mode);
+my_bool STDCALL mysql_commit(MYSQL *mysql);
+my_bool STDCALL mysql_rollback(MYSQL *mysql);
+my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
+unsigned int STDCALL mysql_errno(MYSQL *mysql);
+const char * STDCALL mysql_error(MYSQL *mysql);
+const char * STDCALL mysql_info(MYSQL *mysql);
+unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
+const char * STDCALL mysql_character_set_name(MYSQL *mysql);
+void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs);
+int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname);
+
+my_bool mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *arg, ...);
+my_bool STDCALL mariadb_get_info(MYSQL *mysql, enum mariadb_value value, void *arg);
+MYSQL *		STDCALL mysql_init(MYSQL *mysql);
+int		STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
+				      const char *cert, const char *ca,
+				      const char *capath, const char *cipher);
+const char *	STDCALL mysql_get_ssl_cipher(MYSQL *mysql);
+my_bool		STDCALL mysql_change_user(MYSQL *mysql, const char *user, 
+					  const char *passwd, const char *db);
+MYSQL *		STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
+					   const char *user,
+					   const char *passwd,
+					   const char *db,
+					   unsigned int port,
+					   const char *unix_socket,
+					   unsigned long clientflag);
+void		STDCALL mysql_close(MYSQL *sock);
+int		STDCALL mysql_select_db(MYSQL *mysql, const char *db);
+int		STDCALL mysql_query(MYSQL *mysql, const char *q);
+int		STDCALL mysql_send_query(MYSQL *mysql, const char *q,
+					 unsigned long length);
+my_bool	STDCALL mysql_read_query_result(MYSQL *mysql);
+int		STDCALL mysql_real_query(MYSQL *mysql, const char *q,
+					 unsigned long length);
+int		STDCALL mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level);
+int		STDCALL mysql_dump_debug_info(MYSQL *mysql);
+int		STDCALL mysql_refresh(MYSQL *mysql,
+				     unsigned int refresh_options);
+int		STDCALL mysql_kill(MYSQL *mysql,unsigned long pid);
+int		STDCALL mysql_ping(MYSQL *mysql);
+char *		STDCALL mysql_stat(MYSQL *mysql);
+char *		STDCALL mysql_get_server_info(MYSQL *mysql);
+unsigned long   STDCALL mysql_get_server_version(MYSQL *mysql);
+char *		STDCALL mysql_get_host_info(MYSQL *mysql);
+unsigned int	STDCALL mysql_get_proto_info(MYSQL *mysql);
+MYSQL_RES *	STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
+MYSQL_RES *	STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
+MYSQL_RES *	STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
+					 const char *wild);
+MYSQL_RES *	STDCALL mysql_list_processes(MYSQL *mysql);
+MYSQL_RES *	STDCALL mysql_store_result(MYSQL *mysql);
+MYSQL_RES *	STDCALL mysql_use_result(MYSQL *mysql);
+int		STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
+				      const void *arg);
+int		STDCALL mysql_options4(MYSQL *mysql,enum mysql_option option,
+				      const void *arg1, const void *arg2);
+void		STDCALL mysql_free_result(MYSQL_RES *result);
+void		STDCALL mysql_data_seek(MYSQL_RES *result,
+					unsigned long long offset);
+MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET);
+MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
+					   MYSQL_FIELD_OFFSET offset);
+MYSQL_ROW	STDCALL mysql_fetch_row(MYSQL_RES *result);
+unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result);
+MYSQL_FIELD *	STDCALL mysql_fetch_field(MYSQL_RES *result);
+unsigned long	STDCALL mysql_escape_string(char *to,const char *from,
+					    unsigned long from_length);
+unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
+					       char *to,const char *from,
+					       unsigned long length);
+unsigned int	STDCALL mysql_thread_safe(void);
+unsigned int STDCALL mysql_warning_count(MYSQL *mysql);
+const char * STDCALL mysql_sqlstate(MYSQL *mysql);
+int STDCALL mysql_server_init(int argc, char **argv, char **groups);
+void STDCALL mysql_server_end(void);
+void STDCALL mysql_thread_end(void);
+my_bool STDCALL mysql_thread_init(void);
+int STDCALL mysql_set_server_option(MYSQL *mysql, 
+                                    enum enum_mysql_set_option option);
+const char * STDCALL mysql_get_client_info(void);
+unsigned long STDCALL mysql_get_client_version(void);
+my_bool STDCALL mariadb_connection(MYSQL *mysql);
+const char * STDCALL mysql_get_server_name(MYSQL *mysql);
+MARIADB_CHARSET_INFO * STDCALL mariadb_get_charset_by_name(const char *csname);
+MARIADB_CHARSET_INFO * STDCALL mariadb_get_charset_by_nr(unsigned int csnr);
+size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, MARIADB_CHARSET_INFO *from_cs,
+                                      char *to, size_t *to_len, MARIADB_CHARSET_INFO *to_cs, int *errorcode);
+int mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...);
+int mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...);
+int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option, void *arg);
+unsigned long STDCALL mysql_hex_string(char *to, const char *from, unsigned long len);
+my_socket STDCALL mysql_get_socket(MYSQL *mysql);
+unsigned int STDCALL mysql_get_timeout_value(const MYSQL *mysql);
+unsigned int STDCALL mysql_get_timeout_value_ms(const MYSQL *mysql);
+my_bool STDCALL mariadb_reconnect(MYSQL *mysql);
+int STDCALL mariadb_cancel(MYSQL *mysql);
+void STDCALL mysql_debug(const char *debug);
+unsigned long STDCALL mysql_net_read_packet(MYSQL *mysql);
+unsigned long STDCALL mysql_net_field_length(unsigned char **packet);
+my_bool STDCALL mysql_embedded(void);
+MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void);
+
+/* Async API */
+int STDCALL mysql_close_start(MYSQL *sock);
+int STDCALL mysql_close_cont(MYSQL *sock, int status);
+int STDCALL mysql_commit_start(my_bool *ret, MYSQL * mysql);
+int STDCALL mysql_commit_cont(my_bool *ret, MYSQL * mysql, int status);
+int STDCALL mysql_dump_debug_info_cont(int *ret, MYSQL *mysql, int ready_status);
+int STDCALL mysql_dump_debug_info_start(int *ret, MYSQL *mysql);
+int STDCALL mysql_rollback_start(my_bool *ret, MYSQL * mysql);
+int STDCALL mysql_rollback_cont(my_bool *ret, MYSQL * mysql, int status);
+int STDCALL mysql_autocommit_start(my_bool *ret, MYSQL * mysql,
+                                   my_bool auto_mode);
+int STDCALL mysql_list_fields_cont(MYSQL_RES **ret, MYSQL *mysql, int ready_status);
+int STDCALL mysql_list_fields_start(MYSQL_RES **ret, MYSQL *mysql, const char *table,
+                        const char *wild);
+int STDCALL mysql_autocommit_cont(my_bool *ret, MYSQL * mysql, int status);
+int STDCALL mysql_next_result_start(int *ret, MYSQL *mysql);
+int STDCALL mysql_next_result_cont(int *ret, MYSQL *mysql, int status);
+int STDCALL mysql_select_db_start(int *ret, MYSQL *mysql, const char *db);
+int STDCALL mysql_select_db_cont(int *ret, MYSQL *mysql, int ready_status);
+int STDCALL mysql_stmt_warning_count(MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_next_result_start(int *ret, MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_next_result_cont(int *ret, MYSQL_STMT *stmt, int status);
+
+int STDCALL mysql_set_character_set_start(int *ret, MYSQL *mysql,
+                                                   const char *csname);
+int STDCALL mysql_set_character_set_cont(int *ret, MYSQL *mysql,
+                                                  int status);
+int STDCALL mysql_change_user_start(my_bool *ret, MYSQL *mysql,
+                                                const char *user,
+                                                const char *passwd,
+                                                const char *db);
+int STDCALL mysql_change_user_cont(my_bool *ret, MYSQL *mysql,
+                                               int status);
+int         STDCALL mysql_real_connect_start(MYSQL **ret, MYSQL *mysql,
+                                                 const char *host,
+                                                 const char *user,
+                                                 const char *passwd,
+                                                 const char *db,
+                                                 unsigned int port,
+                                                 const char *unix_socket,
+                                                 unsigned long clientflag);
+int         STDCALL mysql_real_connect_cont(MYSQL **ret, MYSQL *mysql,
+                                                int status);
+int             STDCALL mysql_query_start(int *ret, MYSQL *mysql,
+                                          const char *q);
+int             STDCALL mysql_query_cont(int *ret, MYSQL *mysql,
+                                         int status);
+int             STDCALL mysql_send_query_start(int *ret, MYSQL *mysql,
+                                               const char *q,
+                                               unsigned long length);
+int             STDCALL mysql_send_query_cont(int *ret, MYSQL *mysql, int status);
+int             STDCALL mysql_real_query_start(int *ret, MYSQL *mysql,
+                                               const char *q,
+                                               unsigned long length);
+int             STDCALL mysql_real_query_cont(int *ret, MYSQL *mysql,
+                                              int status);
+int             STDCALL mysql_store_result_start(MYSQL_RES **ret, MYSQL *mysql);
+int             STDCALL mysql_store_result_cont(MYSQL_RES **ret, MYSQL *mysql,
+                                                int status);
+int             STDCALL mysql_shutdown_start(int *ret, MYSQL *mysql,
+                                             enum mysql_enum_shutdown_level
+                                             shutdown_level);
+int             STDCALL mysql_shutdown_cont(int *ret, MYSQL *mysql,
+                                            int status);
+int             STDCALL mysql_refresh_start(int *ret, MYSQL *mysql,
+                                            unsigned int refresh_options);
+int             STDCALL mysql_refresh_cont(int *ret, MYSQL *mysql, int status);
+int             STDCALL mysql_kill_start(int *ret, MYSQL *mysql,
+                                         unsigned long pid);
+int             STDCALL mysql_kill_cont(int *ret, MYSQL *mysql, int status);
+int             STDCALL mysql_set_server_option_start(int *ret, MYSQL *mysql,
+                                                      enum enum_mysql_set_option
+                                                      option);
+int             STDCALL mysql_set_server_option_cont(int *ret, MYSQL *mysql,
+                                                     int status);
+int             STDCALL mysql_ping_start(int *ret, MYSQL *mysql);
+int             STDCALL mysql_ping_cont(int *ret, MYSQL *mysql, int status);
+int             STDCALL mysql_stat_start(const char **ret, MYSQL *mysql);
+int             STDCALL mysql_stat_cont(const char **ret, MYSQL *mysql,
+                                        int status);
+int             STDCALL mysql_free_result_start(MYSQL_RES *result);
+int             STDCALL mysql_free_result_cont(MYSQL_RES *result, int status);
+int             STDCALL mysql_fetch_row_start(MYSQL_ROW *ret,
+                                              MYSQL_RES *result);
+int             STDCALL mysql_fetch_row_cont(MYSQL_ROW *ret, MYSQL_RES *result,
+                                             int status);
+int             STDCALL mysql_read_query_result_start(my_bool *ret,
+                                                      MYSQL *mysql);
+int             STDCALL mysql_read_query_result_cont(my_bool *ret,
+                                                     MYSQL *mysql, int status);
+int             STDCALL mysql_reset_connection_start(int *ret, MYSQL *mysql);
+int             STDCALL mysql_reset_connection_cont(int *ret, MYSQL *mysql, int status);
+int STDCALL mysql_session_track_get_next(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length);
+int STDCALL mysql_session_track_get_first(MYSQL *mysql, enum enum_session_state_type type, const char **data, size_t *length);
+int STDCALL mysql_stmt_prepare_start(int *ret, MYSQL_STMT *stmt,const char *query, unsigned long length);
+int STDCALL mysql_stmt_prepare_cont(int *ret, MYSQL_STMT *stmt, int status);
+int STDCALL mysql_stmt_execute_start(int *ret, MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_execute_cont(int *ret, MYSQL_STMT *stmt, int status);
+int STDCALL mysql_stmt_fetch_start(int *ret, MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_fetch_cont(int *ret, MYSQL_STMT *stmt, int status);
+int STDCALL mysql_stmt_store_result_start(int *ret, MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_store_result_cont(int *ret, MYSQL_STMT *stmt,int status);
+int STDCALL mysql_stmt_close_start(my_bool *ret, MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_close_cont(my_bool *ret, MYSQL_STMT * stmt, int status);
+int STDCALL mysql_stmt_reset_start(my_bool *ret, MYSQL_STMT * stmt);
+int STDCALL mysql_stmt_reset_cont(my_bool *ret, MYSQL_STMT *stmt, int status);
+int STDCALL mysql_stmt_free_result_start(my_bool *ret, MYSQL_STMT *stmt);
+int STDCALL mysql_stmt_free_result_cont(my_bool *ret, MYSQL_STMT *stmt,
+                                        int status);
+int STDCALL mysql_stmt_send_long_data_start(my_bool *ret, MYSQL_STMT *stmt,
+                                            unsigned int param_number,
+                                            const char *data,
+                                            unsigned long len);
+int STDCALL mysql_stmt_send_long_data_cont(my_bool *ret, MYSQL_STMT *stmt,
+                                           int status);
+int STDCALL mysql_reset_connection(MYSQL *mysql);
+
+/* API function calls (used by dynmic plugins) */
+struct st_mariadb_api {
+  unsigned long long (STDCALL *mysql_num_rows)(MYSQL_RES *res);
+  unsigned int (STDCALL *mysql_num_fields)(MYSQL_RES *res);
+  my_bool (STDCALL *mysql_eof)(MYSQL_RES *res);
+  MYSQL_FIELD *(STDCALL *mysql_fetch_field_direct)(MYSQL_RES *res, unsigned int fieldnr);
+  MYSQL_FIELD * (STDCALL *mysql_fetch_fields)(MYSQL_RES *res);
+  MYSQL_ROWS * (STDCALL *mysql_row_tell)(MYSQL_RES *res);
+  unsigned int (STDCALL *mysql_field_tell)(MYSQL_RES *res);
+  unsigned int (STDCALL *mysql_field_count)(MYSQL *mysql);
+  my_bool (STDCALL *mysql_more_results)(MYSQL *mysql);
+  int (STDCALL *mysql_next_result)(MYSQL *mysql);
+  unsigned long long (STDCALL *mysql_affected_rows)(MYSQL *mysql);
+  my_bool (STDCALL *mysql_autocommit)(MYSQL *mysql, my_bool mode);
+  my_bool (STDCALL *mysql_commit)(MYSQL *mysql);
+  my_bool (STDCALL *mysql_rollback)(MYSQL *mysql);
+  unsigned long long (STDCALL *mysql_insert_id)(MYSQL *mysql);
+  unsigned int (STDCALL *mysql_errno)(MYSQL *mysql);
+  const char * (STDCALL *mysql_error)(MYSQL *mysql);
+  const char * (STDCALL *mysql_info)(MYSQL *mysql);
+  unsigned long (STDCALL *mysql_thread_id)(MYSQL *mysql);
+  const char * (STDCALL *mysql_character_set_name)(MYSQL *mysql);
+  void (STDCALL *mysql_get_character_set_info)(MYSQL *mysql, MY_CHARSET_INFO *cs);
+  int (STDCALL *mysql_set_character_set)(MYSQL *mysql, const char *csname);
+  my_bool (*mariadb_get_infov)(MYSQL *mysql, enum mariadb_value value, void *arg, ...);
+  my_bool (STDCALL *mariadb_get_info)(MYSQL *mysql, enum mariadb_value value, void *arg);
+  MYSQL * (STDCALL *mysql_init)(MYSQL *mysql);
+  int (STDCALL *mysql_ssl_set)(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher);
+  const char * (STDCALL *mysql_get_ssl_cipher)(MYSQL *mysql);
+  my_bool (STDCALL *mysql_change_user)(MYSQL *mysql, const char *user, const char *passwd, const char *db);
+  MYSQL * (STDCALL *mysql_real_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag);
+  void (STDCALL *mysql_close)(MYSQL *sock);
+  int (STDCALL *mysql_select_db)(MYSQL *mysql, const char *db);
+  int (STDCALL *mysql_query)(MYSQL *mysql, const char *q);
+  int (STDCALL *mysql_send_query)(MYSQL *mysql, const char *q, unsigned long length);
+  my_bool (STDCALL *mysql_read_query_result)(MYSQL *mysql);
+  int (STDCALL *mysql_real_query)(MYSQL *mysql, const char *q, unsigned long length);
+  int (STDCALL *mysql_shutdown)(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level);
+  int (STDCALL *mysql_dump_debug_info)(MYSQL *mysql);
+  int (STDCALL *mysql_refresh)(MYSQL *mysql, unsigned int refresh_options);
+  int (STDCALL *mysql_kill)(MYSQL *mysql,unsigned long pid);
+  int (STDCALL *mysql_ping)(MYSQL *mysql);
+  char * (STDCALL *mysql_stat)(MYSQL *mysql);
+  char * (STDCALL *mysql_get_server_info)(MYSQL *mysql);
+  unsigned long (STDCALL *mysql_get_server_version)(MYSQL *mysql);
+  char * (STDCALL *mysql_get_host_info)(MYSQL *mysql);
+  unsigned int (STDCALL *mysql_get_proto_info)(MYSQL *mysql);
+  MYSQL_RES * (STDCALL *mysql_list_dbs)(MYSQL *mysql,const char *wild);
+  MYSQL_RES * (STDCALL *mysql_list_tables)(MYSQL *mysql,const char *wild);
+  MYSQL_RES * (STDCALL *mysql_list_fields)(MYSQL *mysql, const char *table, const char *wild);
+  MYSQL_RES * (STDCALL *mysql_list_processes)(MYSQL *mysql);
+  MYSQL_RES * (STDCALL *mysql_store_result)(MYSQL *mysql);
+  MYSQL_RES * (STDCALL *mysql_use_result)(MYSQL *mysql);
+  int (STDCALL *mysql_options)(MYSQL *mysql,enum mysql_option option, const void *arg);
+  void (STDCALL *mysql_free_result)(MYSQL_RES *result);
+  void (STDCALL *mysql_data_seek)(MYSQL_RES *result, unsigned long long offset);
+  MYSQL_ROW_OFFSET (STDCALL *mysql_row_seek)(MYSQL_RES *result, MYSQL_ROW_OFFSET);
+  MYSQL_FIELD_OFFSET (STDCALL *mysql_field_seek)(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset);
+  MYSQL_ROW (STDCALL *mysql_fetch_row)(MYSQL_RES *result);
+  unsigned long * (STDCALL *mysql_fetch_lengths)(MYSQL_RES *result);
+  MYSQL_FIELD * (STDCALL *mysql_fetch_field)(MYSQL_RES *result);
+  unsigned long (STDCALL *mysql_escape_string)(char *to,const char *from, unsigned long from_length);
+  unsigned long (STDCALL *mysql_real_escape_string)(MYSQL *mysql, char *to,const char *from, unsigned long length);
+  unsigned int (STDCALL *mysql_thread_safe)(void);
+  unsigned int (STDCALL *mysql_warning_count)(MYSQL *mysql);
+  const char * (STDCALL *mysql_sqlstate)(MYSQL *mysql);
+  int (STDCALL *mysql_server_init)(int argc, char **argv, char **groups);
+  void (STDCALL *mysql_server_end)(void);
+  void (STDCALL *mysql_thread_end)(void);
+  my_bool (STDCALL *mysql_thread_init)(void);
+  int (STDCALL *mysql_set_server_option)(MYSQL *mysql, enum enum_mysql_set_option option);
+  const char * (STDCALL *mysql_get_client_info)(void);
+  unsigned long (STDCALL *mysql_get_client_version)(void);
+  my_bool (STDCALL *mariadb_connection)(MYSQL *mysql);
+  const char * (STDCALL *mysql_get_server_name)(MYSQL *mysql);
+  MARIADB_CHARSET_INFO * (STDCALL *mariadb_get_charset_by_name)(const char *csname);
+  MARIADB_CHARSET_INFO * (STDCALL *mariadb_get_charset_by_nr)(unsigned int csnr);
+  size_t (STDCALL *mariadb_convert_string)(const char *from, size_t *from_len, MARIADB_CHARSET_INFO *from_cs, char *to, size_t *to_len, MARIADB_CHARSET_INFO *to_cs, int *errorcode);
+  int (*mysql_optionsv)(MYSQL *mysql,enum mysql_option option, ...);
+  int (*mysql_get_optionv)(MYSQL *mysql, enum mysql_option option, void *arg, ...);
+  int (STDCALL *mysql_get_option)(MYSQL *mysql, enum mysql_option option, void *arg);
+  unsigned long (STDCALL *mysql_hex_string)(char *to, const char *from, unsigned long len);
+  my_socket (STDCALL *mysql_get_socket)(MYSQL *mysql);
+  unsigned int (STDCALL *mysql_get_timeout_value)(const MYSQL *mysql);
+  unsigned int (STDCALL *mysql_get_timeout_value_ms)(const MYSQL *mysql);
+  my_bool (STDCALL *mariadb_reconnect)(MYSQL *mysql);
+  MYSQL_STMT * (STDCALL *mysql_stmt_init)(MYSQL *mysql);
+  int (STDCALL *mysql_stmt_prepare)(MYSQL_STMT *stmt, const char *query, unsigned long length);
+  int (STDCALL *mysql_stmt_execute)(MYSQL_STMT *stmt);
+  int (STDCALL *mysql_stmt_fetch)(MYSQL_STMT *stmt);
+  int (STDCALL *mysql_stmt_fetch_column)(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg, unsigned int column, unsigned long offset);
+  int (STDCALL *mysql_stmt_store_result)(MYSQL_STMT *stmt);
+  unsigned long (STDCALL *mysql_stmt_param_count)(MYSQL_STMT * stmt);
+  my_bool (STDCALL *mysql_stmt_attr_set)(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, const void *attr);
+  my_bool (STDCALL *mysql_stmt_attr_get)(MYSQL_STMT *stmt, enum enum_stmt_attr_type attr_type, void *attr);
+  my_bool (STDCALL *mysql_stmt_bind_param)(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
+  my_bool (STDCALL *mysql_stmt_bind_result)(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
+  my_bool (STDCALL *mysql_stmt_close)(MYSQL_STMT * stmt);
+  my_bool (STDCALL *mysql_stmt_reset)(MYSQL_STMT * stmt);
+  my_bool (STDCALL *mysql_stmt_free_result)(MYSQL_STMT *stmt);
+  my_bool (STDCALL *mysql_stmt_send_long_data)(MYSQL_STMT *stmt, unsigned int param_number, const char *data, unsigned long length);
+  MYSQL_RES *(STDCALL *mysql_stmt_result_metadata)(MYSQL_STMT *stmt);
+  MYSQL_RES *(STDCALL *mysql_stmt_param_metadata)(MYSQL_STMT *stmt);
+  unsigned int (STDCALL *mysql_stmt_errno)(MYSQL_STMT * stmt);
+  const char *(STDCALL *mysql_stmt_error)(MYSQL_STMT * stmt);
+  const char *(STDCALL *mysql_stmt_sqlstate)(MYSQL_STMT * stmt);
+  MYSQL_ROW_OFFSET (STDCALL *mysql_stmt_row_seek)(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset);
+  MYSQL_ROW_OFFSET (STDCALL *mysql_stmt_row_tell)(MYSQL_STMT *stmt);
+  void (STDCALL *mysql_stmt_data_seek)(MYSQL_STMT *stmt, unsigned long long offset);
+  unsigned long long (STDCALL *mysql_stmt_num_rows)(MYSQL_STMT *stmt);
+  unsigned long long (STDCALL *mysql_stmt_affected_rows)(MYSQL_STMT *stmt);
+  unsigned long long (STDCALL *mysql_stmt_insert_id)(MYSQL_STMT *stmt);
+  unsigned int (STDCALL *mysql_stmt_field_count)(MYSQL_STMT *stmt);
+  int (STDCALL *mysql_stmt_next_result)(MYSQL_STMT *stmt);
+  my_bool (STDCALL *mysql_stmt_more_results)(MYSQL_STMT *stmt);
+  int (STDCALL *mariadb_stmt_execute_direct)(MYSQL_STMT *stmt, const char *stmtstr, size_t length);
+  int (STDCALL *mysql_reset_connection)(MYSQL *mysql);
+};
+  
+/* these methods can be overwritten by db plugins */
+struct st_mariadb_methods {
+  MYSQL *(*db_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd,
+					   const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag);
+  void (*db_close)(MYSQL *mysql);
+  int (*db_command)(MYSQL *mysql,enum enum_server_command command, const char *arg,
+                    size_t length, my_bool skipp_check, void *opt_arg);
+  void (*db_skip_result)(MYSQL *mysql);
+  int (*db_read_query_result)(MYSQL *mysql);
+  MYSQL_DATA *(*db_read_rows)(MYSQL *mysql,MYSQL_FIELD *fields, unsigned int field_count);
+  int (*db_read_one_row)(MYSQL *mysql,unsigned int fields,MYSQL_ROW row, unsigned long *lengths);
+  /* prepared statements */
+  my_bool (*db_supported_buffer_type)(enum enum_field_types type);
+  my_bool (*db_read_prepare_response)(MYSQL_STMT *stmt);
+  int (*db_read_stmt_result)(MYSQL *mysql);
+  my_bool (*db_stmt_get_result_metadata)(MYSQL_STMT *stmt);
+  my_bool (*db_stmt_get_param_metadata)(MYSQL_STMT *stmt);
+  int (*db_stmt_read_all_rows)(MYSQL_STMT *stmt);
+  int (*db_stmt_fetch)(MYSQL_STMT *stmt, unsigned char **row);
+  int (*db_stmt_fetch_to_bind)(MYSQL_STMT *stmt, unsigned char *row);
+  void (*db_stmt_flush_unbuffered)(MYSQL_STMT *stmt);
+  void (*set_error)(MYSQL *mysql, unsigned int error_nr, const char *sqlstate, const char *format, ...);
+  void (*invalidate_stmts)(MYSQL *mysql, const char *function_name);
+  struct st_mariadb_api *api;
+};
+
+/* synonyms/aliases functions */
+#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
+#define mysql_library_init mysql_server_init
+#define mysql_library_end mysql_server_end
+
+/* new api functions */
+
+#define HAVE_MYSQL_REAL_CONNECT
+
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif
diff --git a/3rdparty/mariadb/include/mysqld_error.h b/3rdparty/mariadb/include/mysqld_error.h
new file mode 100644
index 000000000..cc8c76d21
--- /dev/null
+++ b/3rdparty/mariadb/include/mysqld_error.h
@@ -0,0 +1,1126 @@
+/* Autogenerated file, please don't edit
+   branch: 10.2
+   revision id: 01a4eb8f761eb669fe2ae5139c73a7434b141a8f
+ */
+
+#define ER_ERROR_FIRST 1000
+#define ER_HASHCHK 1000
+#define ER_NISAMCHK 1001
+#define ER_NO 1002
+#define ER_YES 1003
+#define ER_CANT_CREATE_FILE 1004
+#define ER_CANT_CREATE_TABLE 1005
+#define ER_CANT_CREATE_DB 1006
+#define ER_DB_CREATE_EXISTS 1007
+#define ER_DB_DROP_EXISTS 1008
+#define ER_DB_DROP_DELETE 1009
+#define ER_DB_DROP_RMDIR 1010
+#define ER_CANT_DELETE_FILE 1011
+#define ER_CANT_FIND_SYSTEM_REC 1012
+#define ER_CANT_GET_STAT 1013
+#define ER_CANT_GET_WD 1014
+#define ER_CANT_LOCK 1015
+#define ER_CANT_OPEN_FILE 1016
+#define ER_FILE_NOT_FOUND 1017
+#define ER_CANT_READ_DIR 1018
+#define ER_CANT_SET_WD 1019
+#define ER_CHECKREAD 1020
+#define ER_DISK_FULL 1021
+#define ER_DUP_KEY 1022
+#define ER_ERROR_ON_CLOSE 1023
+#define ER_ERROR_ON_READ 1024
+#define ER_ERROR_ON_RENAME 1025
+#define ER_ERROR_ON_WRITE 1026
+#define ER_FILE_USED 1027
+#define ER_FILSORT_ABORT 1028
+#define ER_FORM_NOT_FOUND 1029
+#define ER_GET_ERRNO 1030
+#define ER_ILLEGAL_HA 1031
+#define ER_KEY_NOT_FOUND 1032
+#define ER_NOT_FORM_FILE 1033
+#define ER_NOT_KEYFILE 1034
+#define ER_OLD_KEYFILE 1035
+#define ER_OPEN_AS_READONLY 1036
+#define ER_OUTOFMEMORY 1037
+#define ER_OUT_OF_SORTMEMORY 1038
+#define ER_UNEXPECTED_EOF 1039
+#define ER_CON_COUNT_ERROR 1040
+#define ER_OUT_OF_RESOURCES 1041
+#define ER_BAD_HOST_ERROR 1042
+#define ER_HANDSHAKE_ERROR 1043
+#define ER_DBACCESS_DENIED_ERROR 1044
+#define ER_ACCESS_DENIED_ERROR 1045
+#define ER_NO_DB_ERROR 1046
+#define ER_UNKNOWN_COM_ERROR 1047
+#define ER_BAD_NULL_ERROR 1048
+#define ER_BAD_DB_ERROR 1049
+#define ER_TABLE_EXISTS_ERROR 1050
+#define ER_BAD_TABLE_ERROR 1051
+#define ER_NON_UNIQ_ERROR 1052
+#define ER_SERVER_SHUTDOWN 1053
+#define ER_BAD_FIELD_ERROR 1054
+#define ER_WRONG_FIELD_WITH_GROUP 1055
+#define ER_WRONG_GROUP_FIELD 1056
+#define ER_WRONG_SUM_SELECT 1057
+#define ER_WRONG_VALUE_COUNT 1058
+#define ER_TOO_LONG_IDENT 1059
+#define ER_DUP_FIELDNAME 1060
+#define ER_DUP_KEYNAME 1061
+#define ER_DUP_ENTRY 1062
+#define ER_WRONG_FIELD_SPEC 1063
+#define ER_PARSE_ERROR 1064
+#define ER_EMPTY_QUERY 1065
+#define ER_NONUNIQ_TABLE 1066
+#define ER_INVALID_DEFAULT 1067
+#define ER_MULTIPLE_PRI_KEY 1068
+#define ER_TOO_MANY_KEYS 1069
+#define ER_TOO_MANY_KEY_PARTS 1070
+#define ER_TOO_LONG_KEY 1071
+#define ER_KEY_COLUMN_DOES_NOT_EXITS 1072
+#define ER_BLOB_USED_AS_KEY 1073
+#define ER_TOO_BIG_FIELDLENGTH 1074
+#define ER_WRONG_AUTO_KEY 1075
+#define ER_UNUSED_9 1076
+#define ER_NORMAL_SHUTDOWN 1077
+#define ER_GOT_SIGNAL 1078
+#define ER_SHUTDOWN_COMPLETE 1079
+#define ER_FORCING_CLOSE 1080
+#define ER_IPSOCK_ERROR 1081
+#define ER_NO_SUCH_INDEX 1082
+#define ER_WRONG_FIELD_TERMINATORS 1083
+#define ER_BLOBS_AND_NO_TERMINATED 1084
+#define ER_TEXTFILE_NOT_READABLE 1085
+#define ER_FILE_EXISTS_ERROR 1086
+#define ER_LOAD_INFO 1087
+#define ER_ALTER_INFO 1088
+#define ER_WRONG_SUB_KEY 1089
+#define ER_CANT_REMOVE_ALL_FIELDS 1090
+#define ER_CANT_DROP_FIELD_OR_KEY 1091
+#define ER_INSERT_INFO 1092
+#define ER_UPDATE_TABLE_USED 1093
+#define ER_NO_SUCH_THREAD 1094
+#define ER_KILL_DENIED_ERROR 1095
+#define ER_NO_TABLES_USED 1096
+#define ER_TOO_BIG_SET 1097
+#define ER_NO_UNIQUE_LOGFILE 1098
+#define ER_TABLE_NOT_LOCKED_FOR_WRITE 1099
+#define ER_TABLE_NOT_LOCKED 1100
+#define ER_BLOB_CANT_HAVE_DEFAULT 1101
+#define ER_WRONG_DB_NAME 1102
+#define ER_WRONG_TABLE_NAME 1103
+#define ER_TOO_BIG_SELECT 1104
+#define ER_UNKNOWN_ERROR 1105
+#define ER_UNKNOWN_PROCEDURE 1106
+#define ER_WRONG_PARAMCOUNT_TO_PROCEDURE 1107
+#define ER_WRONG_PARAMETERS_TO_PROCEDURE 1108
+#define ER_UNKNOWN_TABLE 1109
+#define ER_FIELD_SPECIFIED_TWICE 1110
+#define ER_INVALID_GROUP_FUNC_USE 1111
+#define ER_UNSUPPORTED_EXTENSION 1112
+#define ER_TABLE_MUST_HAVE_COLUMNS 1113
+#define ER_RECORD_FILE_FULL 1114
+#define ER_UNKNOWN_CHARACTER_SET 1115
+#define ER_TOO_MANY_TABLES 1116
+#define ER_TOO_MANY_FIELDS 1117
+#define ER_TOO_BIG_ROWSIZE 1118
+#define ER_STACK_OVERRUN 1119
+#define ER_WRONG_OUTER_JOIN 1120
+#define ER_NULL_COLUMN_IN_INDEX 1121
+#define ER_CANT_FIND_UDF 1122
+#define ER_CANT_INITIALIZE_UDF 1123
+#define ER_UDF_NO_PATHS 1124
+#define ER_UDF_EXISTS 1125
+#define ER_CANT_OPEN_LIBRARY 1126
+#define ER_CANT_FIND_DL_ENTRY 1127
+#define ER_FUNCTION_NOT_DEFINED 1128
+#define ER_HOST_IS_BLOCKED 1129
+#define ER_HOST_NOT_PRIVILEGED 1130
+#define ER_PASSWORD_ANONYMOUS_USER 1131
+#define ER_PASSWORD_NOT_ALLOWED 1132
+#define ER_PASSWORD_NO_MATCH 1133
+#define ER_UPDATE_INFO 1134
+#define ER_CANT_CREATE_THREAD 1135
+#define ER_WRONG_VALUE_COUNT_ON_ROW 1136
+#define ER_CANT_REOPEN_TABLE 1137
+#define ER_INVALID_USE_OF_NULL 1138
+#define ER_REGEXP_ERROR 1139
+#define ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140
+#define ER_NONEXISTING_GRANT 1141
+#define ER_TABLEACCESS_DENIED_ERROR 1142
+#define ER_COLUMNACCESS_DENIED_ERROR 1143
+#define ER_ILLEGAL_GRANT_FOR_TABLE 1144
+#define ER_GRANT_WRONG_HOST_OR_USER 1145
+#define ER_NO_SUCH_TABLE 1146
+#define ER_NONEXISTING_TABLE_GRANT 1147
+#define ER_NOT_ALLOWED_COMMAND 1148
+#define ER_SYNTAX_ERROR 1149
+#define ER_DELAYED_CANT_CHANGE_LOCK 1150
+#define ER_TOO_MANY_DELAYED_THREADS 1151
+#define ER_ABORTING_CONNECTION 1152
+#define ER_NET_PACKET_TOO_LARGE 1153
+#define ER_NET_READ_ERROR_FROM_PIPE 1154
+#define ER_NET_FCNTL_ERROR 1155
+#define ER_NET_PACKETS_OUT_OF_ORDER 1156
+#define ER_NET_UNCOMPRESS_ERROR 1157
+#define ER_NET_READ_ERROR 1158
+#define ER_NET_READ_INTERRUPTED 1159
+#define ER_NET_ERROR_ON_WRITE 1160
+#define ER_NET_WRITE_INTERRUPTED 1161
+#define ER_TOO_LONG_STRING 1162
+#define ER_TABLE_CANT_HANDLE_BLOB 1163
+#define ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164
+#define ER_DELAYED_INSERT_TABLE_LOCKED 1165
+#define ER_WRONG_COLUMN_NAME 1166
+#define ER_WRONG_KEY_COLUMN 1167
+#define ER_WRONG_MRG_TABLE 1168
+#define ER_DUP_UNIQUE 1169
+#define ER_BLOB_KEY_WITHOUT_LENGTH 1170
+#define ER_PRIMARY_CANT_HAVE_NULL 1171
+#define ER_TOO_MANY_ROWS 1172
+#define ER_REQUIRES_PRIMARY_KEY 1173
+#define ER_NO_RAID_COMPILED 1174
+#define ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175
+#define ER_KEY_DOES_NOT_EXITS 1176
+#define ER_CHECK_NO_SUCH_TABLE 1177
+#define ER_CHECK_NOT_IMPLEMENTED 1178
+#define ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179
+#define ER_ERROR_DURING_COMMIT 1180
+#define ER_ERROR_DURING_ROLLBACK 1181
+#define ER_ERROR_DURING_FLUSH_LOGS 1182
+#define ER_ERROR_DURING_CHECKPOINT 1183
+#define ER_NEW_ABORTING_CONNECTION 1184
+#define ER_UNUSED_10 1185
+#define ER_FLUSH_MASTER_BINLOG_CLOSED 1186
+#define ER_INDEX_REBUILD 1187
+#define ER_MASTER 1188
+#define ER_MASTER_NET_READ 1189
+#define ER_MASTER_NET_WRITE 1190
+#define ER_FT_MATCHING_KEY_NOT_FOUND 1191
+#define ER_LOCK_OR_ACTIVE_TRANSACTION 1192
+#define ER_UNKNOWN_SYSTEM_VARIABLE 1193
+#define ER_CRASHED_ON_USAGE 1194
+#define ER_CRASHED_ON_REPAIR 1195
+#define ER_WARNING_NOT_COMPLETE_ROLLBACK 1196
+#define ER_TRANS_CACHE_FULL 1197
+#define ER_SLAVE_MUST_STOP 1198
+#define ER_SLAVE_NOT_RUNNING 1199
+#define ER_BAD_SLAVE 1200
+#define ER_MASTER_INFO 1201
+#define ER_SLAVE_THREAD 1202
+#define ER_TOO_MANY_USER_CONNECTIONS 1203
+#define ER_SET_CONSTANTS_ONLY 1204
+#define ER_LOCK_WAIT_TIMEOUT 1205
+#define ER_LOCK_TABLE_FULL 1206
+#define ER_READ_ONLY_TRANSACTION 1207
+#define ER_DROP_DB_WITH_READ_LOCK 1208
+#define ER_CREATE_DB_WITH_READ_LOCK 1209
+#define ER_WRONG_ARGUMENTS 1210
+#define ER_NO_PERMISSION_TO_CREATE_USER 1211
+#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
+#define ER_LOCK_DEADLOCK 1213
+#define ER_TABLE_CANT_HANDLE_FT 1214
+#define ER_CANNOT_ADD_FOREIGN 1215
+#define ER_NO_REFERENCED_ROW 1216
+#define ER_ROW_IS_REFERENCED 1217
+#define ER_CONNECT_TO_MASTER 1218
+#define ER_QUERY_ON_MASTER 1219
+#define ER_ERROR_WHEN_EXECUTING_COMMAND 1220
+#define ER_WRONG_USAGE 1221
+#define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222
+#define ER_CANT_UPDATE_WITH_READLOCK 1223
+#define ER_MIXING_NOT_ALLOWED 1224
+#define ER_DUP_ARGUMENT 1225
+#define ER_USER_LIMIT_REACHED 1226
+#define ER_SPECIFIC_ACCESS_DENIED_ERROR 1227
+#define ER_LOCAL_VARIABLE 1228
+#define ER_GLOBAL_VARIABLE 1229
+#define ER_NO_DEFAULT 1230
+#define ER_WRONG_VALUE_FOR_VAR 1231
+#define ER_WRONG_TYPE_FOR_VAR 1232
+#define ER_VAR_CANT_BE_READ 1233
+#define ER_CANT_USE_OPTION_HERE 1234
+#define ER_NOT_SUPPORTED_YET 1235
+#define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
+#define ER_SLAVE_IGNORED_TABLE 1237
+#define ER_INCORRECT_GLOBAL_LOCAL_VAR 1238
+#define ER_WRONG_FK_DEF 1239
+#define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1240
+#define ER_OPERAND_COLUMNS 1241
+#define ER_SUBQUERY_NO_1_ROW 1242
+#define ER_UNKNOWN_STMT_HANDLER 1243
+#define ER_CORRUPT_HELP_DB 1244
+#define ER_CYCLIC_REFERENCE 1245
+#define ER_AUTO_CONVERT 1246
+#define ER_ILLEGAL_REFERENCE 1247
+#define ER_DERIVED_MUST_HAVE_ALIAS 1248
+#define ER_SELECT_REDUCED 1249
+#define ER_TABLENAME_NOT_ALLOWED_HERE 1250
+#define ER_NOT_SUPPORTED_AUTH_MODE 1251
+#define ER_SPATIAL_CANT_HAVE_NULL 1252
+#define ER_COLLATION_CHARSET_MISMATCH 1253
+#define ER_SLAVE_WAS_RUNNING 1254
+#define ER_SLAVE_WAS_NOT_RUNNING 1255
+#define ER_TOO_BIG_FOR_UNCOMPRESS 1256
+#define ER_ZLIB_Z_MEM_ERROR 1257
+#define ER_ZLIB_Z_BUF_ERROR 1258
+#define ER_ZLIB_Z_DATA_ERROR 1259
+#define ER_CUT_VALUE_GROUP_CONCAT 1260
+#define ER_WARN_TOO_FEW_RECORDS 1261
+#define ER_WARN_TOO_MANY_RECORDS 1262
+#define ER_WARN_NULL_TO_NOTNULL 1263
+#define ER_WARN_DATA_OUT_OF_RANGE 1264
+#define WARN_DATA_TRUNCATED 1265
+#define ER_WARN_USING_OTHER_HANDLER 1266
+#define ER_CANT_AGGREGATE_2COLLATIONS 1267
+#define ER_DROP_USER 1268
+#define ER_REVOKE_GRANTS 1269
+#define ER_CANT_AGGREGATE_3COLLATIONS 1270
+#define ER_CANT_AGGREGATE_NCOLLATIONS 1271
+#define ER_VARIABLE_IS_NOT_STRUCT 1272
+#define ER_UNKNOWN_COLLATION 1273
+#define ER_SLAVE_IGNORED_SSL_PARAMS 1274
+#define ER_SERVER_IS_IN_SECURE_AUTH_MODE 1275
+#define ER_WARN_FIELD_RESOLVED 1276
+#define ER_BAD_SLAVE_UNTIL_COND 1277
+#define ER_MISSING_SKIP_SLAVE 1278
+#define ER_UNTIL_COND_IGNORED 1279
+#define ER_WRONG_NAME_FOR_INDEX 1280
+#define ER_WRONG_NAME_FOR_CATALOG 1281
+#define ER_WARN_QC_RESIZE 1282
+#define ER_BAD_FT_COLUMN 1283
+#define ER_UNKNOWN_KEY_CACHE 1284
+#define ER_WARN_HOSTNAME_WONT_WORK 1285
+#define ER_UNKNOWN_STORAGE_ENGINE 1286
+#define ER_WARN_DEPRECATED_SYNTAX 1287
+#define ER_NON_UPDATABLE_TABLE 1288
+#define ER_FEATURE_DISABLED 1289
+#define ER_OPTION_PREVENTS_STATEMENT 1290
+#define ER_DUPLICATED_VALUE_IN_TYPE 1291
+#define ER_TRUNCATED_WRONG_VALUE 1292
+#define ER_TOO_MUCH_AUTO_TIMESTAMP_COLS 1293
+#define ER_INVALID_ON_UPDATE 1294
+#define ER_UNSUPPORTED_PS 1295
+#define ER_GET_ERRMSG 1296
+#define ER_GET_TEMPORARY_ERRMSG 1297
+#define ER_UNKNOWN_TIME_ZONE 1298
+#define ER_WARN_INVALID_TIMESTAMP 1299
+#define ER_INVALID_CHARACTER_STRING 1300
+#define ER_WARN_ALLOWED_PACKET_OVERFLOWED 1301
+#define ER_CONFLICTING_DECLARATIONS 1302
+#define ER_SP_NO_RECURSIVE_CREATE 1303
+#define ER_SP_ALREADY_EXISTS 1304
+#define ER_SP_DOES_NOT_EXIST 1305
+#define ER_SP_DROP_FAILED 1306
+#define ER_SP_STORE_FAILED 1307
+#define ER_SP_LILABEL_MISMATCH 1308
+#define ER_SP_LABEL_REDEFINE 1309
+#define ER_SP_LABEL_MISMATCH 1310
+#define ER_SP_UNINIT_VAR 1311
+#define ER_SP_BADSELECT 1312
+#define ER_SP_BADRETURN 1313
+#define ER_SP_BADSTATEMENT 1314
+#define ER_UPDATE_LOG_DEPRECATED_IGNORED 1315
+#define ER_UPDATE_LOG_DEPRECATED_TRANSLATED 1316
+#define ER_QUERY_INTERRUPTED 1317
+#define ER_SP_WRONG_NO_OF_ARGS 1318
+#define ER_SP_COND_MISMATCH 1319
+#define ER_SP_NORETURN 1320
+#define ER_SP_NORETURNEND 1321
+#define ER_SP_BAD_CURSOR_QUERY 1322
+#define ER_SP_BAD_CURSOR_SELECT 1323
+#define ER_SP_CURSOR_MISMATCH 1324
+#define ER_SP_CURSOR_ALREADY_OPEN 1325
+#define ER_SP_CURSOR_NOT_OPEN 1326
+#define ER_SP_UNDECLARED_VAR 1327
+#define ER_SP_WRONG_NO_OF_FETCH_ARGS 1328
+#define ER_SP_FETCH_NO_DATA 1329
+#define ER_SP_DUP_PARAM 1330
+#define ER_SP_DUP_VAR 1331
+#define ER_SP_DUP_COND 1332
+#define ER_SP_DUP_CURS 1333
+#define ER_SP_CANT_ALTER 1334
+#define ER_SP_SUBSELECT_NYI 1335
+#define ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG 1336
+#define ER_SP_VARCOND_AFTER_CURSHNDLR 1337
+#define ER_SP_CURSOR_AFTER_HANDLER 1338
+#define ER_SP_CASE_NOT_FOUND 1339
+#define ER_FPARSER_TOO_BIG_FILE 1340
+#define ER_FPARSER_BAD_HEADER 1341
+#define ER_FPARSER_EOF_IN_COMMENT 1342
+#define ER_FPARSER_ERROR_IN_PARAMETER 1343
+#define ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER 1344
+#define ER_VIEW_NO_EXPLAIN 1345
+#define ER_FRM_UNKNOWN_TYPE 1346
+#define ER_WRONG_OBJECT 1347
+#define ER_NONUPDATEABLE_COLUMN 1348
+#define ER_VIEW_SELECT_DERIVED 1349
+#define ER_VIEW_SELECT_CLAUSE 1350
+#define ER_VIEW_SELECT_VARIABLE 1351
+#define ER_VIEW_SELECT_TMPTABLE 1352
+#define ER_VIEW_WRONG_LIST 1353
+#define ER_WARN_VIEW_MERGE 1354
+#define ER_WARN_VIEW_WITHOUT_KEY 1355
+#define ER_VIEW_INVALID 1356
+#define ER_SP_NO_DROP_SP 1357
+#define ER_SP_GOTO_IN_HNDLR 1358
+#define ER_TRG_ALREADY_EXISTS 1359
+#define ER_TRG_DOES_NOT_EXIST 1360
+#define ER_TRG_ON_VIEW_OR_TEMP_TABLE 1361
+#define ER_TRG_CANT_CHANGE_ROW 1362
+#define ER_TRG_NO_SUCH_ROW_IN_TRG 1363
+#define ER_NO_DEFAULT_FOR_FIELD 1364
+#define ER_DIVISION_BY_ZERO 1365
+#define ER_TRUNCATED_WRONG_VALUE_FOR_FIELD 1366
+#define ER_ILLEGAL_VALUE_FOR_TYPE 1367
+#define ER_VIEW_NONUPD_CHECK 1368
+#define ER_VIEW_CHECK_FAILED 1369
+#define ER_PROCACCESS_DENIED_ERROR 1370
+#define ER_RELAY_LOG_FAIL 1371
+#define ER_PASSWD_LENGTH 1372
+#define ER_UNKNOWN_TARGET_BINLOG 1373
+#define ER_IO_ERR_LOG_INDEX_READ 1374
+#define ER_BINLOG_PURGE_PROHIBITED 1375
+#define ER_FSEEK_FAIL 1376
+#define ER_BINLOG_PURGE_FATAL_ERR 1377
+#define ER_LOG_IN_USE 1378
+#define ER_LOG_PURGE_UNKNOWN_ERR 1379
+#define ER_RELAY_LOG_INIT 1380
+#define ER_NO_BINARY_LOGGING 1381
+#define ER_RESERVED_SYNTAX 1382
+#define ER_WSAS_FAILED 1383
+#define ER_DIFF_GROUPS_PROC 1384
+#define ER_NO_GROUP_FOR_PROC 1385
+#define ER_ORDER_WITH_PROC 1386
+#define ER_LOGGING_PROHIBIT_CHANGING_OF 1387
+#define ER_NO_FILE_MAPPING 1388
+#define ER_WRONG_MAGIC 1389
+#define ER_PS_MANY_PARAM 1390
+#define ER_KEY_PART_0 1391
+#define ER_VIEW_CHECKSUM 1392
+#define ER_VIEW_MULTIUPDATE 1393
+#define ER_VIEW_NO_INSERT_FIELD_LIST 1394
+#define ER_VIEW_DELETE_MERGE_VIEW 1395
+#define ER_CANNOT_USER 1396
+#define ER_XAER_NOTA 1397
+#define ER_XAER_INVAL 1398
+#define ER_XAER_RMFAIL 1399
+#define ER_XAER_OUTSIDE 1400
+#define ER_XAER_RMERR 1401
+#define ER_XA_RBROLLBACK 1402
+#define ER_NONEXISTING_PROC_GRANT 1403
+#define ER_PROC_AUTO_GRANT_FAIL 1404
+#define ER_PROC_AUTO_REVOKE_FAIL 1405
+#define ER_DATA_TOO_LONG 1406
+#define ER_SP_BAD_SQLSTATE 1407
+#define ER_STARTUP 1408
+#define ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR 1409
+#define ER_CANT_CREATE_USER_WITH_GRANT 1410
+#define ER_WRONG_VALUE_FOR_TYPE 1411
+#define ER_TABLE_DEF_CHANGED 1412
+#define ER_SP_DUP_HANDLER 1413
+#define ER_SP_NOT_VAR_ARG 1414
+#define ER_SP_NO_RETSET 1415
+#define ER_CANT_CREATE_GEOMETRY_OBJECT 1416
+#define ER_FAILED_ROUTINE_BREAK_BINLOG 1417
+#define ER_BINLOG_UNSAFE_ROUTINE 1418
+#define ER_BINLOG_CREATE_ROUTINE_NEED_SUPER 1419
+#define ER_EXEC_STMT_WITH_OPEN_CURSOR 1420
+#define ER_STMT_HAS_NO_OPEN_CURSOR 1421
+#define ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG 1422
+#define ER_NO_DEFAULT_FOR_VIEW_FIELD 1423
+#define ER_SP_NO_RECURSION 1424
+#define ER_TOO_BIG_SCALE 1425
+#define ER_TOO_BIG_PRECISION 1426
+#define ER_M_BIGGER_THAN_D 1427
+#define ER_WRONG_LOCK_OF_SYSTEM_TABLE 1428
+#define ER_CONNECT_TO_FOREIGN_DATA_SOURCE 1429
+#define ER_QUERY_ON_FOREIGN_DATA_SOURCE 1430
+#define ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST 1431
+#define ER_FOREIGN_DATA_STRING_INVALID_CANT_CREATE 1432
+#define ER_FOREIGN_DATA_STRING_INVALID 1433
+#define ER_CANT_CREATE_FEDERATED_TABLE 1434
+#define ER_TRG_IN_WRONG_SCHEMA 1435
+#define ER_STACK_OVERRUN_NEED_MORE 1436
+#define ER_TOO_LONG_BODY 1437
+#define ER_WARN_CANT_DROP_DEFAULT_KEYCACHE 1438
+#define ER_TOO_BIG_DISPLAYWIDTH 1439
+#define ER_XAER_DUPID 1440
+#define ER_DATETIME_FUNCTION_OVERFLOW 1441
+#define ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG 1442
+#define ER_VIEW_PREVENT_UPDATE 1443
+#define ER_PS_NO_RECURSION 1444
+#define ER_SP_CANT_SET_AUTOCOMMIT 1445
+#define ER_MALFORMED_DEFINER 1446
+#define ER_VIEW_FRM_NO_USER 1447
+#define ER_VIEW_OTHER_USER 1448
+#define ER_NO_SUCH_USER 1449
+#define ER_FORBID_SCHEMA_CHANGE 1450
+#define ER_ROW_IS_REFERENCED_2 1451
+#define ER_NO_REFERENCED_ROW_2 1452
+#define ER_SP_BAD_VAR_SHADOW 1453
+#define ER_TRG_NO_DEFINER 1454
+#define ER_OLD_FILE_FORMAT 1455
+#define ER_SP_RECURSION_LIMIT 1456
+#define ER_SP_PROC_TABLE_CORRUPT 1457
+#define ER_SP_WRONG_NAME 1458
+#define ER_TABLE_NEEDS_UPGRADE 1459
+#define ER_SP_NO_AGGREGATE 1460
+#define ER_MAX_PREPARED_STMT_COUNT_REACHED 1461
+#define ER_VIEW_RECURSIVE 1462
+#define ER_NON_GROUPING_FIELD_USED 1463
+#define ER_TABLE_CANT_HANDLE_SPKEYS 1464
+#define ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA 1465
+#define ER_REMOVED_SPACES 1466
+#define ER_AUTOINC_READ_FAILED 1467
+#define ER_USERNAME 1468
+#define ER_HOSTNAME 1469
+#define ER_WRONG_STRING_LENGTH 1470
+#define ER_NON_INSERTABLE_TABLE 1471
+#define ER_ADMIN_WRONG_MRG_TABLE 1472
+#define ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT 1473
+#define ER_NAME_BECOMES_EMPTY 1474
+#define ER_AMBIGUOUS_FIELD_TERM 1475
+#define ER_FOREIGN_SERVER_EXISTS 1476
+#define ER_FOREIGN_SERVER_DOESNT_EXIST 1477
+#define ER_ILLEGAL_HA_CREATE_OPTION 1478
+#define ER_PARTITION_REQUIRES_VALUES_ERROR 1479
+#define ER_PARTITION_WRONG_VALUES_ERROR 1480
+#define ER_PARTITION_MAXVALUE_ERROR 1481
+#define ER_PARTITION_SUBPARTITION_ERROR 1482
+#define ER_PARTITION_SUBPART_MIX_ERROR 1483
+#define ER_PARTITION_WRONG_NO_PART_ERROR 1484
+#define ER_PARTITION_WRONG_NO_SUBPART_ERROR 1485
+#define ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR 1486
+#define ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR 1487
+#define ER_FIELD_NOT_FOUND_PART_ERROR 1488
+#define ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR 1489
+#define ER_INCONSISTENT_PARTITION_INFO_ERROR 1490
+#define ER_PARTITION_FUNC_NOT_ALLOWED_ERROR 1491
+#define ER_PARTITIONS_MUST_BE_DEFINED_ERROR 1492
+#define ER_RANGE_NOT_INCREASING_ERROR 1493
+#define ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR 1494
+#define ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR 1495
+#define ER_PARTITION_ENTRY_ERROR 1496
+#define ER_MIX_HANDLER_ERROR 1497
+#define ER_PARTITION_NOT_DEFINED_ERROR 1498
+#define ER_TOO_MANY_PARTITIONS_ERROR 1499
+#define ER_SUBPARTITION_ERROR 1500
+#define ER_CANT_CREATE_HANDLER_FILE 1501
+#define ER_BLOB_FIELD_IN_PART_FUNC_ERROR 1502
+#define ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF 1503
+#define ER_NO_PARTS_ERROR 1504
+#define ER_PARTITION_MGMT_ON_NONPARTITIONED 1505
+#define ER_FOREIGN_KEY_ON_PARTITIONED 1506
+#define ER_DROP_PARTITION_NON_EXISTENT 1507
+#define ER_DROP_LAST_PARTITION 1508
+#define ER_COALESCE_ONLY_ON_HASH_PARTITION 1509
+#define ER_REORG_HASH_ONLY_ON_SAME_NO 1510
+#define ER_REORG_NO_PARAM_ERROR 1511
+#define ER_ONLY_ON_RANGE_LIST_PARTITION 1512
+#define ER_ADD_PARTITION_SUBPART_ERROR 1513
+#define ER_ADD_PARTITION_NO_NEW_PARTITION 1514
+#define ER_COALESCE_PARTITION_NO_PARTITION 1515
+#define ER_REORG_PARTITION_NOT_EXIST 1516
+#define ER_SAME_NAME_PARTITION 1517
+#define ER_NO_BINLOG_ERROR 1518
+#define ER_CONSECUTIVE_REORG_PARTITIONS 1519
+#define ER_REORG_OUTSIDE_RANGE 1520
+#define ER_PARTITION_FUNCTION_FAILURE 1521
+#define ER_PART_STATE_ERROR 1522
+#define ER_LIMITED_PART_RANGE 1523
+#define ER_PLUGIN_IS_NOT_LOADED 1524
+#define ER_WRONG_VALUE 1525
+#define ER_NO_PARTITION_FOR_GIVEN_VALUE 1526
+#define ER_FILEGROUP_OPTION_ONLY_ONCE 1527
+#define ER_CREATE_FILEGROUP_FAILED 1528
+#define ER_DROP_FILEGROUP_FAILED 1529
+#define ER_TABLESPACE_AUTO_EXTEND_ERROR 1530
+#define ER_WRONG_SIZE_NUMBER 1531
+#define ER_SIZE_OVERFLOW_ERROR 1532
+#define ER_ALTER_FILEGROUP_FAILED 1533
+#define ER_BINLOG_ROW_LOGGING_FAILED 1534
+#define ER_BINLOG_ROW_WRONG_TABLE_DEF 1535
+#define ER_BINLOG_ROW_RBR_TO_SBR 1536
+#define ER_EVENT_ALREADY_EXISTS 1537
+#define ER_EVENT_STORE_FAILED 1538
+#define ER_EVENT_DOES_NOT_EXIST 1539
+#define ER_EVENT_CANT_ALTER 1540
+#define ER_EVENT_DROP_FAILED 1541
+#define ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG 1542
+#define ER_EVENT_ENDS_BEFORE_STARTS 1543
+#define ER_EVENT_EXEC_TIME_IN_THE_PAST 1544
+#define ER_EVENT_OPEN_TABLE_FAILED 1545
+#define ER_EVENT_NEITHER_M_EXPR_NOR_M_AT 1546
+#define ER_UNUSED_2 1547
+#define ER_UNUSED_3 1548
+#define ER_EVENT_CANNOT_DELETE 1549
+#define ER_EVENT_COMPILE_ERROR 1550
+#define ER_EVENT_SAME_NAME 1551
+#define ER_EVENT_DATA_TOO_LONG 1552
+#define ER_DROP_INDEX_FK 1553
+#define ER_WARN_DEPRECATED_SYNTAX_WITH_VER 1554
+#define ER_CANT_WRITE_LOCK_LOG_TABLE 1555
+#define ER_CANT_LOCK_LOG_TABLE 1556
+#define ER_UNUSED_4 1557
+#define ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE 1558
+#define ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR 1559
+#define ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT 1560
+#define ER_UNUSED_13 1561
+#define ER_PARTITION_NO_TEMPORARY 1562
+#define ER_PARTITION_CONST_DOMAIN_ERROR 1563
+#define ER_PARTITION_FUNCTION_IS_NOT_ALLOWED 1564
+#define ER_DDL_LOG_ERROR 1565
+#define ER_NULL_IN_VALUES_LESS_THAN 1566
+#define ER_WRONG_PARTITION_NAME 1567
+#define ER_CANT_CHANGE_TX_CHARACTERISTICS 1568
+#define ER_DUP_ENTRY_AUTOINCREMENT_CASE 1569
+#define ER_EVENT_MODIFY_QUEUE_ERROR 1570
+#define ER_EVENT_SET_VAR_ERROR 1571
+#define ER_PARTITION_MERGE_ERROR 1572
+#define ER_CANT_ACTIVATE_LOG 1573
+#define ER_RBR_NOT_AVAILABLE 1574
+#define ER_BASE64_DECODE_ERROR 1575
+#define ER_EVENT_RECURSION_FORBIDDEN 1576
+#define ER_EVENTS_DB_ERROR 1577
+#define ER_ONLY_INTEGERS_ALLOWED 1578
+#define ER_UNSUPORTED_LOG_ENGINE 1579
+#define ER_BAD_LOG_STATEMENT 1580
+#define ER_CANT_RENAME_LOG_TABLE 1581
+#define ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT 1582
+#define ER_WRONG_PARAMETERS_TO_NATIVE_FCT 1583
+#define ER_WRONG_PARAMETERS_TO_STORED_FCT 1584
+#define ER_NATIVE_FCT_NAME_COLLISION 1585
+#define ER_DUP_ENTRY_WITH_KEY_NAME 1586
+#define ER_BINLOG_PURGE_EMFILE 1587
+#define ER_EVENT_CANNOT_CREATE_IN_THE_PAST 1588
+#define ER_EVENT_CANNOT_ALTER_IN_THE_PAST 1589
+#define ER_SLAVE_INCIDENT 1590
+#define ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT 1591
+#define ER_BINLOG_UNSAFE_STATEMENT 1592
+#define ER_SLAVE_FATAL_ERROR 1593
+#define ER_SLAVE_RELAY_LOG_READ_FAILURE 1594
+#define ER_SLAVE_RELAY_LOG_WRITE_FAILURE 1595
+#define ER_SLAVE_CREATE_EVENT_FAILURE 1596
+#define ER_SLAVE_MASTER_COM_FAILURE 1597
+#define ER_BINLOG_LOGGING_IMPOSSIBLE 1598
+#define ER_VIEW_NO_CREATION_CTX 1599
+#define ER_VIEW_INVALID_CREATION_CTX 1600
+#define ER_SR_INVALID_CREATION_CTX 1601
+#define ER_TRG_CORRUPTED_FILE 1602
+#define ER_TRG_NO_CREATION_CTX 1603
+#define ER_TRG_INVALID_CREATION_CTX 1604
+#define ER_EVENT_INVALID_CREATION_CTX 1605
+#define ER_TRG_CANT_OPEN_TABLE 1606
+#define ER_CANT_CREATE_SROUTINE 1607
+#define ER_UNUSED_11 1608
+#define ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT 1609
+#define ER_SLAVE_CORRUPT_EVENT 1610
+#define ER_LOAD_DATA_INVALID_COLUMN 1611
+#define ER_LOG_PURGE_NO_FILE 1612
+#define ER_XA_RBTIMEOUT 1613
+#define ER_XA_RBDEADLOCK 1614
+#define ER_NEED_REPREPARE 1615
+#define ER_DELAYED_NOT_SUPPORTED 1616
+#define WARN_NO_MASTER_INFO 1617
+#define WARN_OPTION_IGNORED 1618
+#define ER_PLUGIN_DELETE_BUILTIN 1619
+#define WARN_PLUGIN_BUSY 1620
+#define ER_VARIABLE_IS_READONLY 1621
+#define ER_WARN_ENGINE_TRANSACTION_ROLLBACK 1622
+#define ER_SLAVE_HEARTBEAT_FAILURE 1623
+#define ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE 1624
+#define ER_UNUSED_14 1625
+#define ER_CONFLICT_FN_PARSE_ERROR 1626
+#define ER_EXCEPTIONS_WRITE_ERROR 1627
+#define ER_TOO_LONG_TABLE_COMMENT 1628
+#define ER_TOO_LONG_FIELD_COMMENT 1629
+#define ER_FUNC_INEXISTENT_NAME_COLLISION 1630
+#define ER_DATABASE_NAME 1631
+#define ER_TABLE_NAME 1632
+#define ER_PARTITION_NAME 1633
+#define ER_SUBPARTITION_NAME 1634
+#define ER_TEMPORARY_NAME 1635
+#define ER_RENAMED_NAME 1636
+#define ER_TOO_MANY_CONCURRENT_TRXS 1637
+#define WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED 1638
+#define ER_DEBUG_SYNC_TIMEOUT 1639
+#define ER_DEBUG_SYNC_HIT_LIMIT 1640
+#define ER_DUP_SIGNAL_SET 1641
+#define ER_SIGNAL_WARN 1642
+#define ER_SIGNAL_NOT_FOUND 1643
+#define ER_SIGNAL_EXCEPTION 1644
+#define ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER 1645
+#define ER_SIGNAL_BAD_CONDITION_TYPE 1646
+#define WARN_COND_ITEM_TRUNCATED 1647
+#define ER_COND_ITEM_TOO_LONG 1648
+#define ER_UNKNOWN_LOCALE 1649
+#define ER_SLAVE_IGNORE_SERVER_IDS 1650
+#define ER_QUERY_CACHE_DISABLED 1651
+#define ER_SAME_NAME_PARTITION_FIELD 1652
+#define ER_PARTITION_COLUMN_LIST_ERROR 1653
+#define ER_WRONG_TYPE_COLUMN_VALUE_ERROR 1654
+#define ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR 1655
+#define ER_MAXVALUE_IN_VALUES_IN 1656
+#define ER_TOO_MANY_VALUES_ERROR 1657
+#define ER_ROW_SINGLE_PARTITION_FIELD_ERROR 1658
+#define ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD 1659
+#define ER_PARTITION_FIELDS_TOO_LONG 1660
+#define ER_BINLOG_ROW_ENGINE_AND_STMT_ENGINE 1661
+#define ER_BINLOG_ROW_MODE_AND_STMT_ENGINE 1662
+#define ER_BINLOG_UNSAFE_AND_STMT_ENGINE 1663
+#define ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE 1664
+#define ER_BINLOG_STMT_MODE_AND_ROW_ENGINE 1665
+#define ER_BINLOG_ROW_INJECTION_AND_STMT_MODE 1666
+#define ER_BINLOG_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE 1667
+#define ER_BINLOG_UNSAFE_LIMIT 1668
+#define ER_BINLOG_UNSAFE_INSERT_DELAYED 1669
+#define ER_BINLOG_UNSAFE_SYSTEM_TABLE 1670
+#define ER_BINLOG_UNSAFE_AUTOINC_COLUMNS 1671
+#define ER_BINLOG_UNSAFE_UDF 1672
+#define ER_BINLOG_UNSAFE_SYSTEM_VARIABLE 1673
+#define ER_BINLOG_UNSAFE_SYSTEM_FUNCTION 1674
+#define ER_BINLOG_UNSAFE_NONTRANS_AFTER_TRANS 1675
+#define ER_MESSAGE_AND_STATEMENT 1676
+#define ER_SLAVE_CONVERSION_FAILED 1677
+#define ER_SLAVE_CANT_CREATE_CONVERSION 1678
+#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT 1679
+#define ER_PATH_LENGTH 1680
+#define ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT 1681
+#define ER_WRONG_NATIVE_TABLE_STRUCTURE 1682
+#define ER_WRONG_PERFSCHEMA_USAGE 1683
+#define ER_WARN_I_S_SKIPPED_TABLE 1684
+#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT 1685
+#define ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT 1686
+#define ER_SPATIAL_MUST_HAVE_GEOM_COL 1687
+#define ER_TOO_LONG_INDEX_COMMENT 1688
+#define ER_LOCK_ABORTED 1689
+#define ER_DATA_OUT_OF_RANGE 1690
+#define ER_WRONG_SPVAR_TYPE_IN_LIMIT 1691
+#define ER_BINLOG_UNSAFE_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE 1692
+#define ER_BINLOG_UNSAFE_MIXED_STATEMENT 1693
+#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN 1694
+#define ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN 1695
+#define ER_FAILED_READ_FROM_PAR_FILE 1696
+#define ER_VALUES_IS_NOT_INT_TYPE_ERROR 1697
+#define ER_ACCESS_DENIED_NO_PASSWORD_ERROR 1698
+#define ER_SET_PASSWORD_AUTH_PLUGIN 1699
+#define ER_GRANT_PLUGIN_USER_EXISTS 1700
+#define ER_TRUNCATE_ILLEGAL_FK 1701
+#define ER_PLUGIN_IS_PERMANENT 1702
+#define ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MIN 1703
+#define ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX 1704
+#define ER_STMT_CACHE_FULL 1705
+#define ER_MULTI_UPDATE_KEY_CONFLICT 1706
+#define ER_TABLE_NEEDS_REBUILD 1707
+#define WARN_OPTION_BELOW_LIMIT 1708
+#define ER_INDEX_COLUMN_TOO_LONG 1709
+#define ER_ERROR_IN_TRIGGER_BODY 1710
+#define ER_ERROR_IN_UNKNOWN_TRIGGER_BODY 1711
+#define ER_INDEX_CORRUPT 1712
+#define ER_UNDO_RECORD_TOO_BIG 1713
+#define ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT 1714
+#define ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE 1715
+#define ER_BINLOG_UNSAFE_REPLACE_SELECT 1716
+#define ER_BINLOG_UNSAFE_CREATE_IGNORE_SELECT 1717
+#define ER_BINLOG_UNSAFE_CREATE_REPLACE_SELECT 1718
+#define ER_BINLOG_UNSAFE_UPDATE_IGNORE 1719
+#define ER_UNUSED_15 1720
+#define ER_UNUSED_16 1721
+#define ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT 1722
+#define ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC 1723
+#define ER_BINLOG_UNSAFE_INSERT_TWO_KEYS 1724
+#define ER_TABLE_IN_FK_CHECK 1725
+#define ER_UNUSED_1 1726
+#define ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST 1727
+#define ER_CANNOT_LOAD_FROM_TABLE_V2 1728
+#define ER_MASTER_DELAY_VALUE_OUT_OF_RANGE 1729
+#define ER_ONLY_FD_AND_RBR_EVENTS_ALLOWED_IN_BINLOG_STATEMENT 1730
+#define ER_PARTITION_EXCHANGE_DIFFERENT_OPTION 1731
+#define ER_PARTITION_EXCHANGE_PART_TABLE 1732
+#define ER_PARTITION_EXCHANGE_TEMP_TABLE 1733
+#define ER_PARTITION_INSTEAD_OF_SUBPARTITION 1734
+#define ER_UNKNOWN_PARTITION 1735
+#define ER_TABLES_DIFFERENT_METADATA 1736
+#define ER_ROW_DOES_NOT_MATCH_PARTITION 1737
+#define ER_BINLOG_CACHE_SIZE_GREATER_THAN_MAX 1738
+#define ER_WARN_INDEX_NOT_APPLICABLE 1739
+#define ER_PARTITION_EXCHANGE_FOREIGN_KEY 1740
+#define ER_NO_SUCH_KEY_VALUE 1741
+#define ER_VALUE_TOO_LONG 1742
+#define ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE 1743
+#define ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE 1744
+#define ER_BINLOG_STMT_CACHE_SIZE_GREATER_THAN_MAX 1745
+#define ER_CANT_UPDATE_TABLE_IN_CREATE_TABLE_SELECT 1746
+#define ER_PARTITION_CLAUSE_ON_NONPARTITIONED 1747
+#define ER_ROW_DOES_NOT_MATCH_GIVEN_PARTITION_SET 1748
+#define ER_UNUSED_5 1749
+#define ER_CHANGE_RPL_INFO_REPOSITORY_FAILURE 1750
+#define ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_CREATED_TEMP_TABLE 1751
+#define ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_DROPPED_TEMP_TABLE 1752
+#define ER_MTS_FEATURE_IS_NOT_SUPPORTED 1753
+#define ER_MTS_UPDATED_DBS_GREATER_MAX 1754
+#define ER_MTS_CANT_PARALLEL 1755
+#define ER_MTS_INCONSISTENT_DATA 1756
+#define ER_FULLTEXT_NOT_SUPPORTED_WITH_PARTITIONING 1757
+#define ER_DA_INVALID_CONDITION_NUMBER 1758
+#define ER_INSECURE_PLAIN_TEXT 1759
+#define ER_INSECURE_CHANGE_MASTER 1760
+#define ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO 1761
+#define ER_FOREIGN_DUPLICATE_KEY_WITHOUT_CHILD_INFO 1762
+#define ER_SQLTHREAD_WITH_SECURE_SLAVE 1763
+#define ER_TABLE_HAS_NO_FT 1764
+#define ER_VARIABLE_NOT_SETTABLE_IN_SF_OR_TRIGGER 1765
+#define ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION 1766
+#define ER_GTID_NEXT_IS_NOT_IN_GTID_NEXT_LIST 1767
+#define ER_CANT_CHANGE_GTID_NEXT_IN_TRANSACTION_WHEN_GTID_NEXT_LIST_IS_NULL 1768
+#define ER_SET_STATEMENT_CANNOT_INVOKE_FUNCTION 1769
+#define ER_GTID_NEXT_CANT_BE_AUTOMATIC_IF_GTID_NEXT_LIST_IS_NON_NULL 1770
+#define ER_SKIPPING_LOGGED_TRANSACTION 1771
+#define ER_MALFORMED_GTID_SET_SPECIFICATION 1772
+#define ER_MALFORMED_GTID_SET_ENCODING 1773
+#define ER_MALFORMED_GTID_SPECIFICATION 1774
+#define ER_GNO_EXHAUSTED 1775
+#define ER_BAD_SLAVE_AUTO_POSITION 1776
+#define ER_AUTO_POSITION_REQUIRES_GTID_MODE_ON 1777
+#define ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET 1778
+#define ER_GTID_MODE_2_OR_3_REQUIRES_ENFORCE_GTID_CONSISTENCY_ON 1779
+#define ER_GTID_MODE_REQUIRES_BINLOG 1780
+#define ER_CANT_SET_GTID_NEXT_TO_GTID_WHEN_GTID_MODE_IS_OFF 1781
+#define ER_CANT_SET_GTID_NEXT_TO_ANONYMOUS_WHEN_GTID_MODE_IS_ON 1782
+#define ER_CANT_SET_GTID_NEXT_LIST_TO_NON_NULL_WHEN_GTID_MODE_IS_OFF 1783
+#define ER_FOUND_GTID_EVENT_WHEN_GTID_MODE_IS_OFF 1784
+#define ER_GTID_UNSAFE_NON_TRANSACTIONAL_TABLE 1785
+#define ER_GTID_UNSAFE_CREATE_SELECT 1786
+#define ER_GTID_UNSAFE_CREATE_DROP_TEMPORARY_TABLE_IN_TRANSACTION 1787
+#define ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME 1788
+#define ER_MASTER_HAS_PURGED_REQUIRED_GTIDS 1789
+#define ER_CANT_SET_GTID_NEXT_WHEN_OWNING_GTID 1790
+#define ER_UNKNOWN_EXPLAIN_FORMAT 1791
+#define ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION 1792
+#define ER_TOO_LONG_TABLE_PARTITION_COMMENT 1793
+#define ER_SLAVE_CONFIGURATION 1794
+#define ER_INNODB_FT_LIMIT 1795
+#define ER_INNODB_NO_FT_TEMP_TABLE 1796
+#define ER_INNODB_FT_WRONG_DOCID_COLUMN 1797
+#define ER_INNODB_FT_WRONG_DOCID_INDEX 1798
+#define ER_INNODB_ONLINE_LOG_TOO_BIG 1799
+#define ER_UNKNOWN_ALTER_ALGORITHM 1800
+#define ER_UNKNOWN_ALTER_LOCK 1801
+#define ER_MTS_CHANGE_MASTER_CANT_RUN_WITH_GAPS 1802
+#define ER_MTS_RECOVERY_FAILURE 1803
+#define ER_MTS_RESET_WORKERS 1804
+#define ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2 1805
+#define ER_SLAVE_SILENT_RETRY_TRANSACTION 1806
+#define ER_DISCARD_FK_CHECKS_RUNNING 1807
+#define ER_TABLE_SCHEMA_MISMATCH 1808
+#define ER_TABLE_IN_SYSTEM_TABLESPACE 1809
+#define ER_IO_READ_ERROR 1810
+#define ER_IO_WRITE_ERROR 1811
+#define ER_TABLESPACE_MISSING 1812
+#define ER_TABLESPACE_EXISTS 1813
+#define ER_TABLESPACE_DISCARDED 1814
+#define ER_INTERNAL_ERROR 1815
+#define ER_INNODB_IMPORT_ERROR 1816
+#define ER_INNODB_INDEX_CORRUPT 1817
+#define ER_INVALID_YEAR_COLUMN_LENGTH 1818
+#define ER_NOT_VALID_PASSWORD 1819
+#define ER_MUST_CHANGE_PASSWORD 1820
+#define ER_FK_NO_INDEX_CHILD 1821
+#define ER_FK_NO_INDEX_PARENT 1822
+#define ER_FK_FAIL_ADD_SYSTEM 1823
+#define ER_FK_CANNOT_OPEN_PARENT 1824
+#define ER_FK_INCORRECT_OPTION 1825
+#define ER_DUP_CONSTRAINT_NAME 1826
+#define ER_PASSWORD_FORMAT 1827
+#define ER_FK_COLUMN_CANNOT_DROP 1828
+#define ER_FK_COLUMN_CANNOT_DROP_CHILD 1829
+#define ER_FK_COLUMN_NOT_NULL 1830
+#define ER_DUP_INDEX 1831
+#define ER_FK_COLUMN_CANNOT_CHANGE 1832
+#define ER_FK_COLUMN_CANNOT_CHANGE_CHILD 1833
+#define ER_FK_CANNOT_DELETE_PARENT 1834
+#define ER_MALFORMED_PACKET 1835
+#define ER_READ_ONLY_MODE 1836
+#define ER_GTID_NEXT_TYPE_UNDEFINED_GROUP 1837
+#define ER_VARIABLE_NOT_SETTABLE_IN_SP 1838
+#define ER_CANT_SET_GTID_PURGED_WHEN_GTID_MODE_IS_OFF 1839
+#define ER_CANT_SET_GTID_PURGED_WHEN_GTID_EXECUTED_IS_NOT_EMPTY 1840
+#define ER_CANT_SET_GTID_PURGED_WHEN_OWNED_GTIDS_IS_NOT_EMPTY 1841
+#define ER_GTID_PURGED_WAS_CHANGED 1842
+#define ER_GTID_EXECUTED_WAS_CHANGED 1843
+#define ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES 1844
+#define ER_ALTER_OPERATION_NOT_SUPPORTED 1845
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON 1846
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_COPY 1847
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_PARTITION 1848
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_RENAME 1849
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_COLUMN_TYPE 1850
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_CHECK 1851
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_IGNORE 1852
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOPK 1853
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_AUTOINC 1854
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_HIDDEN_FTS 1855
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_CHANGE_FTS 1856
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FTS 1857
+#define ER_SQL_SLAVE_SKIP_COUNTER_NOT_SETTABLE_IN_GTID_MODE 1858
+#define ER_DUP_UNKNOWN_IN_INDEX 1859
+#define ER_IDENT_CAUSES_TOO_LONG_PATH 1860
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL 1861
+#define ER_MUST_CHANGE_PASSWORD_LOGIN 1862
+#define ER_ROW_IN_WRONG_PARTITION 1863
+#define ER_MTS_EVENT_BIGGER_PENDING_JOBS_SIZE_MAX 1864
+#define ER_INNODB_NO_FT_USES_PARSER 1865
+#define ER_BINLOG_LOGICAL_CORRUPTION 1866
+#define ER_WARN_PURGE_LOG_IN_USE 1867
+#define ER_WARN_PURGE_LOG_IS_ACTIVE 1868
+#define ER_AUTO_INCREMENT_CONFLICT 1869
+#define WARN_ON_BLOCKHOLE_IN_RBR 1870
+#define ER_SLAVE_MI_INIT_REPOSITORY 1871
+#define ER_SLAVE_RLI_INIT_REPOSITORY 1872
+#define ER_ACCESS_DENIED_CHANGE_USER_ERROR 1873
+#define ER_INNODB_READ_ONLY 1874
+#define ER_STOP_SLAVE_SQL_THREAD_TIMEOUT 1875
+#define ER_STOP_SLAVE_IO_THREAD_TIMEOUT 1876
+#define ER_TABLE_CORRUPT 1877
+#define ER_TEMP_FILE_WRITE_FAILURE 1878
+#define ER_INNODB_FT_AUX_NOT_HEX_ID 1879
+#define ER_LAST_MYSQL_ERROR_MESSAGE 1880
+#define ER_ERROR_LAST_SECTION_1 1880
+
+/* New section */
+
+#define ER_ERROR_FIRST_SECTION_2 1900
+#define ER_UNUSED_18 1900
+#define ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED 1901
+#define ER_UNUSED_19 1902
+#define ER_PRIMARY_KEY_BASED_ON_GENERATED_COLUMN 1903
+#define ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN 1904
+#define ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN 1905
+#define ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN 1906
+#define ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN 1907
+#define ER_UNUSED_20 1908
+#define ER_UNUSED_21 1909
+#define ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS 1910
+#define ER_UNKNOWN_OPTION 1911
+#define ER_BAD_OPTION_VALUE 1912
+#define ER_UNUSED_6 1913
+#define ER_UNUSED_7 1914
+#define ER_UNUSED_8 1915
+#define ER_DATA_OVERFLOW 1916
+#define ER_DATA_TRUNCATED 1917
+#define ER_BAD_DATA 1918
+#define ER_DYN_COL_WRONG_FORMAT 1919
+#define ER_DYN_COL_IMPLEMENTATION_LIMIT 1920
+#define ER_DYN_COL_DATA 1921
+#define ER_DYN_COL_WRONG_CHARSET 1922
+#define ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES 1923
+#define ER_QUERY_CACHE_IS_DISABLED 1924
+#define ER_QUERY_CACHE_IS_GLOBALY_DISABLED 1925
+#define ER_VIEW_ORDERBY_IGNORED 1926
+#define ER_CONNECTION_KILLED 1927
+#define ER_UNUSED_12 1928
+#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SKIP_REPLICATION 1929
+#define ER_STORED_FUNCTION_PREVENTS_SWITCH_SKIP_REPLICATION 1930
+#define ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT 1931
+#define ER_NO_SUCH_TABLE_IN_ENGINE 1932
+#define ER_TARGET_NOT_EXPLAINABLE 1933
+#define ER_CONNECTION_ALREADY_EXISTS 1934
+#define ER_MASTER_LOG_PREFIX 1935
+#define ER_CANT_START_STOP_SLAVE 1936
+#define ER_SLAVE_STARTED 1937
+#define ER_SLAVE_STOPPED 1938
+#define ER_SQL_DISCOVER_ERROR 1939
+#define ER_FAILED_GTID_STATE_INIT 1940
+#define ER_INCORRECT_GTID_STATE 1941
+#define ER_CANNOT_UPDATE_GTID_STATE 1942
+#define ER_DUPLICATE_GTID_DOMAIN 1943
+#define ER_GTID_OPEN_TABLE_FAILED 1944
+#define ER_GTID_POSITION_NOT_FOUND_IN_BINLOG 1945
+#define ER_CANNOT_LOAD_SLAVE_GTID_STATE 1946
+#define ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG 1947
+#define ER_MASTER_GTID_POS_MISSING_DOMAIN 1948
+#define ER_UNTIL_REQUIRES_USING_GTID 1949
+#define ER_GTID_STRICT_OUT_OF_ORDER 1950
+#define ER_GTID_START_FROM_BINLOG_HOLE 1951
+#define ER_SLAVE_UNEXPECTED_MASTER_SWITCH 1952
+#define ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO 1953
+#define ER_STORED_FUNCTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO 1954
+#define ER_GTID_POSITION_NOT_FOUND_IN_BINLOG2 1955
+#define ER_BINLOG_MUST_BE_EMPTY 1956
+#define ER_NO_SUCH_QUERY 1957
+#define ER_BAD_BASE64_DATA 1958
+#define ER_INVALID_ROLE 1959
+#define ER_INVALID_CURRENT_USER 1960
+#define ER_CANNOT_GRANT_ROLE 1961
+#define ER_CANNOT_REVOKE_ROLE 1962
+#define ER_CHANGE_SLAVE_PARALLEL_THREADS_ACTIVE 1963
+#define ER_PRIOR_COMMIT_FAILED 1964
+#define ER_IT_IS_A_VIEW 1965
+#define ER_SLAVE_SKIP_NOT_IN_GTID 1966
+#define ER_TABLE_DEFINITION_TOO_BIG 1967
+#define ER_PLUGIN_INSTALLED 1968
+#define ER_STATEMENT_TIMEOUT 1969
+#define ER_SUBQUERIES_NOT_SUPPORTED 1970
+#define ER_SET_STATEMENT_NOT_SUPPORTED 1971
+#define ER_UNUSED_17 1972
+#define ER_USER_CREATE_EXISTS 1973
+#define ER_USER_DROP_EXISTS 1974
+#define ER_ROLE_CREATE_EXISTS 1975
+#define ER_ROLE_DROP_EXISTS 1976
+#define ER_CANNOT_CONVERT_CHARACTER 1977
+#define ER_INVALID_DEFAULT_VALUE_FOR_FIELD 1978
+#define ER_KILL_QUERY_DENIED_ERROR 1979
+#define ER_NO_EIS_FOR_FIELD 1980
+#define ER_WARN_AGGFUNC_DEPENDENCE 1981
+#define ER_ERROR_LAST_SECTION_2 1981
+
+/* New section */
+
+#define ER_ERROR_FIRST_SECTION_3 2000
+#define ER_ERROR_LAST_SECTION_3 2000
+
+/* New section */
+
+#define ER_ERROR_FIRST_SECTION_4 3000
+#define ER_FILE_CORRUPT 3000
+#define ER_ERROR_ON_MASTER 3001
+#define ER_INCONSISTENT_ERROR 3002
+#define ER_STORAGE_ENGINE_NOT_LOADED 3003
+#define ER_GET_STACKED_DA_WITHOUT_ACTIVE_HANDLER 3004
+#define ER_WARN_LEGACY_SYNTAX_CONVERTED 3005
+#define ER_BINLOG_UNSAFE_FULLTEXT_PLUGIN 3006
+#define ER_CANNOT_DISCARD_TEMPORARY_TABLE 3007
+#define ER_FK_DEPTH_EXCEEDED 3008
+#define ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE_V2 3009
+#define ER_WARN_TRIGGER_DOESNT_HAVE_CREATED 3010
+#define ER_REFERENCED_TRG_DOES_NOT_EXIST_MYSQL 3011
+#define ER_EXPLAIN_NOT_SUPPORTED 3012
+#define ER_INVALID_FIELD_SIZE 3013
+#define ER_MISSING_HA_CREATE_OPTION 3014
+#define ER_ENGINE_OUT_OF_MEMORY 3015
+#define ER_PASSWORD_EXPIRE_ANONYMOUS_USER 3016
+#define ER_SLAVE_SQL_THREAD_MUST_STOP 3017
+#define ER_NO_FT_MATERIALIZED_SUBQUERY 3018
+#define ER_INNODB_UNDO_LOG_FULL 3019
+#define ER_INVALID_ARGUMENT_FOR_LOGARITHM 3020
+#define ER_SLAVE_CHANNEL_IO_THREAD_MUST_STOP 3021
+#define ER_WARN_OPEN_TEMP_TABLES_MUST_BE_ZERO 3022
+#define ER_WARN_ONLY_MASTER_LOG_FILE_NO_POS 3023
+#define ER_QUERY_TIMEOUT 3024
+#define ER_NON_RO_SELECT_DISABLE_TIMER 3025
+#define ER_DUP_LIST_ENTRY 3026
+#define ER_SQL_MODE_NO_EFFECT 3027
+#define ER_AGGREGATE_ORDER_FOR_UNION 3028
+#define ER_AGGREGATE_ORDER_NON_AGG_QUERY 3029
+#define ER_SLAVE_WORKER_STOPPED_PREVIOUS_THD_ERROR 3030
+#define ER_DONT_SUPPORT_SLAVE_PRESERVE_COMMIT_ORDER 3031
+#define ER_SERVER_OFFLINE_MODE 3032
+#define ER_GIS_DIFFERENT_SRIDS 3033
+#define ER_GIS_UNSUPPORTED_ARGUMENT 3034
+#define ER_GIS_UNKNOWN_ERROR 3035
+#define ER_GIS_UNKNOWN_EXCEPTION 3036
+#define ER_GIS_INVALID_DATA 3037
+#define ER_BOOST_GEOMETRY_EMPTY_INPUT_EXCEPTION 3038
+#define ER_BOOST_GEOMETRY_CENTROID_EXCEPTION 3039
+#define ER_BOOST_GEOMETRY_OVERLAY_INVALID_INPUT_EXCEPTION 3040
+#define ER_BOOST_GEOMETRY_TURN_INFO_EXCEPTION 3041
+#define ER_BOOST_GEOMETRY_SELF_INTERSECTION_POINT_EXCEPTION 3042
+#define ER_BOOST_GEOMETRY_UNKNOWN_EXCEPTION 3043
+#define ER_STD_BAD_ALLOC_ERROR 3044
+#define ER_STD_DOMAIN_ERROR 3045
+#define ER_STD_LENGTH_ERROR 3046
+#define ER_STD_INVALID_ARGUMENT 3047
+#define ER_STD_OUT_OF_RANGE_ERROR 3048
+#define ER_STD_OVERFLOW_ERROR 3049
+#define ER_STD_RANGE_ERROR 3050
+#define ER_STD_UNDERFLOW_ERROR 3051
+#define ER_STD_LOGIC_ERROR 3052
+#define ER_STD_RUNTIME_ERROR 3053
+#define ER_STD_UNKNOWN_EXCEPTION 3054
+#define ER_GIS_DATA_WRONG_ENDIANESS 3055
+#define ER_CHANGE_MASTER_PASSWORD_LENGTH 3056
+#define ER_USER_LOCK_WRONG_NAME 3057
+#define ER_USER_LOCK_DEADLOCK 3058
+#define ER_REPLACE_INACCESSIBLE_ROWS 3059
+#define ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS 3060
+#define ER_ERROR_LAST_SECTION_4 3060
+
+/* New section */
+
+#define ER_ERROR_FIRST_SECTION_5 4000
+#define ER_COMMULTI_BADCONTEXT 4000
+#define ER_BAD_COMMAND_IN_MULTI 4001
+#define ER_WITH_COL_WRONG_LIST 4002
+#define ER_TOO_MANY_DEFINITIONS_IN_WITH_CLAUSE 4003
+#define ER_DUP_QUERY_NAME 4004
+#define ER_RECURSIVE_WITHOUT_ANCHORS 4005
+#define ER_UNACCEPTABLE_MUTUAL_RECURSION 4006
+#define ER_REF_TO_RECURSIVE_WITH_TABLE_IN_DERIVED 4007
+#define ER_NOT_STANDARD_COMPLIANT_RECURSIVE 4008
+#define ER_WRONG_WINDOW_SPEC_NAME 4009
+#define ER_DUP_WINDOW_NAME 4010
+#define ER_PARTITION_LIST_IN_REFERENCING_WINDOW_SPEC 4011
+#define ER_ORDER_LIST_IN_REFERENCING_WINDOW_SPEC 4012
+#define ER_WINDOW_FRAME_IN_REFERENCED_WINDOW_SPEC 4013
+#define ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS 4014
+#define ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION 4015
+#define ER_WINDOW_FUNCTION_IN_WINDOW_SPEC 4016
+#define ER_NOT_ALLOWED_WINDOW_FRAME 4017
+#define ER_NO_ORDER_LIST_IN_WINDOW_SPEC 4018
+#define ER_RANGE_FRAME_NEEDS_SIMPLE_ORDERBY 4019
+#define ER_WRONG_TYPE_FOR_ROWS_FRAME 4020
+#define ER_WRONG_TYPE_FOR_RANGE_FRAME 4021
+#define ER_FRAME_EXCLUSION_NOT_SUPPORTED 4022
+#define ER_WINDOW_FUNCTION_DONT_HAVE_FRAME 4023
+#define ER_INVALID_NTILE_ARGUMENT 4024
+#define ER_CONSTRAINT_FAILED 4025
+#define ER_EXPRESSION_IS_TOO_BIG 4026
+#define ER_ERROR_EVALUATING_EXPRESSION 4027
+#define ER_CALCULATING_DEFAULT_VALUE 4028
+#define ER_EXPRESSION_REFERS_TO_UNINIT_FIELD 4029
+#define ER_PARTITION_DEFAULT_ERROR 4030
+#define ER_REFERENCED_TRG_DOES_NOT_EXIST 4031
+#define ER_INVALID_DEFAULT_PARAM 4032
+#define ER_BINLOG_NON_SUPPORTED_BULK 4033
+#define ER_BINLOG_UNCOMPRESS_ERROR 4034
+#define ER_JSON_BAD_CHR 4035
+#define ER_JSON_NOT_JSON_CHR 4036
+#define ER_JSON_EOS 4037
+#define ER_JSON_SYNTAX 4038
+#define ER_JSON_ESCAPING 4039
+#define ER_JSON_DEPTH 4040
+#define ER_JSON_PATH_EOS 4041
+#define ER_JSON_PATH_SYNTAX 4042
+#define ER_JSON_PATH_DEPTH 4043
+#define ER_JSON_PATH_NO_WILDCARD 4044
+#define ER_JSON_PATH_ARRAY 4045
+#define ER_JSON_ONE_OR_ALL 4046
+#define ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE 4047
+#define ER_GEOJSON_INCORRECT 4048
+#define ER_GEOJSON_TOO_FEW_POINTS 4049
+#define ER_GEOJSON_NOT_CLOSED 4050
+#define ER_JSON_PATH_EMPTY 4051
+#define ER_SLAVE_SAME_ID 4052
+#define ER_FLASHBACK_NOT_SUPPORTED 4053
+#define ER_KEYS_OUT_OF_ORDER 4054
+#define ER_OVERLAPPING_KEYS 4055
+#define ER_REQUIRE_ROW_BINLOG_FORMAT 4056
+#define ER_ISOLATION_MODE_NOT_SUPPORTED 4057
+#define ER_ON_DUPLICATE_DISABLED 4058
+#define ER_UPDATES_WITH_CONSISTENT_SNAPSHOT 4059
+#define ER_ROLLBACK_ONLY 4060
+#define ER_ROLLBACK_TO_SAVEPOINT 4061
+#define ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT 4062
+#define ER_UNSUPPORTED_COLLATION 4063
+#define ER_METADATA_INCONSISTENCY 4064
+#define ER_KEY_CREATE_DURING_ALTER 4065
+#define ER_SK_POPULATE_DURING_ALTER 4066
+#define ER_CF_DIFFERENT 4067
+#define ER_RDB_STATUS_GENERAL 4068
+#define ER_RDB_STATUS_MSG 4069
+#define ER_NET_OK_PACKET_TOO_LARGE 4070
+#define ER_RDB_TTL_UNSUPPORTED 4071
+#define ER_RDB_TTL_COL_FORMAT 4072
+#define ER_RDB_TTL_DURATION_FORMAT 4073
+#define ER_PER_INDEX_CF_DEPRECATED 4074
+#define ER_ERROR_LAST 4074
diff --git a/3rdparty/mariadb/include/plugin_auth.h b/3rdparty/mariadb/include/plugin_auth.h
new file mode 100644
index 000000000..2be64a6b3
--- /dev/null
+++ b/3rdparty/mariadb/include/plugin_auth.h
@@ -0,0 +1,107 @@
+#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
+/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02111-1301, USA */
+
+/**
+  @file
+
+  This file defines constants and data structures that are the same for
+  both client- and server-side authentication plugins.
+*/
+#define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
+
+/** the max allowed length for a user name */
+#define MYSQL_USERNAME_LENGTH 512
+
+/**
+  return values of the plugin authenticate_user() method.
+*/
+
+/**
+  Authentication failed. Additionally, all other CR_xxx values
+  (libmariadb error code) can be used too.
+
+  The client plugin may set the error code and the error message directly
+  in the MYSQL structure and return CR_ERROR. If a CR_xxx specific error
+  code was returned, an error message in the MYSQL structure will be
+  overwritten. If CR_ERROR is returned without setting the error in MYSQL,
+  CR_UNKNOWN_ERROR will be user.
+*/
+#define CR_ERROR 0
+/**
+  Authentication (client part) was successful. It does not mean that the
+  authentication as a whole was successful, usually it only means
+  that the client was able to send the user name and the password to the
+  server. If CR_OK is returned, the libmariadb reads the next packet expecting
+  it to be one of OK, ERROR, or CHANGE_PLUGIN packets.
+*/
+#define CR_OK -1
+/**
+  Authentication was successful.
+  It means that the client has done its part successfully and also that
+  a plugin has read the last packet (one of OK, ERROR, CHANGE_PLUGIN).
+  In this case, libmariadb will not read a packet from the server,
+  but it will use the data at mysql->net.read_pos.
+
+  A plugin may return this value if the number of roundtrips in the
+  authentication protocol is not known in advance, and the client plugin
+  needs to read one packet more to determine if the authentication is finished
+  or not.
+*/
+#define CR_OK_HANDSHAKE_COMPLETE -2
+
+typedef struct st_plugin_vio_info
+{
+  enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
+         MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol;
+  int socket;     /**< it's set, if the protocol is SOCKET or TCP */
+#ifdef _WIN32
+  HANDLE handle;  /**< it's set, if the protocol is PIPE or MEMORY */
+#endif
+} MYSQL_PLUGIN_VIO_INFO;
+
+/**
+  Provides plugin access to communication channel
+*/
+typedef struct st_plugin_vio
+{
+  /**
+    Plugin provides a pointer reference and this function sets it to the
+    contents of any incoming packet. Returns the packet length, or -1 if
+    the plugin should terminate.
+  */
+  int (*read_packet)(struct st_plugin_vio *vio, 
+                     unsigned char **buf);
+  
+  /**
+    Plugin provides a buffer with data and the length and this
+    function sends it as a packet. Returns 0 on success, 1 on failure.
+  */
+  int (*write_packet)(struct st_plugin_vio *vio, 
+                      const unsigned char *packet, 
+                      int packet_len);
+
+  /**
+    Fills in a st_plugin_vio_info structure, providing the information
+    about the connection.
+  */
+  void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
+
+} MYSQL_PLUGIN_VIO;
+
+#endif
+
diff --git a/3rdparty/mariadb/include/plugin_auth_common.h b/3rdparty/mariadb/include/plugin_auth_common.h
new file mode 100644
index 000000000..ee4b8b9ce
--- /dev/null
+++ b/3rdparty/mariadb/include/plugin_auth_common.h
@@ -0,0 +1,110 @@
+/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02111-1301, USA */
+
+
+#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
+/**
+  @file
+
+  This file defines constants and data structures that are the same for
+  both client- and server-side authentication plugins.
+*/
+#define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
+
+/** the max allowed length for a user name */
+#define MYSQL_USERNAME_LENGTH 512
+
+/**
+  return values of the plugin authenticate_user() method.
+*/
+
+/**
+  Authentication failed. Additionally, all other CR_xxx values
+  (libmariadb error code) can be used too.
+
+  The client plugin may set the error code and the error message directly
+  in the MYSQL structure and return CR_ERROR. If a CR_xxx specific error
+  code was returned, an error message in the MYSQL structure will be
+  overwritten. If CR_ERROR is returned without setting the error in MYSQL,
+  CR_UNKNOWN_ERROR will be user.
+*/
+#define CR_ERROR 0
+/**
+  Authentication (client part) was successful. It does not mean that the
+  authentication as a whole was successful, usually it only means
+  that the client was able to send the user name and the password to the
+  server. If CR_OK is returned, the libmariadb reads the next packet expecting
+  it to be one of OK, ERROR, or CHANGE_PLUGIN packets.
+*/
+#define CR_OK -1
+/**
+  Authentication was successful.
+  It means that the client has done its part successfully and also that
+  a plugin has read the last packet (one of OK, ERROR, CHANGE_PLUGIN).
+  In this case, libmariadb will not read a packet from the server,
+  but it will use the data at mysql->net.read_pos.
+
+  A plugin may return this value if the number of roundtrips in the
+  authentication protocol is not known in advance, and the client plugin
+  needs to read one packet more to determine if the authentication is finished
+  or not.
+*/
+#define CR_OK_HANDSHAKE_COMPLETE -2
+
+typedef struct st_plugin_vio_info
+{
+  enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
+         MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol;
+#ifndef _WIN32
+  int socket;     /**< it's set, if the protocol is SOCKET or TCP */
+#else
+  SOCKET socket;     /**< it's set, if the protocol is SOCKET or TCP */
+  HANDLE handle;  /**< it's set, if the protocol is PIPE or MEMORY */
+#endif
+} MYSQL_PLUGIN_VIO_INFO;
+
+/**
+  Provides plugin access to communication channel
+*/
+typedef struct st_plugin_vio
+{
+  /**
+    Plugin provides a pointer reference and this function sets it to the
+    contents of any incoming packet. Returns the packet length, or -1 if
+    the plugin should terminate.
+  */
+  int (*read_packet)(struct st_plugin_vio *vio, 
+                     unsigned char **buf);
+  
+  /**
+    Plugin provides a buffer with data and the length and this
+    function sends it as a packet. Returns 0 on success, 1 on failure.
+  */
+  int (*write_packet)(struct st_plugin_vio *vio, 
+                      const unsigned char *packet, 
+                      int packet_len);
+
+  /**
+    Fills in a st_plugin_vio_info structure, providing the information
+    about the connection.
+  */
+  void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
+
+} MYSQL_PLUGIN_VIO;
+
+#endif
+
diff --git a/3rdparty/mariadb/lib/libmariadb.lib b/3rdparty/mariadb/lib/libmariadb.lib
new file mode 100644
index 000000000..5a2a616ed
Binary files /dev/null and b/3rdparty/mariadb/lib/libmariadb.lib differ
diff --git a/3rdparty/mariadb/lib/plugin/auth_gssapi_client.dll b/3rdparty/mariadb/lib/plugin/auth_gssapi_client.dll
new file mode 100644
index 000000000..049a5ac0f
Binary files /dev/null and b/3rdparty/mariadb/lib/plugin/auth_gssapi_client.dll differ
diff --git a/3rdparty/mariadb/lib/plugin/caching_sha2_password.dll b/3rdparty/mariadb/lib/plugin/caching_sha2_password.dll
new file mode 100644
index 000000000..882032a41
Binary files /dev/null and b/3rdparty/mariadb/lib/plugin/caching_sha2_password.dll differ
diff --git a/3rdparty/mariadb/lib/plugin/client_ed25519.dll b/3rdparty/mariadb/lib/plugin/client_ed25519.dll
new file mode 100644
index 000000000..d5fe5dbe1
Binary files /dev/null and b/3rdparty/mariadb/lib/plugin/client_ed25519.dll differ
diff --git a/3rdparty/mariadb/lib/plugin/dialog.dll b/3rdparty/mariadb/lib/plugin/dialog.dll
new file mode 100644
index 000000000..7d31042cc
Binary files /dev/null and b/3rdparty/mariadb/lib/plugin/dialog.dll differ
diff --git a/3rdparty/mariadb/lib/plugin/mysql_clear_password.dll b/3rdparty/mariadb/lib/plugin/mysql_clear_password.dll
new file mode 100644
index 000000000..252a1cff6
Binary files /dev/null and b/3rdparty/mariadb/lib/plugin/mysql_clear_password.dll differ
diff --git a/3rdparty/mariadb/lib/plugin/pvio_npipe.dll b/3rdparty/mariadb/lib/plugin/pvio_npipe.dll
new file mode 100644
index 000000000..9d5a7a538
Binary files /dev/null and b/3rdparty/mariadb/lib/plugin/pvio_npipe.dll differ
diff --git a/3rdparty/mariadb/lib/plugin/pvio_shmem.dll b/3rdparty/mariadb/lib/plugin/pvio_shmem.dll
new file mode 100644
index 000000000..0548ac096
Binary files /dev/null and b/3rdparty/mariadb/lib/plugin/pvio_shmem.dll differ
diff --git a/3rdparty/mariadb/lib/plugin/sha256_password.dll b/3rdparty/mariadb/lib/plugin/sha256_password.dll
new file mode 100644
index 000000000..ce7940e9a
Binary files /dev/null and b/3rdparty/mariadb/lib/plugin/sha256_password.dll differ
diff --git a/3rdparty/mysql/include/config-win.h b/3rdparty/mysql/include/config-win.h
deleted file mode 100644
index b2e1c9831..000000000
--- a/3rdparty/mysql/include/config-win.h
+++ /dev/null
@@ -1,470 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/* Defines for Win32 to make it compatible for MySQL */
-
-#ifdef __WIN2000__
-/* We have to do this define before including windows.h to get the AWE API
-functions */
-#define _WIN32_WINNT     0x0500
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-/* Avoid endless warnings about sprintf() etc. being unsafe. */
-#define _CRT_SECURE_NO_DEPRECATE 1
-#endif
-
-#include <sys/locking.h>
-#include <windows.h>
-#include <math.h>			/* Because of rint() */
-#include <fcntl.h>
-#include <io.h>
-#include <malloc.h>
-
-#define HAVE_SMEM 1
-
-#if defined(_WIN64) || defined(WIN64) 
-#define SYSTEM_TYPE	"Win64" 
-#elif defined(_WIN32) || defined(WIN32) 
-#define SYSTEM_TYPE	"Win32" 
-#else
-#define SYSTEM_TYPE	"Windows"
-#endif
-
-#if defined(_M_IA64) 
-#define MACHINE_TYPE	"ia64" 
-#elif defined(_M_IX86) 
-#define MACHINE_TYPE	"ia32" 
-#elif defined(_M_ALPHA) 
-#define MACHINE_TYPE	"axp" 
-#else
-#define MACHINE_TYPE	"unknown"	/* Define to machine type name */
-#endif 
- 
-#if !(defined(_WIN64) || defined(WIN64)) 
-#ifndef _WIN32
-#define _WIN32				/* Compatible with old source */
-#endif
-#ifndef __WIN32__
-#define __WIN32__
-#endif
-#endif /* _WIN64 */
-#ifndef __WIN__
-#define __WIN__			      /* To make it easier in VC++ */
-#endif
-
-#ifndef MAX_INDEXES
-#define MAX_INDEXES 64
-#endif
-
-/* File and lock constants */
-#define O_SHARE		0x1000		/* Open file in sharing mode */
-#ifdef __BORLANDC__
-#define F_RDLCK		LK_NBLCK	/* read lock */
-#define F_WRLCK		LK_NBRLCK	/* write lock */
-#define F_UNLCK		LK_UNLCK	/* remove lock(s) */
-#else
-#define F_RDLCK		_LK_NBLCK	/* read lock */
-#define F_WRLCK		_LK_NBRLCK	/* write lock */
-#define F_UNLCK		_LK_UNLCK	/* remove lock(s) */
-#endif
-
-#define F_EXCLUSIVE	1		/* We have only exclusive locking */
-#define F_TO_EOF	(INT_MAX32/2)	/* size for lock of all file */
-#define F_OK		0		/* parameter to access() */
-#define W_OK		2
-
-#define S_IROTH		S_IREAD		/* for my_lib */
-
-#ifdef __BORLANDC__
-#define FILE_BINARY	O_BINARY	/* my_fopen in binary mode */
-#define O_TEMPORARY	0
-#define O_SHORT_LIVED	0
-#define SH_DENYNO	_SH_DENYNO
-#else
-#define O_BINARY	_O_BINARY	/* compability with MSDOS */
-#define FILE_BINARY	_O_BINARY	/* my_fopen in binary mode */
-#define O_TEMPORARY	_O_TEMPORARY
-#define O_SHORT_LIVED	_O_SHORT_LIVED
-#define SH_DENYNO	_SH_DENYNO
-#endif
-#define NO_OPEN_3			/* For my_create() */
-
-#define SIGQUIT		SIGTERM		/* No SIGQUIT */
-
-#undef _REENTRANT			/* Crashes something for win32 */
-#undef SAFE_MUTEX			/* Can't be used on windows */
-
-#if defined(_MSC_VER) && _MSC_VER >= 1310
-#define LL(A)           A##ll
-#define ULL(A)          A##ull
-#else
-#define LL(A)           ((__int64) A)
-#define ULL(A)          ((unsigned __int64) A)
-#endif
-
-#define LONGLONG_MIN	LL(0x8000000000000000)
-#define LONGLONG_MAX	LL(0x7FFFFFFFFFFFFFFF)
-#define ULONGLONG_MAX	ULL(0xFFFFFFFFFFFFFFFF)
-
-/* Type information */
-
-#if defined(__EMX__) || !defined(HAVE_UINT)
-#undef HAVE_UINT
-#define HAVE_UINT
-typedef unsigned short	ushort;
-typedef unsigned int	uint;
-#endif /* defined(__EMX__) || !defined(HAVE_UINT) */
-
-typedef unsigned __int64 ulonglong;	/* Microsofts 64 bit types */
-typedef __int64 longlong;
-#ifndef HAVE_SIGSET_T
-typedef int sigset_t;
-#endif
-#define longlong_defined
-/*
-  off_t should not be __int64 because of conflicts in header files;
-  Use my_off_t or os_off_t instead
-*/
-#ifndef HAVE_OFF_T
-typedef long off_t;
-#endif
-typedef __int64 os_off_t;
-#ifdef _WIN64
-typedef UINT_PTR rf_SetTimer;
-#else
-#ifndef HAVE_SIZE_T
-typedef unsigned int size_t;
-#endif
-typedef uint rf_SetTimer;
-#endif
-
-#define Socket_defined
-#define my_socket SOCKET
-#define bool BOOL
-#define SIGPIPE SIGINT
-#define RETQSORTTYPE void
-#define QSORT_TYPE_IS_VOID
-#define RETSIGTYPE void
-#define SOCKET_SIZE_TYPE int
-#define my_socket_defined
-#define bool_defined
-#define byte_defined
-#define HUGE_PTR
-#define STDCALL __stdcall	    /* Used by libmysql.dll */
-#define isnan(X) _isnan(X)
-#define finite(X) _finite(X)
-
-#ifndef UNDEF_THREAD_HACK
-#define THREAD
-#endif
-#define VOID_SIGHANDLER
-#define SIZEOF_CHAR		1
-#define SIZEOF_LONG		4
-#define SIZEOF_LONG_LONG	8
-#define SIZEOF_OFF_T		8
-#ifdef _WIN64
-#define SIZEOF_CHARP		8
-#else
-#define SIZEOF_CHARP		4
-#endif
-#define HAVE_BROKEN_NETINET_INCLUDES
-#ifdef __NT__
-#define HAVE_NAMED_PIPE			/* We can only create pipes on NT */
-#endif
-
-/* ERROR is defined in wingdi.h */
-#undef ERROR
-
-/* We need to close files to break connections on shutdown */
-#ifndef SIGNAL_WITH_VIO_CLOSE
-#define SIGNAL_WITH_VIO_CLOSE
-#endif
-
-/* Use all character sets in MySQL */
-#define USE_MB 1
-#define USE_MB_IDENT 1
-#define USE_STRCOLL 1
-
-/* All windows servers should support .sym files */
-#undef USE_SYMDIR
-#define USE_SYMDIR
-
-/* If LOAD DATA LOCAL INFILE should be enabled by default */
-#define ENABLED_LOCAL_INFILE 1
-
-/* Convert some simple functions to Posix */
-
-#define my_sigset(A,B) signal((A),(B))
-#define finite(A) _finite(A)
-#define sleep(A)  Sleep((A)*1000)
-#define popen(A,B) _popen((A),(B))
-#define pclose(A) _pclose(A)
-
-#ifndef __BORLANDC__
-#define access(A,B) _access(A,B)
-#endif
-
-#if !defined(__cplusplus)
-#define inline __inline
-#endif /* __cplusplus */
-
-inline double rint(double nr)
-{
-  double f = floor(nr);
-  double c = ceil(nr);
-  return (((c-nr) >= (nr-f)) ? f :c);
-}
-
-#ifdef _WIN64
-#define ulonglong2double(A) ((double) (ulonglong) (A))
-#define my_off_t2double(A)  ((double) (my_off_t) (A))
-
-#else
-inline double ulonglong2double(ulonglong value)
-{
-  longlong nr=(longlong) value;
-  if (nr >= 0)
-    return (double) nr;
-  return (18446744073709551616.0 + (double) nr);
-}
-#define my_off_t2double(A) ulonglong2double(A)
-#endif /* _WIN64 */
-
-#if SIZEOF_OFF_T > 4
-#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
-#define tell(A) _telli64(A)
-#endif
-
-#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; }
-
-#define STACK_DIRECTION -1
-
-/* Optimized store functions for Intel x86 */
-
-#ifndef _WIN64
-#define sint2korr(A)	(*((int16 *) (A)))
-#define sint3korr(A)	((int32) ((((uchar) (A)[2]) & 128) ? \
-				  (((uint32) 255L << 24) | \
-				   (((uint32) (uchar) (A)[2]) << 16) |\
-				   (((uint32) (uchar) (A)[1]) << 8) | \
-				   ((uint32) (uchar) (A)[0])) : \
-				  (((uint32) (uchar) (A)[2]) << 16) |\
-				  (((uint32) (uchar) (A)[1]) << 8) | \
-				  ((uint32) (uchar) (A)[0])))
-#define sint4korr(A)	(*((long *) (A)))
-#define uint2korr(A)	(*((uint16 *) (A)))
-/*
-   ATTENTION !
-   
-    Please, note, uint3korr reads 4 bytes (not 3) !
-    It means, that you have to provide enough allocated space !
-*/
-#define uint3korr(A)	(long) (*((unsigned int *) (A)) & 0xFFFFFF)
-#define uint4korr(A)	(*((unsigned long *) (A)))
-#define uint5korr(A)	((ulonglong)(((uint32) ((uchar) (A)[0])) +\
-				    (((uint32) ((uchar) (A)[1])) << 8) +\
-				    (((uint32) ((uchar) (A)[2])) << 16) +\
-				    (((uint32) ((uchar) (A)[3])) << 24)) +\
-				    (((ulonglong) ((uchar) (A)[4])) << 32))
-#define uint8korr(A)	(*((ulonglong *) (A)))
-#define sint8korr(A)	(*((longlong *) (A)))
-#define int2store(T,A)	*((uint16*) (T))= (uint16) (A)
-#define int3store(T,A)		{ *(T)=  (uchar) ((A));\
-				  *(T+1)=(uchar) (((uint) (A) >> 8));\
-				  *(T+2)=(uchar) (((A) >> 16)); }
-#define int4store(T,A)	*((long *) (T))= (long) (A)
-#define int5store(T,A)	{ *(T)= (uchar)((A));\
-			  *((T)+1)=(uchar) (((A) >> 8));\
-			  *((T)+2)=(uchar) (((A) >> 16));\
-			  *((T)+3)=(uchar) (((A) >> 24)); \
-			  *((T)+4)=(uchar) (((A) >> 32)); }
-#define int8store(T,A)	*((ulonglong *) (T))= (ulonglong) (A)
-
-#define doubleget(V,M)	do { *((long *) &V) = *((long*) M); \
-			    *(((long *) &V)+1) = *(((long*) M)+1); } while(0)
-#define doublestore(T,V) do { *((long *) T) = *((long*) &V); \
-			      *(((long *) T)+1) = *(((long*) &V)+1); } while(0)
-#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
-#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float))
-#define floatget(V,M)   memcpy((byte*)(&V), (byte*)(M), sizeof(float))
-#define float8get(V,M) doubleget((V),(M))
-#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
-#define float8store(V,M) doublestore((V),(M))
-#endif /* _WIN64 */
-
-#define HAVE_PERROR
-#define HAVE_VFPRINT
-#define HAVE_RENAME		/* Have rename() as function */
-#define HAVE_BINARY_STREAMS	/* Have "b" flag in streams */
-#define HAVE_LONG_JMP		/* Have long jump function */
-#define HAVE_LOCKING		/* have locking() call */
-#define HAVE_ERRNO_AS_DEFINE	/* errno is a define */
-#define HAVE_STDLIB		/* everything is include in this file */
-#define HAVE_MEMCPY
-#define HAVE_MEMMOVE
-#define HAVE_GETCWD
-#define HAVE_TELL
-#define HAVE_TZNAME
-#define HAVE_PUTENV
-#define HAVE_SELECT
-#define HAVE_SETLOCALE
-#define HAVE_SOCKET		/* Giangi */
-#define HAVE_FLOAT_H
-#define HAVE_LIMITS_H
-#define HAVE_STDDEF_H
-#define HAVE_RINT		/* defined in this file */
-#define NO_FCNTL_NONBLOCK	/* No FCNTL */
-#define HAVE_ALLOCA
-#define HAVE_STRPBRK
-#define HAVE_STRSTR
-#define HAVE_COMPRESS
-#define HAVE_CREATESEMAPHORE
-#define HAVE_ISNAN
-#define HAVE_FINITE
-#define HAVE_QUERY_CACHE
-#define SPRINTF_RETURNS_INT
-#define HAVE_SETFILEPOINTER
-#define HAVE_VIO_READ_BUFF
-#define HAVE_STRNLEN
-
-#ifndef __NT__
-#undef FILE_SHARE_DELETE
-#define FILE_SHARE_DELETE 0     /* Not implemented on Win 98/ME */
-#endif
-
-#ifdef NOT_USED
-#define HAVE_SNPRINTF		/* Gave link error */
-#define _snprintf snprintf
-#endif
-
-#ifdef _MSC_VER
-#define HAVE_LDIV		/* The optimizer breaks in zortech for ldiv */
-#define HAVE_ANSI_INCLUDE
-#define HAVE_SYS_UTIME_H
-#define HAVE_STRTOUL
-#endif
-#define my_reinterpret_cast(A) reinterpret_cast <A>
-#define my_const_cast(A) const_cast<A>
-
-
-/* MYSQL OPTIONS */
-
-#ifdef _CUSTOMCONFIG_
-#include <custom_conf.h>
-#else
-#define DEFAULT_MYSQL_HOME	"c:\\mysql"
-#define PACKAGE			"mysql"
-#define DEFAULT_BASEDIR		"C:\\"
-#define SHAREDIR		"share"
-#define DEFAULT_CHARSET_HOME	"C:/mysql/"
-#endif
-#ifndef DEFAULT_HOME_ENV
-#define DEFAULT_HOME_ENV MYSQL_HOME
-#endif
-#ifndef DEFAULT_GROUP_SUFFIX_ENV
-#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX
-#endif
-
-/* File name handling */
-
-#define FN_LIBCHAR	'\\'
-#define FN_ROOTDIR	"\\"
-#define FN_NETWORK_DRIVES	/* Uses \\ to indicate network drives */
-#define FN_NO_CASE_SENCE	/* Files are not case-sensitive */
-#define OS_FILE_LIMIT	2048
-
-#define DO_NOT_REMOVE_THREAD_WRAPPERS
-#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
-#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
-/* The following is only used for statistics, so it should be good enough */
-#ifdef __NT__  /* This should also work on Win98 but .. */
-#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
-#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
-#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
-#else
-#define thread_safe_add(V,C,L) \
-	pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
-#define thread_safe_sub(V,C,L) \
-	pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
-#define statistic_add(V,C,L)	 (V)+=(C)
-#endif
-#define statistic_increment(V,L) thread_safe_increment((V),(L))
-#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
-
-#define shared_memory_buffer_length 16000
-#define default_shared_memory_base_name "MYSQL"
-
-#ifdef CYBOZU
-#define MYSQL_DEFAULT_CHARSET_NAME "utf8"
-#define MYSQL_DEFAULT_COLLATION_NAME "utf8_general_cs"
-#define HAVE_UTF8_GENERAL_CS 1
-#else
-#define MYSQL_DEFAULT_CHARSET_NAME "latin1"
-#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
-#endif
-
-#define HAVE_SPATIAL 1
-#define HAVE_RTREE_KEYS 1
-
-#define HAVE_OPENSSL 1
-#define HAVE_YASSL 1
-
-/* Define charsets you want */
-/* #undef HAVE_CHARSET_armscii8 */
-/* #undef HAVE_CHARSET_ascii */
-#ifndef CYBOZU
-#define HAVE_CHARSET_big5 1
-#define HAVE_CHARSET_cp1250 1
-#endif
-/* #undef HAVE_CHARSET_cp1251 */
-/* #undef HAVE_CHARSET_cp1256 */
-/* #undef HAVE_CHARSET_cp1257 */
-/* #undef HAVE_CHARSET_cp850 */
-/* #undef HAVE_CHARSET_cp852 */
-/* #undef HAVE_CHARSET_cp866 */
-#define HAVE_CHARSET_cp932 1
-/* #undef HAVE_CHARSET_dec8 */
-#ifndef CYBOZU
-#define HAVE_CHARSET_eucjpms 1
-#define HAVE_CHARSET_euckr 1
-#define HAVE_CHARSET_gb2312 1
-#define HAVE_CHARSET_gbk 1
-#endif
-/* #undef HAVE_CHARSET_greek */
-/* #undef HAVE_CHARSET_hebrew */
-/* #undef HAVE_CHARSET_hp8 */
-/* #undef HAVE_CHARSET_keybcs2 */
-/* #undef HAVE_CHARSET_koi8r */
-/* #undef HAVE_CHARSET_koi8u */
-#ifndef CYBOZU
-#define HAVE_CHARSET_latin1 1
-#define HAVE_CHARSET_latin2 1
-#endif
-/* #undef HAVE_CHARSET_latin5 */
-/* #undef HAVE_CHARSET_latin7 */
-/* #undef HAVE_CHARSET_macce */
-/* #undef HAVE_CHARSET_macroman */
-#define HAVE_CHARSET_sjis 1
-/* #undef HAVE_CHARSET_swe7 */
-#ifndef CYBOZU
-#define HAVE_CHARSET_tis620 1
-#define HAVE_CHARSET_ucs2 1
-#define HAVE_CHARSET_ujis 1
-#endif
-#define HAVE_CHARSET_utf8 1
-#define HAVE_UCA_COLLATIONS 1
-
diff --git a/3rdparty/mysql/include/m_ctype.h b/3rdparty/mysql/include/m_ctype.h
deleted file mode 100644
index 7d058d89d..000000000
--- a/3rdparty/mysql/include/m_ctype.h
+++ /dev/null
@@ -1,493 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/*
-  A better inplementation of the UNIX ctype(3) library.
-  Notes:   my_global.h should be included before ctype.h
-*/
-
-#ifndef _m_ctype_h
-#define _m_ctype_h
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#define MY_CS_NAME_SIZE			32
-#define MY_CS_CTYPE_TABLE_SIZE		257
-#define MY_CS_TO_LOWER_TABLE_SIZE	256
-#define MY_CS_TO_UPPER_TABLE_SIZE	256
-#define MY_CS_SORT_ORDER_TABLE_SIZE	256
-#define MY_CS_TO_UNI_TABLE_SIZE		256
-
-#define CHARSET_DIR	"charsets/"
-
-#define my_wc_t ulong
-
-typedef struct unicase_info_st
-{
-  uint16 toupper;
-  uint16 tolower;
-  uint16 sort;
-} MY_UNICASE_INFO;
-
-
-extern MY_UNICASE_INFO *my_unicase_default[256];
-extern MY_UNICASE_INFO *my_unicase_turkish[256];
-
-
-/* wm_wc and wc_mb return codes */
-#define MY_CS_ILSEQ	0     /* Wrong by sequence: wb_wc                   */
-#define MY_CS_ILUNI	0     /* Cannot encode Unicode to charset: wc_mb    */
-#define MY_CS_TOOSMALL  -101  /* Need at least one byte:    wc_mb and mb_wc */
-#define MY_CS_TOOSMALL2 -102  /* Need at least two bytes:   wc_mb and mb_wc */
-#define MY_CS_TOOSMALL3 -103  /* Need at least three bytes: wc_mb and mb_wc */
-/* These following three are currently not really used */
-#define MY_CS_TOOSMALL4 -104  /* Need at least 4 bytes: wc_mb and mb_wc */
-#define MY_CS_TOOSMALL5 -105  /* Need at least 5 bytes: wc_mb and mb_wc */
-#define MY_CS_TOOSMALL6 -106  /* Need at least 6 bytes: wc_mb and mb_wc */
-/* A helper macros for "need at least n bytes" */
-#define MY_CS_TOOSMALLN(n)    (-100-(n))
-
-#define MY_SEQ_INTTAIL	1
-#define MY_SEQ_SPACES	2
-
-        /* My charsets_list flags */
-#define MY_CS_COMPILED  1      /* compiled-in sets               */
-#define MY_CS_CONFIG    2      /* sets that have a *.conf file   */
-#define MY_CS_INDEX     4      /* sets listed in the Index file  */
-#define MY_CS_LOADED    8      /* sets that are currently loaded */
-#define MY_CS_BINSORT	16     /* if binary sort order           */
-#define MY_CS_PRIMARY	32     /* if primary collation           */
-#define MY_CS_STRNXFRM	64     /* if strnxfrm is used for sort   */
-#define MY_CS_UNICODE	128    /* is a charset is full unicode   */
-#define MY_CS_READY	256    /* if a charset is initialized    */
-#define MY_CS_AVAILABLE	512    /* If either compiled-in or loaded*/
-#define MY_CS_CSSORT	1024   /* if case sensitive sort order   */
-#define MY_CHARSET_UNDEFINED 0
-
-
-typedef struct my_uni_idx_st
-{
-  uint16 from;
-  uint16 to;
-  uchar  *tab;
-} MY_UNI_IDX;
-
-typedef struct
-{
-  uint beg;
-  uint end;
-  uint mblen;
-} my_match_t;
-
-enum my_lex_states
-{
-  MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT, 
-  MY_LEX_IDENT_SEP, MY_LEX_IDENT_START,
-  MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER,
-  MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END,
-  MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL,
-  MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE, 
-  MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON, 
-  MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP, 
-  MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
-  MY_LEX_IDENT_OR_KEYWORD,
-  MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR,
-  MY_LEX_STRING_OR_DELIMITER
-};
-
-struct charset_info_st;
-
-typedef struct my_collation_handler_st
-{
-  my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint));
-  /* Collation routines */
-  int     (*strnncoll)(struct charset_info_st *,
-		       const uchar *, uint, const uchar *, uint, my_bool);
-  int     (*strnncollsp)(struct charset_info_st *,
-                         const uchar *, uint, const uchar *, uint,
-                         my_bool diff_if_only_endspace_difference);
-  int     (*strnxfrm)(struct charset_info_st *,
-		      uchar *, uint, const uchar *, uint);
-  uint    (*strnxfrmlen)(struct charset_info_st *, uint); 
-  my_bool (*like_range)(struct charset_info_st *,
-			const char *s, uint s_length,
-			pchar w_prefix, pchar w_one, pchar w_many, 
-			uint res_length,
-			char *min_str, char *max_str,
-			uint *min_len, uint *max_len);
-  int     (*wildcmp)(struct charset_info_st *,
-  		     const char *str,const char *str_end,
-                     const char *wildstr,const char *wildend,
-                     int escape,int w_one, int w_many);
-
-  int  (*strcasecmp)(struct charset_info_st *, const char *, const char *);
-  
-  uint (*instr)(struct charset_info_st *,
-                const char *b, uint b_length,
-                const char *s, uint s_length,
-                my_match_t *match, uint nmatch);
-  
-  /* Hash calculation */
-  void (*hash_sort)(struct charset_info_st *cs, const uchar *key, uint len,
-		    ulong *nr1, ulong *nr2); 
-  my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, uint len);
-} MY_COLLATION_HANDLER;
-
-extern MY_COLLATION_HANDLER my_collation_mb_bin_handler;
-extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler;
-extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler;
-extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler;
-
-
-typedef struct my_charset_handler_st
-{
-  my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint));
-  /* Multibyte routines */
-  int     (*ismbchar)(struct charset_info_st *, const char *, const char *);
-  int     (*mbcharlen)(struct charset_info_st *, uint);
-  uint    (*numchars)(struct charset_info_st *, const char *b, const char *e);
-  uint    (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos);
-  uint    (*well_formed_len)(struct charset_info_st *,
-                             const char *b,const char *e,
-                             uint nchars, int *error);
-  uint    (*lengthsp)(struct charset_info_st *, const char *ptr, uint length);
-  uint    (*numcells)(struct charset_info_st *, const char *b, const char *e);
-  
-  /* Unicode convertion */
-  int (*mb_wc)(struct charset_info_st *cs,my_wc_t *wc,
-	       const unsigned char *s,const unsigned char *e);
-  int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc,
-	       unsigned char *s,unsigned char *e);
-  
-  /* Functions for case and sort convertion */
-  void    (*caseup_str)(struct charset_info_st *, char *);
-  void    (*casedn_str)(struct charset_info_st *, char *);
-  uint    (*caseup)(struct charset_info_st *, char *src, uint srclen,
-                                              char *dst, uint dstlen);
-  uint    (*casedn)(struct charset_info_st *, char *src, uint srclen,
-                                              char *dst, uint dstlen);
-  
-  /* Charset dependant snprintf() */
-  int  (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt,
-		   ...);
-  int  (*long10_to_str)(struct charset_info_st *, char *to, uint n, int radix,
-			long int val);
-  int (*longlong10_to_str)(struct charset_info_st *, char *to, uint n,
-			   int radix, longlong val);
-  
-  void (*fill)(struct charset_info_st *, char *to, uint len, int fill);
-  
-  /* String-to-number convertion routines */
-  long        (*strntol)(struct charset_info_st *, const char *s, uint l,
-			 int base, char **e, int *err);
-  ulong      (*strntoul)(struct charset_info_st *, const char *s, uint l,
-			 int base, char **e, int *err);
-  longlong   (*strntoll)(struct charset_info_st *, const char *s, uint l,
-			 int base, char **e, int *err);
-  ulonglong (*strntoull)(struct charset_info_st *, const char *s, uint l,
-			 int base, char **e, int *err);
-  double      (*strntod)(struct charset_info_st *, char *s, uint l, char **e,
-			 int *err);
-  longlong    (*strtoll10)(struct charset_info_st *cs,
-                           const char *nptr, char **endptr, int *error);
-  ulong        (*scan)(struct charset_info_st *, const char *b, const char *e,
-		       int sq);
-} MY_CHARSET_HANDLER;
-
-extern MY_CHARSET_HANDLER my_charset_8bit_handler;
-extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
-
-
-typedef struct charset_info_st
-{
-  uint      number;
-  uint      primary_number;
-  uint      binary_number;
-  uint      state;
-  const char *csname;
-  const char *name;
-  const char *comment;
-  const char *tailoring;
-  uchar    *ctype;
-  uchar    *to_lower;
-  uchar    *to_upper;
-  uchar    *sort_order;
-  uint16   *contractions;
-  uint16   **sort_order_big;
-  uint16      *tab_to_uni;
-  MY_UNI_IDX  *tab_from_uni;
-  MY_UNICASE_INFO **caseinfo;
-  uchar     *state_map;
-  uchar     *ident_map;
-  uint      strxfrm_multiply;
-  uchar     caseup_multiply;
-  uchar     casedn_multiply;
-  uint      mbminlen;
-  uint      mbmaxlen;
-  uint16    min_sort_char;
-  uint16    max_sort_char; /* For LIKE optimization */
-  uchar     pad_char;
-  my_bool   escape_with_backslash_is_dangerous;
-  
-  MY_CHARSET_HANDLER *cset;
-  MY_COLLATION_HANDLER *coll;
-  
-} CHARSET_INFO;
-
-
-extern CHARSET_INFO my_charset_bin;
-extern CHARSET_INFO my_charset_big5_chinese_ci;
-extern CHARSET_INFO my_charset_big5_bin;
-extern CHARSET_INFO my_charset_cp932_japanese_ci;
-extern CHARSET_INFO my_charset_cp932_bin;
-extern CHARSET_INFO my_charset_eucjpms_japanese_ci;
-extern CHARSET_INFO my_charset_eucjpms_bin;
-extern CHARSET_INFO my_charset_euckr_korean_ci;
-extern CHARSET_INFO my_charset_euckr_bin;
-extern CHARSET_INFO my_charset_gb2312_chinese_ci;
-extern CHARSET_INFO my_charset_gb2312_bin;
-extern CHARSET_INFO my_charset_gbk_chinese_ci;
-extern CHARSET_INFO my_charset_gbk_bin;
-extern CHARSET_INFO my_charset_latin1;
-extern CHARSET_INFO my_charset_latin1_german2_ci;
-extern CHARSET_INFO my_charset_latin1_bin;
-extern CHARSET_INFO my_charset_latin2_czech_ci;
-extern CHARSET_INFO my_charset_sjis_japanese_ci;
-extern CHARSET_INFO my_charset_sjis_bin;
-extern CHARSET_INFO my_charset_tis620_thai_ci;
-extern CHARSET_INFO my_charset_tis620_bin;
-extern CHARSET_INFO my_charset_ucs2_general_ci;
-extern CHARSET_INFO my_charset_ucs2_bin;
-extern CHARSET_INFO my_charset_ucs2_general_uca;
-extern CHARSET_INFO my_charset_ujis_japanese_ci;
-extern CHARSET_INFO my_charset_ujis_bin;
-extern CHARSET_INFO my_charset_utf8_general_ci;
-extern CHARSET_INFO my_charset_utf8_bin;
-extern CHARSET_INFO my_charset_cp1250_czech_ci;
-
-/* declarations for simple charsets */
-extern int  my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *,
-                               uint); 
-uint  my_strnxfrmlen_simple(CHARSET_INFO *, uint); 
-extern int  my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint,
-				const uchar *, uint, my_bool);
-
-extern int  my_strnncollsp_simple(CHARSET_INFO *, const uchar *, uint,
-                                  const uchar *, uint,
-                                  my_bool diff_if_only_endspace_difference);
-
-extern void my_hash_sort_simple(CHARSET_INFO *cs,
-				const uchar *key, uint len,
-				ulong *nr1, ulong *nr2); 
-
-extern uint my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, uint length);
-
-extern uint my_instr_simple(struct charset_info_st *,
-                            const char *b, uint b_length,
-                            const char *s, uint s_length,
-                            my_match_t *match, uint nmatch);
-
-
-/* Functions for 8bit */
-extern void my_caseup_str_8bit(CHARSET_INFO *, char *);
-extern void my_casedn_str_8bit(CHARSET_INFO *, char *);
-extern uint my_caseup_8bit(CHARSET_INFO *, char *src, uint srclen,
-                                           char *dst, uint dstlen);
-extern uint my_casedn_8bit(CHARSET_INFO *, char *src, uint srclen,
-                                           char *dst, uint dstlen);
-
-extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
-
-int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,const uchar *e);
-int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e);
-
-ulong my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq);
-
-int my_snprintf_8bit(struct charset_info_st *, char *to, uint n,
-		     const char *fmt, ...);
-
-long        my_strntol_8bit(CHARSET_INFO *, const char *s, uint l, int base,
-			    char **e, int *err);
-ulong      my_strntoul_8bit(CHARSET_INFO *, const char *s, uint l, int base,
-			    char **e, int *err);
-longlong   my_strntoll_8bit(CHARSET_INFO *, const char *s, uint l, int base,
-			    char **e, int *err);
-ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, uint l, int base,
-			    char **e, int *err);
-double      my_strntod_8bit(CHARSET_INFO *, char *s, uint l,char **e,
-			    int *err);
-int  my_long10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix,
-			   long int val);
-int my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix,
-			      longlong val);
-
-longlong my_strtoll10_8bit(CHARSET_INFO *cs,
-                           const char *nptr, char **endptr, int *error);
-longlong my_strtoll10_ucs2(CHARSET_INFO *cs, 
-                           const char *nptr, char **endptr, int *error);
-
-void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill);
-
-my_bool  my_like_range_simple(CHARSET_INFO *cs,
-			      const char *ptr, uint ptr_length,
-			      pbool escape, pbool w_one, pbool w_many,
-			      uint res_length,
-			      char *min_str, char *max_str,
-			      uint *min_length, uint *max_length);
-
-my_bool  my_like_range_mb(CHARSET_INFO *cs,
-			  const char *ptr, uint ptr_length,
-			  pbool escape, pbool w_one, pbool w_many,
-			  uint res_length,
-			  char *min_str, char *max_str,
-			  uint *min_length, uint *max_length);
-
-my_bool  my_like_range_ucs2(CHARSET_INFO *cs,
-			    const char *ptr, uint ptr_length,
-			    pbool escape, pbool w_one, pbool w_many,
-			    uint res_length,
-			    char *min_str, char *max_str,
-			    uint *min_length, uint *max_length);
-
-
-int my_wildcmp_8bit(CHARSET_INFO *,
-		    const char *str,const char *str_end,
-		    const char *wildstr,const char *wildend,
-		    int escape, int w_one, int w_many);
-
-int my_wildcmp_bin(CHARSET_INFO *,
-		   const char *str,const char *str_end,
-		   const char *wildstr,const char *wildend,
-		   int escape, int w_one, int w_many);
-
-uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e);
-uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e);
-uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos);
-uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e,
-                             uint pos, int *error);
-int my_mbcharlen_8bit(CHARSET_INFO *, uint c);
-
-
-/* Functions for multibyte charsets */
-extern void my_caseup_str_mb(CHARSET_INFO *, char *);
-extern void my_casedn_str_mb(CHARSET_INFO *, char *);
-extern uint my_caseup_mb(CHARSET_INFO *, char *src, uint srclen,
-                                         char *dst, uint dstlen);
-extern uint my_casedn_mb(CHARSET_INFO *, char *src, uint srclen,
-                                         char *dst, uint dstlen);
-extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);
-
-int my_wildcmp_mb(CHARSET_INFO *,
-		  const char *str,const char *str_end,
-		  const char *wildstr,const char *wildend,
-		  int escape, int w_one, int w_many);
-uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e);
-uint my_numcells_mb(CHARSET_INFO *, const char *b, const char *e);
-uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos);
-uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e,
-                           uint pos, int *error);
-uint my_instr_mb(struct charset_info_st *,
-                 const char *b, uint b_length,
-                 const char *s, uint s_length,
-                 my_match_t *match, uint nmatch);
-
-int my_wildcmp_unicode(CHARSET_INFO *cs,
-                       const char *str, const char *str_end,
-                       const char *wildstr, const char *wildend,
-                       int escape, int w_one, int w_many,
-                       MY_UNICASE_INFO **weights);
-
-extern my_bool my_parse_charset_xml(const char *bug, uint len,
-				    int (*add)(CHARSET_INFO *cs));
-
-my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, uint len);
-my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, uint len);
-
-
-#define	_MY_U	01	/* Upper case */
-#define	_MY_L	02	/* Lower case */
-#define	_MY_NMR	04	/* Numeral (digit) */
-#define	_MY_SPC	010	/* Spacing character */
-#define	_MY_PNT	020	/* Punctuation */
-#define	_MY_CTR	040	/* Control character */
-#define	_MY_B	0100	/* Blank */
-#define	_MY_X	0200	/* heXadecimal digit */
-
-
-#define	my_isascii(c)	(!((c) & ~0177))
-#define	my_toascii(c)	((c) & 0177)
-#define my_tocntrl(c)	((c) & 31)
-#define my_toprint(c)	((c) | 64)
-#define my_toupper(s,c)	(char) ((s)->to_upper[(uchar) (c)])
-#define my_tolower(s,c)	(char) ((s)->to_lower[(uchar) (c)])
-#define	my_isalpha(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L))
-#define	my_isupper(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_U)
-#define	my_islower(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_L)
-#define	my_isdigit(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_NMR)
-#define	my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X)
-#define	my_isalnum(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR))
-#define	my_isspace(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_SPC)
-#define	my_ispunct(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_PNT)
-#define	my_isprint(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
-#define	my_isgraph(s, c)  (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
-#define	my_iscntrl(s, c)  (((s)->ctype+1)[(uchar) (c)] & _MY_CTR)
-
-/* Some macros that should be cleaned up a little */
-#define my_isvar(s,c)                 (my_isalnum(s,c) || (c) == '_')
-#define my_isvar_start(s,c)           (my_isalpha(s,c) || (c) == '_')
-
-#define my_binary_compare(s)	      ((s)->state  & MY_CS_BINSORT)
-#define use_strnxfrm(s)               ((s)->state  & MY_CS_STRNXFRM)
-#define my_strnxfrm(s, a, b, c, d)    ((s)->coll->strnxfrm((s), (a), (b), (c), (d)))
-#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
-#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
-   ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
-#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
-#define my_strcasecmp(s, a, b)        ((s)->coll->strcasecmp((s), (a), (b)))
-#define my_charpos(cs, b, e, num)     (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
-
-
-#define use_mb(s)                     ((s)->cset->ismbchar != NULL)
-#define my_ismbchar(s, a, b)          ((s)->cset->ismbchar((s), (a), (b)))
-#ifdef USE_MB
-#define my_mbcharlen(s, a)            ((s)->cset->mbcharlen((s),(a)))
-#else
-#define my_mbcharlen(s, a)            1
-#endif
-
-#define my_caseup_str(s, a)           ((s)->cset->caseup_str((s), (a)))
-#define my_casedn_str(s, a)           ((s)->cset->casedn_str((s), (a)))
-#define my_strntol(s, a, b, c, d, e)  ((s)->cset->strntol((s),(a),(b),(c),(d),(e)))
-#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e)))
-#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e)))
-#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
-#define my_strntod(s, a, b, c, d)     ((s)->cset->strntod((s),(a),(b),(c),(d)))
-
-
-/* XXX: still need to take care of this one */
-#ifdef MY_CHARSET_TIS620
-#error The TIS620 charset is broken at the moment.  Tell tim to fix it.
-#define USE_TIS620
-#include "t_ctype.h"
-#endif
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif /* _m_ctype_h */
diff --git a/3rdparty/mysql/include/my_alloc.h b/3rdparty/mysql/include/my_alloc.h
deleted file mode 100644
index 1641b3acf..000000000
--- a/3rdparty/mysql/include/my_alloc.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/* 
-   Data structures for mysys/my_alloc.c (root memory allocator)
-*/
-
-#ifndef _my_alloc_h
-#define _my_alloc_h
-
-#define ALLOC_MAX_BLOCK_TO_DROP			4096
-#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP	10
-
-typedef struct st_used_mem
-{				   /* struct for once_alloc (block) */
-  struct st_used_mem *next;	   /* Next block in use */
-  unsigned int	left;		   /* memory left in block  */
-  unsigned int	size;		   /* size of block */
-} USED_MEM;
-
-
-typedef struct st_mem_root
-{
-  USED_MEM *free;                  /* blocks with free memory in it */
-  USED_MEM *used;                  /* blocks almost without free memory */
-  USED_MEM *pre_alloc;             /* preallocated block */
-  /* if block have less memory it will be put in 'used' list */
-  unsigned int min_malloc;
-  unsigned int block_size;         /* initial block size */
-  unsigned int block_num;          /* allocated blocks counter */
-  /* 
-     first free block in queue test counter (if it exceed 
-     MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
-  */
-  unsigned int first_block_usage;
-
-  void (*error_handler)(void);
-} MEM_ROOT;
-#endif
diff --git a/3rdparty/mysql/include/my_dbug.h b/3rdparty/mysql/include/my_dbug.h
deleted file mode 100644
index b76a3fcc8..000000000
--- a/3rdparty/mysql/include/my_dbug.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#ifndef _dbug_h
-#define _dbug_h
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-#if !defined(DBUG_OFF) && !defined(_lint)
-extern	int _db_on_,_no_db_;
-extern	FILE *_db_fp_;
-extern	char *_db_process_;
-extern	int _db_keyword_(const char *keyword);
-extern  int _db_strict_keyword_(const char *keyword);
-extern	void _db_setjmp_(void);
-extern	void _db_longjmp_(void);
-extern	void _db_push_(const char *control);
-extern	void _db_pop_(void);
-extern	void _db_enter_(const char *_func_,const char *_file_,uint _line_,
-			const char **_sfunc_,const char **_sfile_,
-			uint *_slevel_, char ***);
-extern	void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
-			 uint *_slevel_);
-extern	void _db_pargs_(uint _line_,const char *keyword);
-extern	void _db_doprnt_ _VARARGS((const char *format,...));
-extern	void _db_dump_(uint _line_,const char *keyword,const char *memory,
-		       uint length);
-extern	void _db_output_(uint flag);
-extern	void _db_lock_file(void);
-extern	void _db_unlock_file(void);
-
-#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
-	char **_db_framep_; \
-	_db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
-		    &_db_framep_)
-#define DBUG_LEAVE \
-	(_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
-#define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);}
-#define DBUG_VOID_RETURN {DBUG_LEAVE; return;}
-#define DBUG_EXECUTE(keyword,a1) \
-	{if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
-#define DBUG_PRINT(keyword,arglist) \
-	{if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
-#define DBUG_PUSH(a1) _db_push_ (a1)
-#define DBUG_POP() _db_pop_ ()
-#define DBUG_PROCESS(a1) (_db_process_ = a1)
-#define DBUG_FILE (_db_fp_)
-#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
-#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
-#define DBUG_DUMP(keyword,a1,a2)\
-	{if (_db_on_) {_db_dump_(__LINE__,keyword,a1,a2);}}
-#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr)
-#define DEBUGGER_OFF _no_db_=1;_db_on_=0;
-#define DEBUGGER_ON  _no_db_=0
-#define DBUG_LOCK_FILE { _db_lock_file(); }
-#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
-#define DBUG_OUTPUT(A) { _db_output_(A); }
-#define DBUG_ASSERT(A) assert(A)
-#define DBUG_EXECUTE_IF(keyword,a1) \
-        {if (_db_on_) {if (_db_strict_keyword_ (keyword)) { a1 }}}
-#else						/* No debugger */
-
-#define DBUG_ENTER(a1)
-#define DBUG_RETURN(a1) return(a1)
-#define DBUG_VOID_RETURN return
-#define DBUG_EXECUTE(keyword,a1) {}
-#define DBUG_EXECUTE_IF(keyword,a1) {}
-#define DBUG_PRINT(keyword,arglist) {}
-#define DBUG_PUSH(a1) {}
-#define DBUG_POP() {}
-#define DBUG_PROCESS(a1) {}
-#define DBUG_FILE (stderr)
-#define DBUG_SETJMP setjmp
-#define DBUG_LONGJMP longjmp
-#define DBUG_DUMP(keyword,a1,a2) {}
-#define DBUG_IN_USE 0
-#define DEBUGGER_OFF
-#define DEBUGGER_ON
-#define DBUG_LOCK_FILE
-#define DBUG_UNLOCK_FILE
-#define DBUG_OUTPUT(A)
-#define DBUG_ASSERT(A) {}
-#endif
-#ifdef	__cplusplus
-}
-#endif
-#endif
diff --git a/3rdparty/mysql/include/my_global.h b/3rdparty/mysql/include/my_global.h
deleted file mode 100644
index 8e4287c19..000000000
--- a/3rdparty/mysql/include/my_global.h
+++ /dev/null
@@ -1,1306 +0,0 @@
-/* Copyright (C) 2000-2003 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/* This is the include file that should be included 'first' in every C file. */
-
-#ifndef _global_h
-#define _global_h
-
-#ifndef EMBEDDED_LIBRARY
-#define HAVE_REPLICATION
-#define HAVE_EXTERNAL_CLIENT
-#endif
-
-#if defined( __EMX__) && !defined( MYSQL_SERVER)
-/* moved here to use below VOID macro redefinition */
-#define INCL_BASE
-#define INCL_NOPMAPI
-#include <os2.h>
-#endif /* __EMX__ */
-
-#ifdef __CYGWIN__
-/* We use a Unix API, so pretend it's not Windows */
-#undef WIN
-#undef WIN32
-#undef _WIN
-#undef _WIN32
-#undef _WIN64
-#undef __WIN__
-#undef __WIN32__
-#define HAVE_ERRNO_AS_DEFINE
-#endif /* __CYGWIN__ */
-
-#if defined(__QNXNTO__) && !defined(FD_SETSIZE)
-#define FD_SETSIZE 1024         /* Max number of file descriptor bits in
-                                   fd_set, used when calling 'select'
-                                   Must be defined before including
-                                   "sys/select.h" and "sys/time.h"
-                                 */
-#endif
-
-
-/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
-#ifdef USE_PRAGMA_IMPLEMENTATION
-#define USE_PRAGMA_INTERFACE
-#endif
-
-#if defined(i386) && !defined(__i386__)
-#define __i386__
-#endif
-
-/* Macros to make switching between C and C++ mode easier */
-#ifdef __cplusplus
-#define C_MODE_START    extern "C" {
-#define C_MODE_END	}
-#else
-#define C_MODE_START
-#define C_MODE_END
-#endif
-
-#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
-#include <config-win.h>
-#elif defined(OS2)
-#include <config-os2.h>
-#elif defined(__NETWARE__)
-#include <my_config.h>
-#include <config-netware.h>
-#if defined(__cplusplus) && defined(inline)
-#undef inline				/* fix configure problem */
-#endif
-#else
-#include <my_config.h>
-#if defined(__cplusplus) && defined(inline)
-#undef inline				/* fix configure problem */
-#endif
-#endif /* _WIN32... */
-
-/* Some defines to avoid ifdefs in the code */
-#ifndef NETWARE_YIELD
-#define NETWARE_YIELD
-#define NETWARE_SET_SCREEN_MODE(A)
-#endif
-
-#include "common/strlib.h"
-
-/*
-  The macros below are borrowed from include/linux/compiler.h in the
-  Linux kernel. Use them to indicate the likelyhood of the truthfulness
-  of a condition. This serves two purposes - newer versions of gcc will be
-  able to optimize for branch predication, which could yield siginficant
-  performance gains in frequently executed sections of the code, and the
-  other reason to use them is for documentation
-*/
-
-#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
-#define __builtin_expect(x, expected_value) (x)
-#endif
-
-#define likely(x)	__builtin_expect((x),1)
-#define unlikely(x)	__builtin_expect((x),0)
-
-
-/* Fix problem with S_ISLNK() on Linux */
-#if defined(TARGET_OS_LINUX)
-#undef  _GNU_SOURCE
-#define _GNU_SOURCE 1
-#endif
-
-/*
-  Temporary solution to solve bug#7156. Include "sys/types.h" before
-  the thread headers, else the function madvise() will not be defined
-*/
-#if defined(HAVE_SYS_TYPES_H) && ( defined(sun) || defined(__sun) )
-#include <sys/types.h>
-#endif
-
-/* The client defines this to avoid all thread code */
-#if defined(UNDEF_THREADS_HACK)
-#undef THREAD
-#undef HAVE_mit_thread
-#undef HAVE_LINUXTHREADS
-#undef HAVE_NPTL
-#undef HAVE_UNIXWARE7_THREADS
-#endif
-
-#ifdef HAVE_THREADS_WITHOUT_SOCKETS
-/* MIT pthreads does not work with unix sockets */
-#undef HAVE_SYS_UN_H
-#endif
-
-#define __EXTENSIONS__ 1	/* We want some extension */
-#ifndef __STDC_EXT__
-#define __STDC_EXT__ 1          /* To get large file support on hpux */
-#endif
-
-/*
-  Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
-
-    System Interfaces and Headers, Issue 5
-
-  saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
-  but apparently other systems (namely FreeBSD) don't agree.
-
-  On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
-  Furthermore, it tests that if a program requires older standard
-  (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
-  run on a new compiler (that defines _STDC_C99) and issues an #error.
-  It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
-  or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
-
-  To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
-  C++ compiler does not!
-
-  So, in a desperate attempt to get correct prototypes for both
-  C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
-  depending on the compiler's announced C standard support.
-
-  Cleaner solutions are welcome.
-*/
-#ifdef __sun
-#if __STDC_VERSION__ - 0 >= 199901L
-#define _XOPEN_SOURCE 600
-#else
-#define _XOPEN_SOURCE 500
-#endif
-#endif
-
-#if defined(THREAD) && !defined(__WIN__) && !defined(OS2)
-#ifndef _POSIX_PTHREAD_SEMANTICS
-#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
-#endif
-
-#if !defined(SCO)
-#define _REENTRANT	1	/* Some thread libraries require this */
-#endif
-#if !defined(_THREAD_SAFE) && !defined(_AIX)
-#define _THREAD_SAFE            /* Required for OSF1 */
-#endif
-#ifndef HAVE_mit_thread
-#ifdef HAVE_UNIXWARE7_THREADS
-#include <thread.h>
-#else
-#if defined(HPUX10) || defined(HPUX11)
-C_MODE_START			/* HPUX needs this, signal.h bug */
-#include <pthread.h>
-C_MODE_END
-#else
-#include <pthread.h>		/* AIX must have this included first */
-#endif
-#endif /* HAVE_UNIXWARE7_THREADS */
-#endif /* HAVE_mit_thread */
-#if !defined(SCO) && !defined(_REENTRANT)
-#define _REENTRANT	1	/* Threads requires reentrant code */
-#endif
-#endif /* THREAD */
-
-/* Go around some bugs in different OS and compilers */
-#ifdef _AIX			/* By soren@t.dk */
-#define _H_STRINGS
-#define _SYS_STREAM_H
-/* #define _AIX32_CURSES */	/* XXX: this breaks AIX 4.3.3 (others?). */
-#define ulonglong2double(A) my_ulonglong2double(A)
-#define my_off_t2double(A)  my_ulonglong2double(A)
-C_MODE_START
-double my_ulonglong2double(unsigned long long A);
-C_MODE_END
-#endif /* _AIX */
-
-#ifdef HAVE_BROKEN_SNPRINTF	/* HPUX 10.20 don't have this defined */
-#undef HAVE_SNPRINTF
-#endif
-#ifdef HAVE_BROKEN_PREAD
-/*
-  pread()/pwrite() are not 64 bit safe on HP-UX 11.0 without
-  installing the kernel patch PHKL_20349 or greater
-*/
-#undef HAVE_PREAD
-#undef HAVE_PWRITE
-#endif
-#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
-#undef inline
-#define inline
-#endif
-
-#ifdef UNDEF_HAVE_GETHOSTBYNAME_R		/* For OSF4.x */
-#undef HAVE_GETHOSTBYNAME_R
-#endif
-#ifdef UNDEF_HAVE_INITGROUPS			/* For AIX 4.3 */
-#undef HAVE_INITGROUPS
-#endif
-
-/* gcc/egcs issues */
-
-#if defined(__GNUC) && defined(__EXCEPTIONS)
-#error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
-#endif
-
-
-/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */
-#if SIZEOF_LONG == 4 && defined(__LONG_MAX__) && (__GNUC__ == 2 && __GNUC_MINOR__ == 8)
-#undef __LONG_MAX__             /* Is a longlong value in gcc 2.8.0 ??? */
-#define __LONG_MAX__ 2147483647
-#endif
-
-/* egcs 1.1.2 has a problem with memcpy on Alpha */
-#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 &&  __GNUC_MINOR__ >= 95))
-#define BAD_MEMCPY
-#endif
-
-#if defined(_lint) && !defined(lint)
-#define lint
-#endif
-#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
-#define _LONG_LONG 1		/* For AIX string library */
-#endif
-
-#ifndef stdin
-#include <stdio.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-
-#include <math.h>
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#ifdef HAVE_FLOAT_H
-#include <float.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_SYS_TIMEB_H
-#include <sys/timeb.h>				/* Avoid warnings on SCO */
-#endif
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif /* TIME_WITH_SYS_TIME */
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
-#undef HAVE_ALLOCA
-#undef HAVE_ALLOCA_H
-#endif
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-#ifdef HAVE_ATOMIC_ADD
-#define new my_arg_new
-#define need_to_restore_new 1
-C_MODE_START
-#include <asm/atomic.h>
-C_MODE_END
-#ifdef need_to_restore_new /* probably safer than #ifdef new */
-#undef new
-#undef need_to_restore_new
-#endif
-#endif
-#include <errno.h>				/* Recommended by debian */
-/* We need the following to go around a problem with openssl on solaris */
-#if defined(HAVE_CRYPT_H)
-#include <crypt.h>
-#endif
-
-/*
-  A lot of our programs uses asserts, so better to always include it
-  This also fixes a problem when people uses DBUG_ASSERT without including
-  assert.h
-*/
-#include <assert.h>
-
-/* Go around some bugs in different OS and compilers */
-#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
-#include <sys/stream.h>		/* HPUX 10.20 defines ulong here. UGLY !!! */
-#define HAVE_ULONG
-#endif
-#ifdef DONT_USE_FINITE		/* HPUX 11.x has is_finite() */
-#undef HAVE_FINITE
-#endif
-#if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD)
-/* Fix bug in setrlimit */
-#undef setrlimit
-#define setrlimit cma_setrlimit64
-#endif
-/* Declare madvise where it is not declared for C++, like Solaris */
-#if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus)
-extern "C" int madvise(void *addr, size_t len, int behav);
-#endif
-
-#ifdef __QNXNTO__
-/* This has to be after include limits.h */
-#define HAVE_ERRNO_AS_DEFINE
-#define HAVE_FCNTL_LOCK
-#undef  HAVE_FINITE
-#undef  LONGLONG_MIN            /* These get wrongly defined in QNX 6.2 */
-#undef  LONGLONG_MAX            /* standard system library 'limits.h' */
-#ifdef __cplusplus
-#ifndef HAVE_RINT
-#define HAVE_RINT
-#endif                          /* rint() and isnan() functions are not */
-#define rint(a) std::rint(a)    /* visible in C++ scope due to an error */
-#define isnan(a) std::isnan(a)  /* in the usr/include/math.h on QNX     */
-#endif
-#endif
-
-/* We can not live without the following defines */
-
-#define USE_MYFUNC 1		/* Must use syscall indirection */
-#define MASTER 1		/* Compile without unireg */
-#define ENGLISH 1		/* Messages in English */
-#define POSIX_MISTAKE 1		/* regexp: Fix stupid spec error */
-#define USE_REGEX 1		/* We want the use the regex library */
-/* Do not define for ultra sparcs */
-#ifndef OS2
-#define USE_BMOVE512 1		/* Use this unless system bmove is faster */
-#endif
-
-#define QUOTE_ARG(x)		#x	/* Quote argument (before cpp) */
-#define STRINGIFY_ARG(x) QUOTE_ARG(x)	/* Quote argument, after cpp */
-
-/* Paranoid settings. Define I_AM_PARANOID if you are paranoid */
-#ifdef I_AM_PARANOID
-#define DONT_ALLOW_USER_CHANGE 1
-#define DONT_USE_MYSQL_PWD 1
-#endif
-
-/* Does the system remember a signal handler after a signal ? */
-#ifndef HAVE_BSD_SIGNALS
-#define DONT_REMEMBER_SIGNAL
-#endif
-
-/* Define void to stop lint from generating "null effekt" comments */
-#ifndef DONT_DEFINE_VOID
-#ifdef _lint
-int	__void__;
-#define VOID(X)		(__void__ = (int) (X))
-#else
-#undef VOID
-#define VOID(X)		(X)
-#endif
-#endif /* DONT_DEFINE_VOID */
-
-#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
-#define LINT_INIT(var)	var=0			/* No uninitialize-warning */
-#else
-#define LINT_INIT(var)
-#endif
-
-#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify)
-#define PURIFY_OR_LINT_INIT(var) var=0
-#else
-#define PURIFY_OR_LINT_INIT(var)
-#endif
-
-/* Define some useful general macros */
-#if !defined(max)
-#define max(a, b)	((a) > (b) ? (a) : (b))
-#define min(a, b)	((a) < (b) ? (a) : (b))
-#endif
-
-#if defined(__EMX__) || !defined(HAVE_UINT)
-#undef HAVE_UINT
-#define HAVE_UINT
-typedef unsigned int uint;
-typedef unsigned short ushort;
-#endif
-
-#define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
-#define sgn(a)		(((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
-#define swap_variables(t, a, b) { register t dummy; dummy= a; a= b; b= dummy; }
-#define test(a)		((a) ? 1 : 0)
-#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
-#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
-#define test_all_bits(a,b) (((a) & (b)) == (b))
-#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
-#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
-#ifndef HAVE_RINT
-#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
-#endif
-
-/* Define some general constants */
-#ifndef TRUE
-#define TRUE		(1)	/* Logical true */
-#define FALSE		(0)	/* Logical false */
-#endif
-
-#if defined(__GNUC__)
-#define function_volatile	volatile
-#define my_reinterpret_cast(A) reinterpret_cast<A>
-#define my_const_cast(A) const_cast<A>
-#elif !defined(my_reinterpret_cast)
-#define my_reinterpret_cast(A) (A)
-#define my_const_cast(A) (A)
-#endif
-#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__)  || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#define __attribute__(A)
-#endif
-
-/*
-  Wen using the embedded library, users might run into link problems,
-  dupicate declaration of __cxa_pure_virtual, solved by declaring it a
-  weak symbol.
-*/
-#ifdef USE_MYSYS_NEW
-C_MODE_START
-int __cxa_pure_virtual () __attribute__ ((weak));
-C_MODE_END
-#endif
-
-/* From old s-system.h */
-
-/*
-  Support macros for non ansi & other old compilers. Since such
-  things are no longer supported we do nothing. We keep then since
-  some of our code may still be needed to upgrade old customers.
-*/
-#define _VARARGS(X) X
-#define _STATIC_VARARGS(X) X
-#define _PC(X)	X
-
-#if defined(DBUG_ON) && defined(DBUG_OFF)
-#undef DBUG_OFF
-#endif
-
-#if defined(_lint) && !defined(DBUG_OFF)
-#define DBUG_OFF
-#endif
-
-#include <my_dbug.h>
-
-#define MIN_ARRAY_SIZE	0	/* Zero or One. Gcc allows zero*/
-#define ASCII_BITS_USED 8	/* Bit char used */
-#define NEAR_F			/* No near function handling */
-
-/* Some types that is different between systems */
-
-typedef int	File;		/* File descriptor */
-#ifndef Socket_defined
-typedef int	my_socket;	/* File descriptor for sockets */
-#define INVALID_SOCKET -1
-#endif
-/* Type for fuctions that handles signals */
-#define sig_handler RETSIGTYPE
-C_MODE_START
-typedef void	(*sig_return)();/* Returns type from signal */
-C_MODE_END
-#if defined(__GNUC__) && !defined(_lint)
-typedef char	pchar;		/* Mixed prototypes can take char */
-typedef char	puchar;		/* Mixed prototypes can take char */
-typedef char	pbool;		/* Mixed prototypes can take char */
-typedef short	pshort;		/* Mixed prototypes can take short int */
-typedef float	pfloat;		/* Mixed prototypes can take float */
-#else
-typedef int	pchar;		/* Mixed prototypes can't take char */
-typedef uint	puchar;		/* Mixed prototypes can't take char */
-typedef int	pbool;		/* Mixed prototypes can't take char */
-typedef int	pshort;		/* Mixed prototypes can't take short int */
-typedef double	pfloat;		/* Mixed prototypes can't take float */
-#endif
-C_MODE_START
-typedef int	(*qsort_cmp)(const void *,const void *);
-typedef int	(*qsort_cmp2)(void*, const void *,const void *);
-C_MODE_END
-#ifdef HAVE_mit_thread
-#define qsort_t void
-#undef QSORT_TYPE_IS_VOID
-#define QSORT_TYPE_IS_VOID
-#else
-#define qsort_t RETQSORTTYPE	/* Broken GCC cant handle typedef !!!! */
-#endif
-#ifdef HAVE_mit_thread
-#define size_socket socklen_t	/* Type of last arg to accept */
-#else
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-typedef SOCKET_SIZE_TYPE size_socket;
-#endif
-
-#ifndef SOCKOPT_OPTLEN_TYPE
-#define SOCKOPT_OPTLEN_TYPE size_socket
-#endif
-
-/* file create flags */
-
-#ifndef O_SHARE			/* Probably not windows */
-#define O_SHARE		0	/* Flag to my_open for shared files */
-#ifndef O_BINARY
-#define O_BINARY	0	/* Flag to my_open for binary files */
-#endif
-#ifndef FILE_BINARY
-#define FILE_BINARY	O_BINARY /* Flag to my_fopen for binary streams */
-#endif
-#ifdef HAVE_FCNTL
-#define HAVE_FCNTL_LOCK
-#define F_TO_EOF	0L	/* Param to lockf() to lock rest of file */
-#endif
-#endif /* O_SHARE */
-
-#ifndef O_TEMPORARY
-#define O_TEMPORARY	0
-#endif
-#ifndef O_SHORT_LIVED
-#define O_SHORT_LIVED	0
-#endif
-#ifndef O_NOFOLLOW
-#define O_NOFOLLOW      0
-#endif
-
-/* additional file share flags for win32 */
-#ifdef __WIN__
-#define _SH_DENYRWD     0x110    /* deny read/write mode & delete */
-#define _SH_DENYWRD     0x120    /* deny write mode & delete      */
-#define _SH_DENYRDD     0x130    /* deny read mode & delete       */
-#define _SH_DENYDEL     0x140    /* deny delete only              */
-#endif /* __WIN__ */
-
-
-/* #define USE_RECORD_LOCK	*/
-
-	/* Unsigned types supported by the compiler */
-#define UNSINT8			/* unsigned int8 (char) */
-#define UNSINT16		/* unsigned int16 */
-#define UNSINT32		/* unsigned int32 */
-
-	/* General constants */
-#define SC_MAXWIDTH	256	/* Max width of screen (for error messages) */
-#define FN_LEN		256	/* Max file name len */
-#define FN_HEADLEN	253	/* Max length of filepart of file name */
-#define FN_EXTLEN	20	/* Max length of extension (part of FN_LEN) */
-#define FN_REFLEN	512	/* Max length of full path-name */
-#define FN_EXTCHAR	'.'
-#define FN_HOMELIB	'~'	/* ~/ is used as abbrev for home dir */
-#define FN_CURLIB	'.'	/* ./ is used as abbrev for current dir */
-#define FN_PARENTDIR	".."	/* Parent directory; Must be a string */
-#define FN_DEVCHAR	':'
-
-#ifndef FN_LIBCHAR
-#ifdef __EMX__
-#define FN_LIBCHAR	'\\'
-#define FN_ROOTDIR	"\\"
-#else
-#define FN_LIBCHAR	'/'
-#define FN_ROOTDIR	"/"
-#endif
-#endif
-#define MY_NFILE	64	/* This is only used to save filenames */
-#ifndef OS_FILE_LIMIT
-#define OS_FILE_LIMIT	65535
-#endif
-
-/* #define EXT_IN_LIBNAME     */
-/* #define FN_NO_CASE_SENCE   */
-/* #define FN_UPPER_CASE TRUE */
-
-/*
-  Io buffer size; Must be a power of 2 and a multiple of 512. May be
-  smaller what the disk page size. This influences the speed of the
-  isam btree library. eg to big to slow.
-*/
-#define IO_SIZE			4096
-/*
-  How much overhead does malloc have. The code often allocates
-  something like 1024-MALLOC_OVERHEAD bytes
-*/
-#ifdef SAFEMALLOC
-#define MALLOC_OVERHEAD (8+24+4)
-#else
-#define MALLOC_OVERHEAD 8
-#endif
-	/* get memory in huncs */
-#define ONCE_ALLOC_INIT		(uint) (4096-MALLOC_OVERHEAD)
-	/* Typical record cash */
-#define RECORD_CACHE_SIZE	(uint) (64*1024-MALLOC_OVERHEAD)
-	/* Typical key cash */
-#define KEY_CACHE_SIZE		(uint) (8*1024*1024-MALLOC_OVERHEAD)
-	/* Default size of a key cache block  */
-#define KEY_CACHE_BLOCK_SIZE	(uint) 1024
-
-
-	/* Some things that this system doesn't have */
-
-#define NO_HASH			/* Not needed anymore */
-#ifdef __WIN__
-#define NO_DIR_LIBRARY		/* Not standar dir-library */
-#define USE_MY_STAT_STRUCT	/* For my_lib */
-#endif
-
-/* Some defines of functions for portability */
-
-#undef remove		/* Crashes MySQL on SCO 5.0.0 */
-#ifndef __WIN__
-#ifdef OS2
-#define closesocket(A)	soclose(A)
-#else
-#define closesocket(A)	close(A)
-#endif
-#ifndef ulonglong2double
-#define ulonglong2double(A) ((double) (ulonglong) (A))
-#define my_off_t2double(A)  ((double) (my_off_t) (A))
-#endif
-#endif
-
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-#define ulong_to_double(X) ((double) (ulong) (X))
-#define SET_STACK_SIZE(X)	/* Not needed on real machines */
-
-#if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
-#define strtok_r(A,B,C) strtok((A),(B))
-#endif
-
-/* Remove some things that mit_thread break or doesn't support */
-#if defined(HAVE_mit_thread) && defined(THREAD)
-#undef HAVE_PREAD
-#undef HAVE_REALPATH
-#undef HAVE_MLOCK
-#undef HAVE_TEMPNAM				/* Use ours */
-#undef HAVE_PTHREAD_SETPRIO
-#undef HAVE_FTRUNCATE
-#undef HAVE_READLINK
-#endif
-
-/* This is from the old m-machine.h file */
-
-#if SIZEOF_LONG_LONG > 4
-#define HAVE_LONG_LONG 1
-#endif
-
-/*
-  Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define
-  ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined.
-  Also on Windows we define these constants by hand in config-win.h.
-*/
-
-#if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
-#define LONGLONG_MIN	((long long) 0x8000000000000000LL)
-#define LONGLONG_MAX	((long long) 0x7FFFFFFFFFFFFFFFLL)
-#endif
-
-#if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
-/* First check for ANSI C99 definition: */
-#ifdef ULLONG_MAX
-#define ULONGLONG_MAX  ULLONG_MAX
-#else
-#define ULONGLONG_MAX ((unsigned long long)(~0ULL))
-#endif
-#endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/
-
-#define INT_MIN32       (~0x7FFFFFFFL)
-#define INT_MAX32       0x7FFFFFFFL
-#define UINT_MAX32      0xFFFFFFFFL
-#define INT_MIN24       (~0x007FFFFF)
-#define INT_MAX24       0x007FFFFF
-#define UINT_MAX24      0x00FFFFFF
-#define INT_MIN16       (~0x7FFF)
-#define INT_MAX16       0x7FFF
-#define UINT_MAX16      0xFFFF
-#define INT_MIN8        (~0x7F)
-#define INT_MAX8        0x7F
-#define UINT_MAX8       0xFF
-
-/* From limits.h instead */
-#ifndef DBL_MIN
-#define DBL_MIN		4.94065645841246544e-324
-#define FLT_MIN		((float)1.40129846432481707e-45)
-#endif
-#ifndef DBL_MAX
-#define DBL_MAX		1.79769313486231470e+308
-#define FLT_MAX		((float)3.40282346638528860e+38)
-#endif
-
-#if !defined(HAVE_ISINF) && !defined(isinf)
-#define isinf(X)    0
-#endif
-
-/* Define missing math constants. */
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-#ifndef M_E
-#define M_E 2.7182818284590452354
-#endif
-#ifndef M_LN2
-#define M_LN2 0.69314718055994530942
-#endif
-
-/*
-  Max size that must be added to a so that we know Size to make
-  adressable obj.
-*/
-#if SIZEOF_CHARP == 4
-typedef long		my_ptrdiff_t;
-#else
-typedef long long	my_ptrdiff_t;
-#endif
-
-#define MY_ALIGN(A,L)	(((A) + (L) - 1) & ~((L) - 1))
-#define ALIGN_SIZE(A)	MY_ALIGN((A),sizeof(double))
-/* Size to make adressable obj. */
-#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
-			 /* Offset of field f in structure t */
-#define OFFSET(t, f)	((size_t)(char *)&((t *)0)->f)
-#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
-#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
-
-#define NullS		(char *) 0
-/* Nowdays we do not support MessyDos */
-#ifndef NEAR
-#define NEAR				/* Who needs segments ? */
-#define FAR				/* On a good machine */
-#ifndef HUGE_PTR
-#define HUGE_PTR
-#endif
-#endif
-#if defined(__IBMC__) || defined(__IBMCPP__)
-/* This was  _System _Export but caused a lot of warnings on _AIX43 */
-#define STDCALL
-#elif !defined( STDCALL)
-#define STDCALL
-#endif
-
-/* Typdefs for easyier portability */
-
-#if defined(VOIDTYPE)
-typedef void	*gptr;		/* Generic pointer */
-#else
-typedef char	*gptr;		/* Generic pointer */
-#endif
-#ifndef HAVE_INT_8_16_32
-typedef signed char int8;       /* Signed integer >= 8  bits */
-typedef short	int16;		/* Signed integer >= 16 bits */
-#endif
-#ifndef HAVE_UCHAR
-typedef unsigned char	uchar;	/* Short for unsigned char */
-#endif
-typedef unsigned char	uint8;	/* Short for unsigned integer >= 8  bits */
-typedef unsigned short	uint16; /* Short for unsigned integer >= 16 bits */
-
-#if SIZEOF_INT == 4
-#ifndef HAVE_INT_8_16_32
-typedef int		int32;
-#endif
-typedef unsigned int	uint32; /* Short for unsigned integer >= 32 bits */
-#elif SIZEOF_LONG == 4
-#ifndef HAVE_INT_8_16_32
-typedef long		int32;
-#endif
-typedef unsigned long	uint32; /* Short for unsigned integer >= 32 bits */
-#else
-#error "Neither int or long is of 4 bytes width"
-#endif
-
-#if !defined(HAVE_ULONG) && !defined(TARGET_OS_LINUX) && !defined(__USE_MISC)
-typedef unsigned long	ulong;		  /* Short for unsigned long */
-#endif
-#ifndef longlong_defined
-#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8
-typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
-typedef long long int	longlong;
-#else
-typedef unsigned long	ulonglong;	  /* ulong or unsigned long long */
-typedef long		longlong;
-#endif
-#endif
-
-#if defined(NO_CLIENT_LONG_LONG)
-typedef unsigned long my_ulonglong;
-#elif defined (__WIN__)
-typedef unsigned __int64 my_ulonglong;
-#else
-typedef unsigned long long my_ulonglong;
-#endif
-
-#ifdef USE_RAID
-/*
-  The following is done with a if to not get problems with pre-processors
-  with late define evaluation
-*/
-#if SIZEOF_OFF_T == 4
-#define SYSTEM_SIZEOF_OFF_T 4
-#else
-#define SYSTEM_SIZEOF_OFF_T 8
-#endif
-#undef  SIZEOF_OFF_T
-#define SIZEOF_OFF_T	    8
-#else
-#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
-#endif /* USE_RAID */
-
-#if SIZEOF_OFF_T > 4
-typedef ulonglong my_off_t;
-#else
-typedef unsigned long my_off_t;
-#endif
-#define MY_FILEPOS_ERROR	(~(my_off_t) 0)
-#if !defined(__WIN__) && !defined(OS2)
-typedef off_t os_off_t;
-#endif
-
-#if defined(__WIN__)
-#define socket_errno	WSAGetLastError()
-#define SOCKET_EINTR	WSAEINTR
-#define SOCKET_EAGAIN	WSAEINPROGRESS
-#define SOCKET_ETIMEDOUT WSAETIMEDOUT
-#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
-#define SOCKET_EADDRINUSE WSAEADDRINUSE
-#define SOCKET_ENFILE	ENFILE
-#define SOCKET_EMFILE	EMFILE
-#elif defined(OS2)
-#define socket_errno	sock_errno()
-#define SOCKET_EINTR	SOCEINTR
-#define SOCKET_EAGAIN	SOCEINPROGRESS
-#define SOCKET_ETIMEDOUT SOCKET_EINTR
-#define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK
-#define SOCKET_EADDRINUSE SOCEADDRINUSE
-#define SOCKET_ENFILE	SOCENFILE
-#define SOCKET_EMFILE	SOCEMFILE
-#define closesocket(A)	soclose(A)
-#else /* Unix */
-#define socket_errno	errno
-#define closesocket(A)	close(A)
-#define SOCKET_EINTR	EINTR
-#define SOCKET_EAGAIN	EAGAIN
-#define SOCKET_ETIMEDOUT SOCKET_EINTR
-#define SOCKET_EWOULDBLOCK EWOULDBLOCK
-#define SOCKET_EADDRINUSE EADDRINUSE
-#define SOCKET_ENFILE	ENFILE
-#define SOCKET_EMFILE	EMFILE
-#endif
-
-typedef uint8		int7;	/* Most effective integer 0 <= x <= 127 */
-typedef short		int15;	/* Most effective integer 0 <= x <= 32767 */
-typedef char		*my_string; /* String of characters */
-typedef unsigned long	size_s; /* Size of strings (In string-funcs) */
-typedef int		myf;	/* Type of MyFlags in my_funcs */
-#ifndef byte_defined
-typedef char		byte;	/* Smallest addressable unit */
-#endif
-typedef char		my_bool; /* Small bool */
-#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
-typedef char		bool;	/* Ordinary boolean values 0 1 */
-#endif
-	/* Macros for converting *constants* to the right type */
-#define INT8(v)		(int8) (v)
-#define INT16(v)	(int16) (v)
-#define INT32(v)	(int32) (v)
-#define MYF(v)		(myf) (v)
-
-#ifndef LL
-#ifdef HAVE_LONG_LONG
-#define LL(A) A ## LL
-#else
-#define LL(A) A ## L
-#endif
-#endif
-
-#ifndef ULL
-#ifdef HAVE_LONG_LONG
-#define ULL(A) A ## ULL
-#else
-#define ULL(A) A ## UL
-#endif
-#endif
-
-/*
-  Defines to make it possible to prioritize register assignments. No
-  longer that important with modern compilers.
-*/
-#ifndef USING_X
-#define reg1 register
-#define reg2 register
-#define reg3 register
-#define reg4 register
-#define reg5 register
-#define reg6 register
-#define reg7 register
-#define reg8 register
-#define reg9 register
-#define reg10 register
-#define reg11 register
-#define reg12 register
-#define reg13 register
-#define reg14 register
-#define reg15 register
-#define reg16 register
-#endif
-
-/*
-  Sometimes we want to make sure that the variable is not put into
-  a register in debugging mode so we can see its value in the core
-*/
-
-#ifndef DBUG_OFF
-#define dbug_volatile volatile
-#else
-#define dbug_volatile
-#endif
-
-/* Defines for time function */
-#define SCALE_SEC	100
-#define SCALE_USEC	10000
-#define MY_HOW_OFTEN_TO_ALARM	2	/* How often we want info on screen */
-#define MY_HOW_OFTEN_TO_WRITE	1000	/* How often we want info on screen */
-
-#ifdef HAVE_TIMESPEC_TS_SEC
-#ifndef set_timespec
-#define set_timespec(ABSTIME,SEC) \
-{ \
-  (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \
-  (ABSTIME).ts_nsec=0; \
-}
-#endif /* !set_timespec */
-#ifndef set_timespec_nsec
-#define set_timespec_nsec(ABSTIME,NSEC) \
-{ \
-  ulonglong now= my_getsystime() + (NSEC/100); \
-  (ABSTIME).ts_sec=  (now / ULL(10000000)); \
-  (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
-}
-#endif /* !set_timespec_nsec */
-#else
-#ifndef set_timespec
-#define set_timespec(ABSTIME,SEC) \
-{\
-  struct timeval tv;\
-  gettimeofday(&tv,0);\
-  (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
-  (ABSTIME).tv_nsec=tv.tv_usec*1000;\
-}
-#endif /* !set_timespec */
-#ifndef set_timespec_nsec
-#define set_timespec_nsec(ABSTIME,NSEC) \
-{\
-  ulonglong now= my_getsystime() + (NSEC/100); \
-  (ABSTIME).tv_sec=  (now / ULL(10000000)); \
-  (ABSTIME).tv_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100));    \
-}
-#endif /* !set_timespec_nsec */
-#endif /* HAVE_TIMESPEC_TS_SEC */
-
-/*
-  Define-funktions for reading and storing in machine independent format
-  (low byte first)
-*/
-
-/* Optimized store functions for Intel x86 */
-#if defined(__i386__) && !defined(_WIN64)
-#define sint2korr(A)	(*((int16 *) (A)))
-#define sint3korr(A)	((int32) ((((uchar) (A)[2]) & 128) ? \
-				  (((uint32) 255L << 24) | \
-				   (((uint32) (uchar) (A)[2]) << 16) |\
-				   (((uint32) (uchar) (A)[1]) << 8) | \
-				   ((uint32) (uchar) (A)[0])) : \
-				  (((uint32) (uchar) (A)[2]) << 16) |\
-				  (((uint32) (uchar) (A)[1]) << 8) | \
-				  ((uint32) (uchar) (A)[0])))
-#define sint4korr(A)	(*((long *) (A)))
-#define uint2korr(A)	(*((uint16 *) (A)))
-#ifdef HAVE_purify
-#define uint3korr(A)	(uint32) (((uint32) ((uchar) (A)[0])) +\
-				  (((uint32) ((uchar) (A)[1])) << 8) +\
-				  (((uint32) ((uchar) (A)[2])) << 16))
-#else
-/*
-   ATTENTION !
-   
-    Please, note, uint3korr reads 4 bytes (not 3) !
-    It means, that you have to provide enough allocated space !
-*/
-#define uint3korr(A)	(long) (*((unsigned int *) (A)) & 0xFFFFFF)
-#endif
-#define uint4korr(A)	(*((unsigned long *) (A)))
-#define uint5korr(A)	((ulonglong)(((uint32) ((uchar) (A)[0])) +\
-				    (((uint32) ((uchar) (A)[1])) << 8) +\
-				    (((uint32) ((uchar) (A)[2])) << 16) +\
-				    (((uint32) ((uchar) (A)[3])) << 24)) +\
-				    (((ulonglong) ((uchar) (A)[4])) << 32))
-#define uint8korr(A)	(*((ulonglong *) (A)))
-#define sint8korr(A)	(*((longlong *) (A)))
-#define int2store(T,A)	*((uint16*) (T))= (uint16) (A)
-#define int3store(T,A)  do { *(T)=  (uchar) ((A));\
-                            *(T+1)=(uchar) (((uint) (A) >> 8));\
-                            *(T+2)=(uchar) (((A) >> 16)); } while (0)
-#define int4store(T,A)	*((long *) (T))= (long) (A)
-#define int5store(T,A)  do { *(T)= (uchar)((A));\
-                             *((T)+1)=(uchar) (((A) >> 8));\
-                             *((T)+2)=(uchar) (((A) >> 16));\
-                             *((T)+3)=(uchar) (((A) >> 24)); \
-                             *((T)+4)=(uchar) (((A) >> 32)); } while(0)
-#define int8store(T,A)	*((ulonglong *) (T))= (ulonglong) (A)
-
-typedef union {
-  double v;
-  long m[2];
-} doubleget_union;
-#define doubleget(V,M)	\
-do { doubleget_union _tmp; \
-     _tmp.m[0] = *((long*)(M)); \
-     _tmp.m[1] = *(((long*) (M))+1); \
-     (V) = _tmp.v; } while(0)
-#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
-			     *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
-                         } while (0)
-#define float4get(V,M) do { *((long *) &(V)) = *((long*) (M)); } while(0)
-#define float8get(V,M) doubleget((V),(M))
-#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
-#define floatstore(T,V)  memcpy((byte*)(T), (byte*)(&V),sizeof(float))
-#define floatget(V,M)    memcpy((byte*) &V,(byte*) (M),sizeof(float))
-#define float8store(V,M) doublestore((V),(M))
-#endif /* __i386__ */
-
-#ifndef sint2korr
-/*
-  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
-  were done before)
-*/
-#define sint2korr(A)	(int16) (((int16) ((uchar) (A)[0])) +\
-				 ((int16) ((int16) (A)[1]) << 8))
-#define sint3korr(A)	((int32) ((((uchar) (A)[2]) & 128) ? \
-				  (((uint32) 255L << 24) | \
-				   (((uint32) (uchar) (A)[2]) << 16) |\
-				   (((uint32) (uchar) (A)[1]) << 8) | \
-				   ((uint32) (uchar) (A)[0])) : \
-				  (((uint32) (uchar) (A)[2]) << 16) |\
-				  (((uint32) (uchar) (A)[1]) << 8) | \
-				  ((uint32) (uchar) (A)[0])))
-#define sint4korr(A)	(int32) (((int32) ((uchar) (A)[0])) +\
-				(((int32) ((uchar) (A)[1]) << 8)) +\
-				(((int32) ((uchar) (A)[2]) << 16)) +\
-				(((int32) ((int16) (A)[3]) << 24)))
-#define sint8korr(A)	(longlong) uint8korr(A)
-#define uint2korr(A)	(uint16) (((uint16) ((uchar) (A)[0])) +\
-				  ((uint16) ((uchar) (A)[1]) << 8))
-#define uint3korr(A)	(uint32) (((uint32) ((uchar) (A)[0])) +\
-				  (((uint32) ((uchar) (A)[1])) << 8) +\
-				  (((uint32) ((uchar) (A)[2])) << 16))
-#define uint4korr(A)	(uint32) (((uint32) ((uchar) (A)[0])) +\
-				  (((uint32) ((uchar) (A)[1])) << 8) +\
-				  (((uint32) ((uchar) (A)[2])) << 16) +\
-				  (((uint32) ((uchar) (A)[3])) << 24))
-#define uint5korr(A)	((ulonglong)(((uint32) ((uchar) (A)[0])) +\
-				    (((uint32) ((uchar) (A)[1])) << 8) +\
-				    (((uint32) ((uchar) (A)[2])) << 16) +\
-				    (((uint32) ((uchar) (A)[3])) << 24)) +\
-				    (((ulonglong) ((uchar) (A)[4])) << 32))
-#define uint8korr(A)	((ulonglong)(((uint32) ((uchar) (A)[0])) +\
-				    (((uint32) ((uchar) (A)[1])) << 8) +\
-				    (((uint32) ((uchar) (A)[2])) << 16) +\
-				    (((uint32) ((uchar) (A)[3])) << 24)) +\
-			(((ulonglong) (((uint32) ((uchar) (A)[4])) +\
-				    (((uint32) ((uchar) (A)[5])) << 8) +\
-				    (((uint32) ((uchar) (A)[6])) << 16) +\
-				    (((uint32) ((uchar) (A)[7])) << 24))) <<\
-				    32))
-#define int2store(T,A)       do { uint def_temp= (uint) (A) ;\
-                                  *((uchar*) (T))=  (uchar)(def_temp); \
-                                   *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
-                             } while(0)
-#define int3store(T,A)       do { /*lint -save -e734 */\
-                                  *((uchar*)(T))=(uchar) ((A));\
-                                  *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
-                                  *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
-                                  /*lint -restore */} while(0)
-#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
-                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
-                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
-                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
-#define int5store(T,A)       do { *((char *)(T))=((A));\
-                                  *(((char *)(T))+1)=(((A) >> 8));\
-                                  *(((char *)(T))+2)=(((A) >> 16));\
-                                  *(((char *)(T))+3)=(((A) >> 24)); \
-                                  *(((char *)(T))+4)=(((A) >> 32)); } while(0)
-#define int8store(T,A)       do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
-                                  int4store((T),def_temp); \
-                                  int4store((T+4),def_temp2); } while(0)
-#ifdef WORDS_BIGENDIAN
-#define float4store(T,A) do { *(T)= ((byte *) &A)[3];\
-                              *((T)+1)=(char) ((byte *) &A)[2];\
-                              *((T)+2)=(char) ((byte *) &A)[1];\
-                              *((T)+3)=(char) ((byte *) &A)[0]; } while(0)
-
-#define float4get(V,M)   do { float def_temp;\
-                              ((byte*) &def_temp)[0]=(M)[3];\
-                              ((byte*) &def_temp)[1]=(M)[2];\
-                              ((byte*) &def_temp)[2]=(M)[1];\
-                              ((byte*) &def_temp)[3]=(M)[0];\
-                              (V)=def_temp; } while(0)
-#define float8store(T,V) do { *(T)= ((byte *) &V)[7];\
-                              *((T)+1)=(char) ((byte *) &V)[6];\
-                              *((T)+2)=(char) ((byte *) &V)[5];\
-                              *((T)+3)=(char) ((byte *) &V)[4];\
-                              *((T)+4)=(char) ((byte *) &V)[3];\
-                              *((T)+5)=(char) ((byte *) &V)[2];\
-                              *((T)+6)=(char) ((byte *) &V)[1];\
-                              *((T)+7)=(char) ((byte *) &V)[0]; } while(0)
-
-#define float8get(V,M)   do { double def_temp;\
-                              ((byte*) &def_temp)[0]=(M)[7];\
-                              ((byte*) &def_temp)[1]=(M)[6];\
-                              ((byte*) &def_temp)[2]=(M)[5];\
-                              ((byte*) &def_temp)[3]=(M)[4];\
-                              ((byte*) &def_temp)[4]=(M)[3];\
-                              ((byte*) &def_temp)[5]=(M)[2];\
-                              ((byte*) &def_temp)[6]=(M)[1];\
-                              ((byte*) &def_temp)[7]=(M)[0];\
-                              (V) = def_temp; } while(0)
-#else
-#define float4get(V,M)   memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
-#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
-
-#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
-#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\
-                              *(((char*)T)+1)=(char) ((byte *) &V)[5];\
-                              *(((char*)T)+2)=(char) ((byte *) &V)[6];\
-                              *(((char*)T)+3)=(char) ((byte *) &V)[7];\
-                              *(((char*)T)+4)=(char) ((byte *) &V)[0];\
-                              *(((char*)T)+5)=(char) ((byte *) &V)[1];\
-                              *(((char*)T)+6)=(char) ((byte *) &V)[2];\
-                              *(((char*)T)+7)=(char) ((byte *) &V)[3]; }\
-                         while(0)
-#define doubleget(V,M)   do { double def_temp;\
-                              ((byte*) &def_temp)[0]=(M)[4];\
-                              ((byte*) &def_temp)[1]=(M)[5];\
-                              ((byte*) &def_temp)[2]=(M)[6];\
-                              ((byte*) &def_temp)[3]=(M)[7];\
-                              ((byte*) &def_temp)[4]=(M)[0];\
-                              ((byte*) &def_temp)[5]=(M)[1];\
-                              ((byte*) &def_temp)[6]=(M)[2];\
-                              ((byte*) &def_temp)[7]=(M)[3];\
-                              (V) = def_temp; } while(0)
-#endif /* __FLOAT_WORD_ORDER */
-
-#define float8get(V,M)   doubleget((V),(M))
-#define float8store(V,M) doublestore((V),(M))
-#endif /* WORDS_BIGENDIAN */
-
-#endif /* sint2korr */
-
-/*
-  Macro for reading 32-bit integer from network byte order (big-endian)
-  from unaligned memory location.
-*/
-#define int4net(A)        (int32) (((uint32) ((uchar) (A)[3]))        |\
-				  (((uint32) ((uchar) (A)[2])) << 8)  |\
-				  (((uint32) ((uchar) (A)[1])) << 16) |\
-				  (((uint32) ((uchar) (A)[0])) << 24))
-/*
-  Define-funktions for reading and storing in machine format from/to
-  short/long to/from some place in memory V should be a (not
-  register) variable, M is a pointer to byte
-*/
-
-#ifdef WORDS_BIGENDIAN
-
-#define ushortget(V,M)  do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
-                                 ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
-#define shortget(V,M)   do { V = (short) (((short) ((uchar) (M)[1]))+\
-                                 ((short) ((short) (M)[0]) << 8)); } while(0)
-#define longget(V,M)    do { int32 def_temp;\
-                             ((byte*) &def_temp)[0]=(M)[0];\
-                             ((byte*) &def_temp)[1]=(M)[1];\
-                             ((byte*) &def_temp)[2]=(M)[2];\
-                             ((byte*) &def_temp)[3]=(M)[3];\
-                             (V)=def_temp; } while(0)
-#define ulongget(V,M)   do { uint32 def_temp;\
-                            ((byte*) &def_temp)[0]=(M)[0];\
-                            ((byte*) &def_temp)[1]=(M)[1];\
-                            ((byte*) &def_temp)[2]=(M)[2];\
-                            ((byte*) &def_temp)[3]=(M)[3];\
-                            (V)=def_temp; } while(0)
-#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
-                             *(((char*)T)+1)=(char)(def_temp); \
-                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
-#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
-                             *(((char*)T)+2)=(((A) >> 8));\
-                             *(((char*)T)+1)=(((A) >> 16));\
-                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
-
-#define floatget(V,M)    memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
-#define floatstore(T,V)  memcpy_fixed((byte*) (T),(byte*)(&V),sizeof(float))
-#define doubleget(V,M)	 memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
-#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
-#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
-#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
-
-#else
-
-#define ushortget(V,M)	do { V = uint2korr(M); } while(0)
-#define shortget(V,M)	do { V = sint2korr(M); } while(0)
-#define longget(V,M)	do { V = sint4korr(M); } while(0)
-#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
-#define shortstore(T,V) int2store(T,V)
-#define longstore(T,V)	int4store(T,V)
-#ifndef floatstore
-#define floatstore(T,V)  memcpy_fixed((byte*) (T),(byte*) (&V),sizeof(float))
-#define floatget(V,M)    memcpy_fixed((byte*) &V, (byte*) (M), sizeof(float))
-#endif
-#ifndef doubleget
-#define doubleget(V,M)	 memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
-#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
-#endif /* doubleget */
-#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
-#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
-
-#endif /* WORDS_BIGENDIAN */
-
-/* sprintf does not always return the number of bytes :- */
-#ifdef SPRINTF_RETURNS_INT
-#define my_sprintf(buff,args) sprintf args
-#else
-#ifdef SPRINTF_RETURNS_PTR
-#define my_sprintf(buff,args) ((int)(sprintf args - buff))
-#else
-#define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff))
-#endif
-#endif
-
-#ifndef THREAD
-#define thread_safe_increment(V,L) (V)++
-#define thread_safe_add(V,C,L)     (V)+=(C)
-#define thread_safe_sub(V,C,L)     (V)-=(C)
-#define statistic_increment(V,L)   (V)++
-#define statistic_add(V,C,L)       (V)+=(C)
-#endif
-
-#ifdef HAVE_CHARSET_utf8
-#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
-#else
-#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
-#endif
-
-#if defined(EMBEDDED_LIBRARY) && !defined(HAVE_EMBEDDED_PRIVILEGE_CONTROL)
-#define NO_EMBEDDED_ACCESS_CHECKS
-#endif
-
-#endif /* my_global_h */
diff --git a/3rdparty/mysql/include/my_list.h b/3rdparty/mysql/include/my_list.h
deleted file mode 100644
index 92598696f..000000000
--- a/3rdparty/mysql/include/my_list.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#ifndef _list_h_
-#define _list_h_
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-typedef struct st_list {
-  struct st_list *prev,*next;
-  void *data;
-} LIST;
-
-typedef int (*list_walk_action)(void *,void *);
-
-extern LIST *list_add(LIST *root,LIST *element);
-extern LIST *list_delete(LIST *root,LIST *element);
-extern LIST *list_cons(void *data,LIST *root);
-extern LIST *list_reverse(LIST *root);
-extern void list_free(LIST *root,unsigned int free_data);
-extern unsigned int list_length(LIST *);
-extern int list_walk(LIST *,list_walk_action action,gptr argument);
-
-#define list_rest(a) ((a)->next)
-#define list_push(a,b) (a)=list_cons((b),(a))
-#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); }
-
-#ifdef	__cplusplus
-}
-#endif
-#endif
diff --git a/3rdparty/mysql/include/my_pthread.h b/3rdparty/mysql/include/my_pthread.h
deleted file mode 100644
index 202e047dc..000000000
--- a/3rdparty/mysql/include/my_pthread.h
+++ /dev/null
@@ -1,717 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/* Defines to make different thread packages compatible */
-
-#ifndef _my_pthread_h
-#define _my_pthread_h
-
-#include <errno.h>
-#ifndef ETIME
-#define ETIME ETIMEDOUT				/* For FreeBSD */
-#endif
-
-#ifdef  __cplusplus
-#define EXTERNC extern "C"
-extern "C" {
-#else
-#define EXTERNC
-#endif /* __cplusplus */ 
-
-#if defined(__WIN__) || defined(OS2)
-
-#ifdef OS2
-typedef ULONG     HANDLE;
-typedef ULONG     DWORD;
-typedef int sigset_t;
-#endif
-
-#ifdef OS2
-typedef HMTX             pthread_mutex_t;
-#else
-typedef CRITICAL_SECTION pthread_mutex_t;
-#endif
-typedef HANDLE		 pthread_t;
-typedef struct thread_attr {
-    DWORD dwStackSize ;
-    DWORD dwCreatingFlag ;
-    int priority ;
-} pthread_attr_t ;
-
-typedef struct { int dummy; } pthread_condattr_t;
-
-/* Implementation of posix conditions */
-
-typedef struct st_pthread_link {
-  DWORD thread_id;
-  struct st_pthread_link *next;
-} pthread_link;
-
-typedef struct {
-  uint32 waiting;
-#ifdef OS2
-  HEV    semaphore;
-#else
-  HANDLE semaphore;
-#endif
-} pthread_cond_t;
-
-
-#ifndef OS2
-struct timespec {		/* For pthread_cond_timedwait() */
-    time_t tv_sec;
-    long tv_nsec;
-};
-#endif
-
-typedef int pthread_mutexattr_t;
-#define win_pthread_self my_thread_var->pthread_self
-#ifdef OS2
-#define pthread_handler_t EXTERNC void * _Optlink
-typedef void * (_Optlink *pthread_handler)(void *);
-#else
-#define pthread_handler_t EXTERNC void * __cdecl
-typedef void * (__cdecl *pthread_handler)(void *);
-#endif
-
-void win_pthread_init(void);
-int win_pthread_setspecific(void *A,void *B,uint length);
-int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
-int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
-int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
-int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
-			   struct timespec *abstime);
-int pthread_cond_signal(pthread_cond_t *cond);
-int pthread_cond_broadcast(pthread_cond_t *cond);
-int pthread_cond_destroy(pthread_cond_t *cond);
-int pthread_attr_init(pthread_attr_t *connect_att);
-int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
-int pthread_attr_setprio(pthread_attr_t *connect_att,int priority);
-int pthread_attr_destroy(pthread_attr_t *connect_att);
-struct tm *localtime_r(const time_t *timep,struct tm *tmp);
-struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
-
-
-void pthread_exit(void *a);	 /* was #define pthread_exit(A) ExitThread(A)*/
-
-#ifndef OS2
-#define ETIMEDOUT 145		    /* Win32 doesn't have this */
-#define getpid() GetCurrentThreadId()
-#endif
-#define pthread_self() win_pthread_self
-#define HAVE_LOCALTIME_R		1
-#define _REENTRANT			1
-#define HAVE_PTHREAD_ATTR_SETSTACKSIZE	1
-
-#ifdef USE_TLS					/* For LIBMYSQL.DLL */
-#undef SAFE_MUTEX				/* This will cause conflicts */
-#define pthread_key(T,V)  DWORD V
-#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
-#define pthread_key_delete(A) TlsFree(A)
-#define pthread_getspecific(A) (TlsGetValue(A))
-#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
-#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V))
-#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
-#define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
-#else
-#define pthread_key(T,V) __declspec(thread) T V
-#define pthread_key_create(A,B) pthread_dummy(0)
-#define pthread_key_delete(A) pthread_dummy(0)
-#define pthread_getspecific(A) (&(A))
-#define my_pthread_getspecific(T,A) (&(A))
-#define my_pthread_getspecific_ptr(T,V) (V)
-#define my_pthread_setspecific_ptr(T,V) ((T)=(V),0)
-#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A))
-#endif /* USE_TLS */
-
-#define pthread_equal(A,B) ((A) == (B))
-#ifdef OS2
-extern int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *);
-extern int pthread_mutex_lock (pthread_mutex_t *);
-extern int pthread_mutex_unlock (pthread_mutex_t *);
-extern int pthread_mutex_destroy (pthread_mutex_t *);
-#define my_pthread_setprio(A,B)  DosSetPriority(PRTYS_THREAD,PRTYC_NOCHANGE, B, A)
-#define pthread_kill(A,B) raise(B)
-#define pthread_exit(A) pthread_dummy()
-#else
-#define pthread_mutex_init(A,B)  (InitializeCriticalSection(A),0)
-#define pthread_mutex_lock(A)	 (EnterCriticalSection(A),0)
-#define pthread_mutex_trylock(A) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT)
-#define pthread_mutex_unlock(A)  LeaveCriticalSection(A)
-#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
-#define my_pthread_setprio(A,B)  SetThreadPriority(GetCurrentThread(), (B))
-#define pthread_kill(A,B) pthread_dummy(0)
-#endif /* OS2 */
-
-/* Dummy defines for easier code */
-#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
-#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B)
-#define pthread_attr_setscope(A,B)
-#define pthread_detach_this_thread()
-#define pthread_condattr_init(A)
-#define pthread_condattr_destroy(A)
-
-/*Irena: compiler does not like this: */
-/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */
-#define my_pthread_getprio(thread_id) pthread_dummy(0)
-
-#elif defined(HAVE_UNIXWARE7_THREADS)
-
-#include <thread.h>
-#include <synch.h>
-
-#ifndef _REENTRANT
-#define _REENTRANT
-#endif
-
-#define HAVE_NONPOSIX_SIGWAIT
-#define pthread_t thread_t
-#define pthread_cond_t cond_t
-#define pthread_mutex_t mutex_t
-#define pthread_key_t thread_key_t
-typedef int pthread_attr_t;			/* Needed by Unixware 7.0.0 */
-
-#define pthread_key_create(A,B) thr_keycreate((A),(B))
-#define pthread_key_delete(A) thr_keydelete(A)
-
-#define pthread_handler_t EXTERNC void *
-#define pthread_key(T,V) pthread_key_t V
-
-void *	my_pthread_getspecific_imp(pthread_key_t key);
-#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
-#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,V)
-
-#define pthread_setspecific(A,B) thr_setspecific(A,B)
-#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,V)
-
-#define pthread_create(A,B,C,D) thr_create(NULL,65536L,(C),(D),THR_DETACHED,(A))
-#define pthread_cond_init(a,b) cond_init((a),USYNC_THREAD,NULL)
-#define pthread_cond_destroy(a) cond_destroy(a)
-#define pthread_cond_signal(a) cond_signal(a)
-#define pthread_cond_wait(a,b) cond_wait((a),(b))
-#define pthread_cond_timedwait(a,b,c) cond_timedwait((a),(b),(c))
-#define pthread_cond_broadcast(a) cond_broadcast(a)
-
-#define pthread_mutex_init(a,b) mutex_init((a),USYNC_THREAD,NULL)
-#define pthread_mutex_lock(a) mutex_lock(a)
-#define pthread_mutex_unlock(a) mutex_unlock(a)
-#define pthread_mutex_destroy(a) mutex_destroy(a)
-
-#define pthread_self() thr_self()
-#define pthread_exit(A) thr_exit(A)
-#define pthread_equal(A,B) (((A) == (B)) ? 1 : 0)
-#define pthread_kill(A,B) thr_kill((A),(B))
-#define HAVE_PTHREAD_KILL
-
-#define pthread_sigmask(A,B,C) thr_sigsetmask((A),(B),(C))
-
-extern int my_sigwait(const sigset_t *set,int *sig);
-
-#define pthread_detach_this_thread() pthread_dummy(0)
-
-#define pthread_attr_init(A) pthread_dummy(0)
-#define pthread_attr_destroy(A) pthread_dummy(0)
-#define pthread_attr_setscope(A,B) pthread_dummy(0)
-#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
-#define my_pthread_setprio(A,B) pthread_dummy (0)
-#define my_pthread_getprio(A) pthread_dummy (0)
-#define my_pthread_attr_setprio(A,B) pthread_dummy(0)
-
-#else /* Normal threads */
-
-#ifdef HAVE_rts_threads
-#define sigwait org_sigwait
-#include <signal.h>
-#undef sigwait
-#endif
-#include <pthread.h>
-#ifndef _REENTRANT
-#define _REENTRANT
-#endif
-#ifdef HAVE_THR_SETCONCURRENCY
-#include <thread.h>			/* Probably solaris */
-#endif
-#ifdef HAVE_SCHED_H
-#include <sched.h>
-#endif
-#ifdef HAVE_SYNCH_H
-#include <synch.h>
-#endif
-#if defined(__EMX__) && (!defined(EMX_PTHREAD_REV) || (EMX_PTHREAD_REV < 2))
-#error Requires at least rev 2 of EMX pthreads library.
-#endif
-
-#ifdef __NETWARE__
-void my_pthread_exit(void *status);
-#define pthread_exit(A) my_pthread_exit(A)
-#endif
-
-extern int my_pthread_getprio(pthread_t thread_id);
-
-#define pthread_key(T,V) pthread_key_t V
-#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V))
-#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V))
-#define pthread_detach_this_thread()
-#define pthread_handler_t EXTERNC void *
-typedef void *(* pthread_handler)(void *);
-
-/* Test first for RTS or FSU threads */
-
-#if defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM)
-#define HAVE_rts_threads
-extern int my_pthread_create_detached;
-#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
-#define PTHREAD_CREATE_DETACHED &my_pthread_create_detached
-#define PTHREAD_SCOPE_SYSTEM  PTHREAD_SCOPE_GLOBAL
-#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL
-#define USE_ALARM_THREAD
-#elif defined(HAVE_mit_thread)
-#define USE_ALARM_THREAD
-#undef	HAVE_LOCALTIME_R
-#define HAVE_LOCALTIME_R
-#undef	HAVE_GMTIME_R
-#define HAVE_GMTIME_R
-#undef	HAVE_PTHREAD_ATTR_SETSCOPE
-#define HAVE_PTHREAD_ATTR_SETSCOPE
-#undef HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE	/* If we are running linux */
-#undef HAVE_RWLOCK_T
-#undef HAVE_RWLOCK_INIT
-#undef HAVE_PTHREAD_RWLOCK_RDLOCK
-#undef HAVE_SNPRINTF
-
-#define my_pthread_attr_setprio(A,B)
-#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
-
-#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199910
-int sigwait(sigset_t *set, int *sig);
-#endif
-
-#ifndef HAVE_NONPOSIX_SIGWAIT
-#define my_sigwait(A,B) sigwait((A),(B))
-#else
-int my_sigwait(const sigset_t *set,int *sig);
-#endif
-
-#ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT
-#ifndef SAFE_MUTEX
-#define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b))
-extern int my_pthread_mutex_init(pthread_mutex_t *mp,
-				 const pthread_mutexattr_t *attr);
-#endif /* SAFE_MUTEX */
-#define pthread_cond_init(a,b) my_pthread_cond_init((a),(b))
-extern int my_pthread_cond_init(pthread_cond_t *mp,
-				const pthread_condattr_t *attr);
-#endif /* HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */
-
-#if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK)
-#define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C))
-#endif
-
-#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
-int sigwait(sigset_t *setp, int *sigp);		/* Use our implemention */
-#endif
-
-
-/*
-  We define my_sigset() and use that instead of the system sigset() so that
-  we can favor an implementation based on sigaction(). On some systems, such
-  as Mac OS X, sigset() results in flags such as SA_RESTART being set, and
-  we want to make sure that no such flags are set.
-*/
-#if defined(HAVE_SIGACTION) && !defined(my_sigset)
-#define my_sigset(A,B) do { struct sigaction s; sigset_t set;              \
-                            sigemptyset(&set);                             \
-                            s.sa_handler = (B);                            \
-                            s.sa_mask    = set;                            \
-                            s.sa_flags   = 0;                              \
-                            sigaction((A), &s, (struct sigaction *) NULL); \
-                          } while (0)
-#elif defined(HAVE_SIGSET) && !defined(my_sigset)
-#define my_sigset(A,B) sigset((A),(B))
-#elif !defined(my_sigset)
-#define my_sigset(A,B) signal((A),(B))
-#endif
-
-#ifndef my_pthread_setprio
-#if defined(HAVE_PTHREAD_SETPRIO_NP)		/* FSU threads */
-#define my_pthread_setprio(A,B) pthread_setprio_np((A),(B))
-#elif defined(HAVE_PTHREAD_SETPRIO)
-#define my_pthread_setprio(A,B) pthread_setprio((A),(B))
-#else
-extern void my_pthread_setprio(pthread_t thread_id,int prior);
-#endif
-#endif
-
-#ifndef my_pthread_attr_setprio
-#ifdef HAVE_PTHREAD_ATTR_SETPRIO
-#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B))
-#else
-extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority);
-#endif
-#endif
-
-#if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS)
-#define pthread_attr_setscope(A,B)
-#undef	HAVE_GETHOSTBYADDR_R			/* No definition */
-#endif
-
-#if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) && !defined(SAFE_MUTEX)
-extern int my_pthread_cond_timedwait(pthread_cond_t *cond,
-				     pthread_mutex_t *mutex,
-				     struct timespec *abstime);
-#define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C))
-#endif
-
-#if defined(OS2)
-#define my_pthread_getspecific(T,A) ((T) &(A))
-#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A))
-#elif !defined( HAVE_NONPOSIX_PTHREAD_GETSPECIFIC)
-#define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B))
-#else
-#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
-void *my_pthread_getspecific_imp(pthread_key_t key);
-#endif /* OS2 */
-
-#ifndef HAVE_LOCALTIME_R
-struct tm *localtime_r(const time_t *clock, struct tm *res);
-#endif
-
-#ifndef HAVE_GMTIME_R
-struct tm *gmtime_r(const time_t *clock, struct tm *res);
-#endif
-
-#ifdef HAVE_PTHREAD_CONDATTR_CREATE
-/* DCE threads on HPUX 10.20 */
-#define pthread_condattr_init pthread_condattr_create
-#define pthread_condattr_destroy pthread_condattr_delete
-#endif
-
-/* FSU THREADS */
-#if !defined(HAVE_PTHREAD_KEY_DELETE) && !defined(pthread_key_delete)
-#define pthread_key_delete(A) pthread_dummy(0)
-#endif
-
-#ifdef HAVE_CTHREADS_WRAPPER			/* For MacOSX */
-#define pthread_cond_destroy(A) pthread_dummy(0)
-#define pthread_mutex_destroy(A) pthread_dummy(0)
-#define pthread_attr_delete(A) pthread_dummy(0)
-#define pthread_condattr_delete(A) pthread_dummy(0)
-#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
-#define pthread_equal(A,B) ((A) == (B))
-#define pthread_cond_timedwait(a,b,c) pthread_cond_wait((a),(b))
-#define pthread_attr_init(A) pthread_attr_create(A)
-#define pthread_attr_destroy(A) pthread_attr_delete(A)
-#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
-#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
-#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
-#define pthread_kill(A,B) pthread_dummy(0)
-#undef	pthread_detach_this_thread
-#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
-#endif
-
-#ifdef HAVE_DARWIN5_THREADS
-#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
-#define pthread_kill(A,B) pthread_dummy(0)
-#define pthread_condattr_init(A) pthread_dummy(0)
-#define pthread_condattr_destroy(A) pthread_dummy(0)
-#undef	pthread_detach_this_thread
-#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
-#endif
-
-#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
-/* This is set on AIX_3_2 and Siemens unix (and DEC OSF/1 3.2 too) */
-#define pthread_key_create(A,B) \
-		pthread_keycreate(A,(B) ?\
-				  (pthread_destructor_t) (B) :\
-				  (pthread_destructor_t) pthread_dummy)
-#define pthread_attr_init(A) pthread_attr_create(A)
-#define pthread_attr_destroy(A) pthread_attr_delete(A)
-#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
-#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
-#ifndef pthread_sigmask
-#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
-#endif
-#define pthread_kill(A,B) pthread_dummy(0)
-#undef	pthread_detach_this_thread
-#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
-#elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */
-#define HAVE_PTHREAD_KILL
-#endif
-
-#endif /* defined(__WIN__) */
-
-#if defined(HPUX10) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
-#undef pthread_cond_timedwait
-#define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c))
-int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
-			      struct timespec *abstime);
-#endif
-
-#if defined(HPUX10)
-#define pthread_attr_getstacksize(A,B) my_pthread_attr_getstacksize(A,B)
-void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size);
-#endif
-
-#if defined(HAVE_POSIX1003_4a_MUTEX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
-#undef pthread_mutex_trylock
-#define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a))
-int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
-#endif
-
-	/* safe_mutex adds checking to mutex for easier debugging */
-
-#if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY)
-#define SAFE_MUTEX_DETECT_DESTROY
-#endif
-
-typedef struct st_safe_mutex_t
-{
-  pthread_mutex_t global,mutex;
-  const char *file;
-  uint line,count;
-  pthread_t thread;
-#ifdef SAFE_MUTEX_DETECT_DESTROY
-  struct st_safe_mutex_info_t *info;	/* to track destroying of mutexes */
-#endif
-} safe_mutex_t;
-
-#ifdef SAFE_MUTEX_DETECT_DESTROY
-/*
-  Used to track the destroying of mutexes. This needs to be a seperate
-  structure because the safe_mutex_t structure could be freed before
-  the mutexes are destroyed.
-*/
-
-typedef struct st_safe_mutex_info_t
-{
-  struct st_safe_mutex_info_t *next;
-  struct st_safe_mutex_info_t *prev;
-  const char *init_file;
-  uint32 init_line;
-} safe_mutex_info_t;
-#endif /* SAFE_MUTEX_DETECT_DESTROY */
-
-int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr,
-                    const char *file, uint line);
-int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line);
-int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line);
-int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line);
-int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file,
-		   uint line);
-int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
-			struct timespec *abstime, const char *file, uint line);
-void safe_mutex_global_init(void);
-void safe_mutex_end(FILE *file);
-
-	/* Wrappers if safe mutex is actually used */
-#ifdef SAFE_MUTEX
-#undef pthread_mutex_init
-#undef pthread_mutex_lock
-#undef pthread_mutex_unlock
-#undef pthread_mutex_destroy
-#undef pthread_mutex_wait
-#undef pthread_mutex_timedwait
-#undef pthread_mutex_t
-#undef pthread_cond_wait
-#undef pthread_cond_timedwait
-#undef pthread_mutex_trylock
-#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__)
-#define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__)
-#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
-#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)
-#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__)
-#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
-#define pthread_mutex_trylock(A) pthread_mutex_lock(A)
-#define pthread_mutex_t safe_mutex_t
-#define safe_mutex_assert_owner(mp) \
-          DBUG_ASSERT((mp)->count > 0 && \
-                      pthread_equal(pthread_self(), (mp)->thread))
-#define safe_mutex_assert_not_owner(mp) \
-          DBUG_ASSERT(! (mp)->count || \
-                      ! pthread_equal(pthread_self(), (mp)->thread))
-#else
-#define safe_mutex_assert_owner(mp)
-#define safe_mutex_assert_not_owner(mp)
-#endif /* SAFE_MUTEX */
-
-	/* READ-WRITE thread locking */
-
-#ifdef HAVE_BROKEN_RWLOCK			/* For OpenUnix */
-#undef HAVE_PTHREAD_RWLOCK_RDLOCK
-#undef HAVE_RWLOCK_INIT
-#undef HAVE_RWLOCK_T
-#endif
-
-#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
-/* use these defs for simple mutex locking */
-#define rw_lock_t pthread_mutex_t
-#define my_rwlock_init(A,B) pthread_mutex_init((A),(B))
-#define rw_rdlock(A) pthread_mutex_lock((A))
-#define rw_wrlock(A) pthread_mutex_lock((A))
-#define rw_tryrdlock(A) pthread_mutex_trylock((A))
-#define rw_trywrlock(A) pthread_mutex_trylock((A))
-#define rw_unlock(A) pthread_mutex_unlock((A))
-#define rwlock_destroy(A) pthread_mutex_destroy((A))
-#elif defined(HAVE_PTHREAD_RWLOCK_RDLOCK)
-#define rw_lock_t pthread_rwlock_t
-#define my_rwlock_init(A,B) pthread_rwlock_init((A),(B))
-#define rw_rdlock(A) pthread_rwlock_rdlock(A)
-#define rw_wrlock(A) pthread_rwlock_wrlock(A)
-#define rw_tryrdlock(A) pthread_rwlock_tryrdlock((A))
-#define rw_trywrlock(A) pthread_rwlock_trywrlock((A))
-#define rw_unlock(A) pthread_rwlock_unlock(A)
-#define rwlock_destroy(A) pthread_rwlock_destroy(A)
-#elif defined(HAVE_RWLOCK_INIT)
-#ifdef HAVE_RWLOCK_T				/* For example Solaris 2.6-> */
-#define rw_lock_t rwlock_t
-#endif
-#define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0)
-#else
-/* Use our own version of read/write locks */
-typedef struct _my_rw_lock_t {
-	pthread_mutex_t lock;		/* lock for structure		*/
-	pthread_cond_t	readers;	/* waiting readers		*/
-	pthread_cond_t	writers;	/* waiting writers		*/
-	int		state;		/* -1:writer,0:free,>0:readers	*/
-	int		waiters;	/* number of waiting writers	*/
-} my_rw_lock_t;
-
-#define rw_lock_t my_rw_lock_t
-#define rw_rdlock(A) my_rw_rdlock((A))
-#define rw_wrlock(A) my_rw_wrlock((A))
-#define rw_tryrdlock(A) my_rw_tryrdlock((A))
-#define rw_trywrlock(A) my_rw_trywrlock((A))
-#define rw_unlock(A) my_rw_unlock((A))
-#define rwlock_destroy(A) my_rwlock_destroy((A))
-
-extern int my_rwlock_init(my_rw_lock_t *, void *);
-extern int my_rwlock_destroy(my_rw_lock_t *);
-extern int my_rw_rdlock(my_rw_lock_t *);
-extern int my_rw_wrlock(my_rw_lock_t *);
-extern int my_rw_unlock(my_rw_lock_t *);
-extern int my_rw_tryrdlock(my_rw_lock_t *);
-extern int my_rw_trywrlock(my_rw_lock_t *);
-#endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */
-
-#define GETHOSTBYADDR_BUFF_SIZE 2048
-
-#ifndef HAVE_THR_SETCONCURRENCY
-#define thr_setconcurrency(A) pthread_dummy(0)
-#endif
-#if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize)
-#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
-#endif
-
-/* Define mutex types, see my_thr_init.c */
-#define MY_MUTEX_INIT_SLOW   NULL
-#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
-extern pthread_mutexattr_t my_fast_mutexattr;
-#define MY_MUTEX_INIT_FAST &my_fast_mutexattr
-#else
-#define MY_MUTEX_INIT_FAST   NULL
-#endif
-#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
-extern pthread_mutexattr_t my_errorcheck_mutexattr;
-#define MY_MUTEX_INIT_ERRCHK &my_errorcheck_mutexattr
-#else
-#define MY_MUTEX_INIT_ERRCHK   NULL
-#endif
-
-extern my_bool my_thread_global_init(void);
-extern void my_thread_global_end(void);
-extern my_bool my_thread_init(void);
-extern void my_thread_end(void);
-extern const char *my_thread_name(void);
-extern long my_thread_id(void);
-extern int pthread_no_free(void *);
-extern int pthread_dummy(int);
-
-/* All thread specific variables are in the following struct */
-
-#define THREAD_NAME_SIZE 10
-#ifndef DEFAULT_THREAD_STACK
-#if SIZEOF_CHARP > 4
-/*
-  MySQL can survive with 32K, but some glibc libraries require > 128K stack
-  To resolve hostnames. Also recursive stored procedures needs stack.
-*/
-#define DEFAULT_THREAD_STACK	(256*1024L)
-#else
-#define DEFAULT_THREAD_STACK	(192*1024)
-#endif
-#endif
-
-struct st_my_thread_var
-{
-  int thr_errno;
-  pthread_cond_t suspend;
-  pthread_mutex_t mutex;
-  pthread_mutex_t * volatile current_mutex;
-  pthread_cond_t * volatile current_cond;
-  pthread_t pthread_self;
-  long id;
-  int cmp_length;
-  int volatile abort;
-  my_bool init;
-  struct st_my_thread_var *next,**prev;
-  void *opt_info;
-#ifndef DBUG_OFF
-  gptr dbug;
-  char name[THREAD_NAME_SIZE+1];
-#endif
-};
-
-extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
-#define my_thread_var (_my_thread_var())
-#define my_errno my_thread_var->thr_errno
-/*
-  Keep track of shutdown,signal, and main threads so that my_end() will not
-  report errors with them
-*/
-extern pthread_t shutdown_th, main_th, signal_th;
-
-	/* statistics_xxx functions are for not essential statistic */
-
-#ifndef thread_safe_increment
-#ifdef HAVE_ATOMIC_ADD
-#define thread_safe_increment(V,L) atomic_inc((atomic_t*) &V)
-#define thread_safe_decrement(V,L) atomic_dec((atomic_t*) &V)
-#define thread_safe_add(V,C,L)     atomic_add((C),(atomic_t*) &V)
-#define thread_safe_sub(V,C,L)     atomic_sub((C),(atomic_t*) &V)
-#else
-#define thread_safe_increment(V,L) \
-        (pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
-#define thread_safe_decrement(V,L) \
-        (pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L)))
-#define thread_safe_add(V,C,L) (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
-#define thread_safe_sub(V,C,L) \
-        (pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
-#endif /* HAVE_ATOMIC_ADD */
-#ifdef SAFE_STATISTICS
-#define statistic_increment(V,L)   thread_safe_increment((V),(L))
-#define statistic_decrement(V,L)   thread_safe_decrement((V),(L))
-#define statistic_add(V,C,L)       thread_safe_add((V),(C),(L))
-#else
-#define statistic_decrement(V,L) (V)--
-#define statistic_increment(V,L) (V)++
-#define statistic_add(V,C,L)     (V)+=(C)
-#endif /* SAFE_STATISTICS */
-#endif /* thread_safe_increment */
-
-#ifdef  __cplusplus
-}
-#endif
-#endif /* _my_ptread_h */
diff --git a/3rdparty/mysql/include/my_sys.h b/3rdparty/mysql/include/my_sys.h
deleted file mode 100644
index 44fe383bf..000000000
--- a/3rdparty/mysql/include/my_sys.h
+++ /dev/null
@@ -1,904 +0,0 @@
-/* Copyright (C) 2000-2003 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#ifndef _my_sys_h
-#define _my_sys_h
-C_MODE_START
-
-#ifdef HAVE_AIOWAIT
-#include <sys/asynch.h>			/* Used by record-cache */
-typedef struct my_aio_result {
-  aio_result_t result;
-  int	       pending;
-} my_aio_result;
-#endif
-
-#ifndef THREAD
-extern int NEAR my_errno;		/* Last error in mysys */
-#else
-#include <my_pthread.h>
-#endif
-
-#ifndef _m_ctype_h
-#include <m_ctype.h>                    /* for CHARSET_INFO */
-#endif
-
-#include <stdarg.h>
-#include <typelib.h>
-
-#define MYSYS_PROGRAM_USES_CURSES()  { error_handler_hook = my_message_curses;	mysys_uses_curses=1; }
-#define MYSYS_PROGRAM_DONT_USE_CURSES()  { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
-#define MY_INIT(name);		{ my_progname= name; my_init(); }
-
-#define ERRMSGSIZE	(SC_MAXWIDTH)	/* Max length of a error message */
-#define NRERRBUFFS	(2)	/* Buffers for parameters */
-#define MY_FILE_ERROR	((uint) ~0)
-
-	/* General bitmaps for my_func's */
-#define MY_FFNF		1	/* Fatal if file not found */
-#define MY_FNABP	2	/* Fatal if not all bytes read/writen */
-#define MY_NABP		4	/* Error if not all bytes read/writen */
-#define MY_FAE		8	/* Fatal if any error */
-#define MY_WME		16	/* Write message on error */
-#define MY_WAIT_IF_FULL 32	/* Wait and try again if disk full error */
-#define MY_IGNORE_BADFD 32      /* my_sync: ignore 'bad descriptor' errors */
-#define MY_RAID         64      /* Support for RAID */
-#define MY_FULL_IO     512      /* For my_read - loop intil I/O is complete */
-#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
-#define MY_LINK_WARNING 32	/* my_redel() gives warning if links */
-#define MY_COPYTIME	64	/* my_redel() copys time */
-#define MY_DELETE_OLD	256	/* my_create_with_symlink() */
-#define MY_RESOLVE_LINK 128	/* my_realpath(); Only resolve links */
-#define MY_HOLD_ORIGINAL_MODES 128  /* my_copy() holds to file modes */
-#define MY_REDEL_MAKE_BACKUP 256
-#define MY_SEEK_NOT_DONE 32	/* my_lock may have to do a seek */
-#define MY_DONT_WAIT	64	/* my_lock() don't wait if can't lock */
-#define MY_ZEROFILL	32	/* my_malloc(), fill array with zero */
-#define MY_ALLOW_ZERO_PTR 64	/* my_realloc() ; zero ptr -> malloc */
-#define MY_FREE_ON_ERROR 128	/* my_realloc() ; Free old ptr on error */
-#define MY_HOLD_ON_ERROR 256	/* my_realloc() ; Return old ptr on error */
-#define MY_THREADSAFE	128	/* pread/pwrite:  Don't allow interrupts */
-#define MY_DONT_OVERWRITE_FILE 1024	/* my_copy: Don't overwrite file */
-
-#define MY_CHECK_ERROR	1	/* Params to my_end; Check open-close */
-#define MY_GIVE_INFO	2	/* Give time info about process*/
-
-#define ME_HIGHBYTE	8	/* Shift for colours */
-#define ME_NOCUR	1	/* Don't use curses message */
-#define ME_OLDWIN	2	/* Use old window */
-#define ME_BELL		4	/* Ring bell then printing message */
-#define ME_HOLDTANG	8	/* Don't delete last keys */
-#define ME_WAITTOT	16	/* Wait for errtime secs of for a action */
-#define ME_WAITTANG	32	/* Wait for a user action  */
-#define ME_NOREFRESH	64	/* Dont refresh screen */
-#define ME_NOINPUT	128	/* Dont use the input libary */
-#define ME_COLOUR1	((1 << ME_HIGHBYTE))	/* Possibly error-colours */
-#define ME_COLOUR2	((2 << ME_HIGHBYTE))
-#define ME_COLOUR3	((3 << ME_HIGHBYTE))
-
-	/* Bits in last argument to fn_format */
-#define MY_REPLACE_DIR		1	/* replace dir in name with 'dir' */
-#define MY_REPLACE_EXT		2	/* replace extension with 'ext' */
-#define MY_UNPACK_FILENAME	4	/* Unpack name (~ -> home) */
-#define MY_PACK_FILENAME	8	/* Pack name (home -> ~) */
-#define MY_RESOLVE_SYMLINKS	16	/* Resolve all symbolic links */
-#define MY_RETURN_REAL_PATH	32	/* return full path for file */
-#define MY_SAFE_PATH		64	/* Return NULL if too long path */
-#define MY_RELATIVE_PATH	128	/* name is relative to 'dir' */
-
-	/* My seek flags */
-#define MY_SEEK_SET	0
-#define MY_SEEK_CUR	1
-#define MY_SEEK_END	2
-
-	/* Some constants */
-#define MY_WAIT_FOR_USER_TO_FIX_PANIC	60	/* in seconds */
-#define MY_WAIT_GIVE_USER_A_MESSAGE	10	/* Every 10 times of prev */
-#define MIN_COMPRESS_LENGTH		50	/* Don't compress small bl. */
-#define DFLT_INIT_HITS  3
-
-	/* root_alloc flags */
-#define MY_KEEP_PREALLOC	1
-#define MY_MARK_BLOCKS_FREE     2  /* move used to free list and reuse them */
-
-	/* Internal error numbers (for assembler functions) */
-#define MY_ERRNO_EDOM		33
-#define MY_ERRNO_ERANGE		34
-
-	/* Bits for get_date timeflag */
-#define GETDATE_DATE_TIME	1
-#define GETDATE_SHORT_DATE	2
-#define GETDATE_HHMMSSTIME	4
-#define GETDATE_GMT		8
-#define GETDATE_FIXEDLENGTH	16
-
-	/* defines when allocating data */
-#ifdef SAFEMALLOC
-#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG )
-#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG )
-#define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG )
-#define my_checkmalloc() _sanity( __FILE__, __LINE__ )
-#define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG)
-#define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C)
-#define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C)
-#define my_strdup_with_length(A,B,C) _my_strdup_with_length((A),(B),__FILE__,__LINE__,C)
-#define TRASH(A,B) bfill(A, B, 0x8F)
-#define QUICK_SAFEMALLOC sf_malloc_quick=1
-#define NORMAL_SAFEMALLOC sf_malloc_quick=0
-extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
-extern ulonglong sf_malloc_mem_limit;
-
-#define CALLER_INFO_PROTO   , const char *sFile, uint uLine
-#define CALLER_INFO         , __FILE__, __LINE__
-#define ORIG_CALLER_INFO    , sFile, uLine
-#else
-#define my_checkmalloc()
-#undef TERMINATE
-#define TERMINATE(A) {}
-#define QUICK_SAFEMALLOC
-#define NORMAL_SAFEMALLOC
-extern gptr my_malloc(uint Size,myf MyFlags);
-#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
-extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);
-extern void my_no_flags_free(gptr ptr);
-extern gptr my_memdup(const byte *from,uint length,myf MyFlags);
-extern char *my_strdup(const char *from,myf MyFlags);
-extern char *my_strdup_with_length(const byte *from, uint length,
-				   myf MyFlags);
-/* we do use FG (as a no-op) in below so that a typo on FG is caught */
-#define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR))
-#define CALLER_INFO_PROTO   /* nothing */
-#define CALLER_INFO         /* nothing */
-#define ORIG_CALLER_INFO    /* nothing */
-#define TRASH(A,B) /* nothing */
-#endif
-
-#ifdef HAVE_LARGE_PAGES
-extern uint my_get_large_page_size(void);
-extern gptr my_large_malloc(uint size, myf my_flags);
-extern void my_large_free(gptr ptr, myf my_flags);
-#else
-#define my_get_large_page_size() (0)
-#define my_large_malloc(A,B) my_malloc_lock((A),(B))
-#define my_large_free(A,B) my_free_lock((A),(B))
-#endif /* HAVE_LARGE_PAGES */
-
-#ifdef HAVE_ALLOCA
-#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
-#pragma alloca
-#endif /* _AIX */
-#if defined(__MWERKS__)
-#undef alloca
-#define alloca _alloca
-#endif /* __MWERKS__ */
-#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
-#define alloca __builtin_alloca
-#endif /* GNUC */
-#define my_alloca(SZ) alloca((size_t) (SZ))
-#define my_afree(PTR) {}
-#else
-#define my_alloca(SZ) my_malloc(SZ,MYF(0))
-#define my_afree(PTR) my_free(PTR,MYF(MY_WME))
-#endif /* HAVE_ALLOCA */
-
-#ifdef MSDOS
-#ifdef __ZTC__
-void * __CDECL halloc(long count,size_t length);
-void   __CDECL hfree(void *ptr);
-#endif
-#if defined(USE_HALLOC)
-#if defined(_VCM_) || defined(M_IC80386)
-#undef USE_HALLOC
-#endif
-#endif
-#ifdef USE_HALLOC
-#define malloc(a) halloc((long) (a),1)
-#define free(a) hfree(a)
-#endif
-#endif /* MSDOS */
-
-#ifndef errno				/* did we already get it? */
-#ifdef HAVE_ERRNO_AS_DEFINE
-#include <errno.h>			/* errno is a define */
-#else
-extern int errno;			/* declare errno */
-#endif
-#endif					/* #ifndef errno */
-extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
-extern char *home_dir;			/* Home directory for user */
-extern const char *my_progname;		/* program-name (printed in errors) */
-extern char NEAR curr_dir[];		/* Current directory for user */
-extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
-extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
-				       myf MyFlags);
-extern uint my_file_limit;
-
-#ifdef HAVE_LARGE_PAGES
-extern my_bool my_use_large_pages;
-extern uint    my_large_page_size;
-#endif
-
-/* charsets */
-extern CHARSET_INFO *default_charset_info;
-extern CHARSET_INFO *all_charsets[256];
-extern CHARSET_INFO compiled_charsets[];
-
-/* statistics */
-extern ulong	my_file_opened,my_stream_opened, my_tmp_file_created;
-extern uint	mysys_usage_id;
-extern my_bool	my_init_done;
-
-					/* Point to current my_message() */
-extern void (*my_sigtstp_cleanup)(void),
-					/* Executed before jump to shell */
-	    (*my_sigtstp_restart)(void),
-	    (*my_abort_hook)(int);
-					/* Executed when comming from shell */
-extern int NEAR my_umask,		/* Default creation mask  */
-	   NEAR my_umask_dir,
-	   NEAR my_recived_signals,	/* Signals we have got */
-	   NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
-	   NEAR my_dont_interrupt;	/* call remember_intr when set */
-extern my_bool NEAR mysys_uses_curses, my_use_symdir;
-extern ulong sf_malloc_cur_memory, sf_malloc_max_memory;
-
-extern ulong	my_default_record_cache_size;
-extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
-               NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks;
-extern char	wild_many,wild_one,wild_prefix;
-extern const char *charsets_dir;
-extern char *defaults_extra_file;
-extern const char *defaults_group_suffix;
-extern const char *defaults_file;
-
-extern my_bool timed_mutexes;
-
-typedef struct wild_file_pack	/* Struct to hold info when selecting files */
-{
-  uint		wilds;		/* How many wildcards */
-  uint		not_pos;	/* Start of not-theese-files */
-  my_string	*wild;		/* Pointer to wildcards */
-} WF_PACK;
-
-enum loglevel {
-   ERROR_LEVEL,
-   WARNING_LEVEL,
-   INFORMATION_LEVEL
-};
-
-enum cache_type
-{
-  TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE,
-  SEQ_READ_APPEND		/* sequential read or append */,
-  READ_FIFO, READ_NET,WRITE_NET};
-
-enum flush_type
-{
-  FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE
-};
-
-typedef struct st_record_cache	/* Used when cacheing records */
-{
-  File file;
-  int	rc_seek,error,inited;
-  uint	rc_length,read_length,reclength;
-  my_off_t rc_record_pos,end_of_file;
-  byte	*rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
-#ifdef HAVE_AIOWAIT
-  int	use_async_io;
-  my_aio_result aio_result;
-#endif
-  enum cache_type type;
-} RECORD_CACHE;
-
-enum file_type
-{
-  UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN,
-  FILE_BY_MKSTEMP, FILE_BY_DUP
-};
-
-struct st_my_file_info
-{
-  my_string		name;
-  enum file_type	type;
-#if defined(THREAD) && !defined(HAVE_PREAD)
-  pthread_mutex_t	mutex;
-#endif
-};
-
-extern struct st_my_file_info *my_file_info;
-
-typedef struct st_my_tmpdir
-{
-  char **list;
-  uint cur, max;
-#ifdef THREAD
-  pthread_mutex_t mutex;
-#endif
-} MY_TMPDIR;
-
-typedef struct st_dynamic_array
-{
-  char *buffer;
-  uint elements,max_element;
-  uint alloc_increment;
-  uint size_of_element;
-} DYNAMIC_ARRAY;
-
-typedef struct st_dynamic_string
-{
-  char *str;
-  uint length,max_length,alloc_increment;
-} DYNAMIC_STRING;
-
-struct st_io_cache;
-typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
-
-#ifdef THREAD
-typedef struct st_io_cache_share
-{
-  /* to sync on reads into buffer */
-  pthread_mutex_t mutex;
-  pthread_cond_t  cond;
-  int             count, total;
-  /* actual IO_CACHE that filled the buffer */
-  struct st_io_cache *active;
-#ifdef NOT_YET_IMPLEMENTED
-  /* whether the structure should be free'd */
-  my_bool alloced;
-#endif
-} IO_CACHE_SHARE;
-#endif
-
-typedef struct st_io_cache		/* Used when cacheing files */
-{
-  /* Offset in file corresponding to the first byte of byte* buffer. */
-  my_off_t pos_in_file;
-  /*
-    The offset of end of file for READ_CACHE and WRITE_CACHE.
-    For SEQ_READ_APPEND it the maximum of the actual end of file and
-    the position represented by read_end.
-  */
-  my_off_t end_of_file;
-  /* Points to current read position in the buffer */
-  byte	*read_pos;
-  /* the non-inclusive boundary in the buffer for the currently valid read */
-  byte  *read_end;
-  byte  *buffer;				/* The read buffer */
-  /* Used in ASYNC_IO */
-  byte  *request_pos;
-
-  /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
-  byte  *write_buffer;
-  /*
-    Only used in SEQ_READ_APPEND, and points to the current read position
-    in the write buffer. Note that reads in SEQ_READ_APPEND caches can
-    happen from both read buffer (byte* buffer) and write buffer
-    (byte* write_buffer).
-  */
-  byte *append_read_pos;
-  /* Points to current write position in the write buffer */
-  byte *write_pos;
-  /* The non-inclusive boundary of the valid write area */
-  byte *write_end;
-
-  /*
-    Current_pos and current_end are convenience variables used by
-    my_b_tell() and other routines that need to know the current offset
-    current_pos points to &write_pos, and current_end to &write_end in a
-    WRITE_CACHE, and &read_pos and &read_end respectively otherwise
-  */
-  byte  **current_pos, **current_end;
-#ifdef THREAD
-  /*
-    The lock is for append buffer used in SEQ_READ_APPEND cache
-    need mutex copying from append buffer to read buffer.
-  */
-  pthread_mutex_t append_buffer_lock;
-  /*
-    The following is used when several threads are reading the
-    same file in parallel. They are synchronized on disk
-    accesses reading the cached part of the file asynchronously.
-    It should be set to NULL to disable the feature.  Only
-    READ_CACHE mode is supported.
-  */
-  IO_CACHE_SHARE *share;
-#endif
-  /*
-    A caller will use my_b_read() macro to read from the cache
-    if the data is already in cache, it will be simply copied with
-    memcpy() and internal variables will be accordinging updated with
-    no functions invoked. However, if the data is not fully in the cache,
-    my_b_read() will call read_function to fetch the data. read_function
-    must never be invoked directly.
-  */
-  int (*read_function)(struct st_io_cache *,byte *,uint);
-  /*
-    Same idea as in the case of read_function, except my_b_write() needs to
-    be replaced with my_b_append() for a SEQ_READ_APPEND cache
-  */
-  int (*write_function)(struct st_io_cache *,const byte *,uint);
-  /*
-    Specifies the type of the cache. Depending on the type of the cache
-    certain operations might not be available and yield unpredicatable
-    results. Details to be documented later
-  */
-  enum cache_type type;
-  /*
-    Callbacks when the actual read I/O happens. These were added and
-    are currently used for binary logging of LOAD DATA INFILE - when a
-    block is read from the file, we create a block create/append event, and
-    when IO_CACHE is closed, we create an end event. These functions could,
-    of course be used for other things
-  */
-  IO_CACHE_CALLBACK pre_read;
-  IO_CACHE_CALLBACK post_read;
-  IO_CACHE_CALLBACK pre_close;
-  /*
-    Counts the number of times, when we were forced to use disk. We use it to
-    increase the binlog_cache_disk_use status variable.
-  */
-  ulong disk_writes;
-  void* arg;				/* for use by pre/post_read */
-  char *file_name;			/* if used with 'open_cached_file' */
-  char *dir,*prefix;
-  File file; /* file descriptor */
-  /*
-    seek_not_done is set by my_b_seek() to inform the upcoming read/write
-    operation that a seek needs to be preformed prior to the actual I/O
-    error is 0 if the cache operation was successful, -1 if there was a
-    "hard" error, and the actual number of I/O-ed bytes if the read/write was
-    partial.
-  */
-  int	seek_not_done,error;
-  /* buffer_length is memory size allocated for buffer or write_buffer */
-  uint	buffer_length;
-  /* read_length is the same as buffer_length except when we use async io */
-  uint  read_length;
-  myf	myflags;			/* Flags used to my_read/my_write */
-  /*
-    alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
-    0 if it was supplied by the user.
-    Currently READ_NET is the only one that will use a buffer allocated
-    somewhere else
-  */
-  my_bool alloced_buffer;
-#ifdef HAVE_AIOWAIT
-  /*
-    As inidicated by ifdef, this is for async I/O, which is not currently
-    used (because it's not reliable on all systems)
-  */
-  uint inited;
-  my_off_t aio_read_pos;
-  my_aio_result aio_result;
-#endif
-} IO_CACHE;
-
-typedef int (*qsort2_cmp)(const void *, const void *, const void *);
-
-	/* defines for mf_iocache */
-
-	/* Test if buffer is inited */
-#define my_b_clear(info) (info)->buffer=0
-#define my_b_inited(info) (info)->buffer
-#define my_b_EOF INT_MIN
-
-#define my_b_read(info,Buffer,Count) \
-  ((info)->read_pos + (Count) <= (info)->read_end ?\
-   (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \
-    ((info)->read_pos+=(Count)),0) :\
-   (*(info)->read_function)((info),Buffer,Count))
-
-#define my_b_write(info,Buffer,Count) \
- ((info)->write_pos + (Count) <=(info)->write_end ?\
-  (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
-   ((info)->write_pos+=(Count)),0) : \
-   (*(info)->write_function)((info),(Buffer),(Count)))
-
-#define my_b_get(info) \
-  ((info)->read_pos != (info)->read_end ?\
-   ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\
-   _my_b_get(info))
-
-	/* my_b_write_byte dosn't have any err-check */
-#define my_b_write_byte(info,chr) \
-  (((info)->write_pos < (info)->write_end) ?\
-   ((*(info)->write_pos++)=(chr)) :\
-   (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr))))
-
-#define my_b_fill_cache(info) \
-  (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0))
-
-#define my_b_tell(info) ((info)->pos_in_file + \
-			 (uint) (*(info)->current_pos - (info)->request_pos))
-
-/* tell write offset in the SEQ_APPEND cache */
-my_off_t my_b_append_tell(IO_CACHE* info);
-my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
-
-#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \
-					  *(info)->current_pos)
-
-typedef uint32 ha_checksum;
-
-/* Define the type of function to be passed to process_default_option_files */
-typedef int (*Process_option_func)(void *ctx, const char *group_name,
-                                   const char *option);
-
-#include <my_alloc.h>
-
-	/* Prototypes for mysys and my_func functions */
-
-extern int my_copy(const char *from,const char *to,myf MyFlags);
-extern int my_append(const char *from,const char *to,myf MyFlags);
-extern int my_delete(const char *name,myf MyFlags);
-extern int my_getwd(my_string buf,uint size,myf MyFlags);
-extern int my_setwd(const char *dir,myf MyFlags);
-extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
-extern gptr my_once_alloc(uint Size,myf MyFlags);
-extern void my_once_free(void);
-extern char *my_once_strdup(const char *src,myf myflags);
-extern char *my_once_memdup(const char *src, uint len, myf myflags);
-extern File my_open(const char *FileName,int Flags,myf MyFlags);
-extern File my_register_filename(File fd, const char *FileName,
-				 enum file_type type_of_file,
-				 uint error_message_number, myf MyFlags);
-extern File my_create(const char *FileName,int CreateFlags,
-		      int AccsesFlags, myf MyFlags);
-extern int my_close(File Filedes,myf MyFlags);
-extern File my_dup(File file, myf MyFlags);
-extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
-extern int my_readlink(char *to, const char *filename, myf MyFlags);
-extern int my_realpath(char *to, const char *filename, myf MyFlags);
-extern File my_create_with_symlink(const char *linkname, const char *filename,
-				   int createflags, int access_flags,
-				   myf MyFlags);
-extern int my_delete_with_symlink(const char *name, myf MyFlags);
-extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
-extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
-extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags);
-extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset,
-		     myf MyFlags);
-extern int my_rename(const char *from,const char *to,myf MyFlags);
-extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
-extern my_off_t my_tell(File fd,myf MyFlags);
-extern uint my_write(File Filedes,const byte *Buffer,uint Count,
-		     myf MyFlags);
-extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count,
-		      my_off_t offset,myf MyFlags);
-extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags);
-extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count,
-		      myf MyFlags);
-extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
-extern my_off_t my_ftell(FILE *stream,myf MyFlags);
-extern gptr _mymalloc(uint uSize,const char *sFile,
-		      uint uLine, myf MyFlag);
-extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
-		       uint uLine, myf MyFlag);
-extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
-extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
-extern int _sanity(const char *sFile,unsigned int uLine);
-extern gptr _my_memdup(const byte *from,uint length,
-		       const char *sFile, uint uLine,myf MyFlag);
-extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
-			    myf MyFlag);
-extern char *_my_strdup_with_length(const byte *from, uint length,
-				    const char *sFile, uint uLine,
-				    myf MyFlag);
-
-#ifdef __WIN__
-extern int my_access(const char *path, int amode);
-extern File my_sopen(const char *path, int oflag, int shflag, int pmode);
-#else
-#define my_access access
-#endif
-extern int check_if_legal_filename(const char *path);
-
-#ifndef TERMINATE
-extern void TERMINATE(FILE *file);
-#endif
-extern void init_glob_errs(void);
-extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
-extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
-extern int my_fclose(FILE *fd,myf MyFlags);
-extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
-extern int my_sync(File fd, myf my_flags);
-extern int my_error _VARARGS((int nr,myf MyFlags, ...));
-extern int my_printf_error _VARARGS((uint my_err, const char *format,
-				     myf MyFlags, ...)
-				    __attribute__ ((format (printf, 2, 4))));
-extern int my_error_register(const char **errmsgs, int first, int last);
-extern const char **my_error_unregister(int first, int last);
-extern int my_message(uint my_err, const char *str,myf MyFlags);
-extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
-extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
-extern my_bool my_init(void);
-extern void my_end(int infoflag);
-extern int my_redel(const char *from, const char *to, int MyFlags);
-extern int my_copystat(const char *from, const char *to, int MyFlags);
-extern my_string my_filename(File fd);
-
-#ifndef THREAD
-extern void dont_break(void);
-extern void allow_break(void);
-#else
-#define dont_break()
-#define allow_break()
-#endif
-
-extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
-extern char *my_tmpdir(MY_TMPDIR *tmpdir);
-extern void free_tmpdir(MY_TMPDIR *tmpdir);
-
-extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
-extern uint dirname_part(my_string to,const char *name);
-extern uint dirname_length(const char *name);
-#define base_name(A) (A+dirname_length(A))
-extern int test_if_hard_path(const char *dir_name);
-extern my_bool has_path(const char *name);
-extern char *convert_dirname(char *to, const char *from, const char *from_end);
-extern void to_unix_path(my_string name);
-extern my_string fn_ext(const char *name);
-extern my_string fn_same(my_string toname,const char *name,int flag);
-extern my_string fn_format(my_string to,const char *name,const char *dir,
-			   const char *form, uint flag);
-extern size_s strlength(const char *str);
-extern void pack_dirname(my_string to,const char *from);
-extern uint unpack_dirname(my_string to,const char *from);
-extern uint cleanup_dirname(my_string to,const char *from);
-extern uint system_filename(my_string to,const char *from);
-extern uint unpack_filename(my_string to,const char *from);
-extern my_string intern_filename(my_string to,const char *from);
-extern my_string directory_file_name(my_string dst, const char *src);
-extern int pack_filename(my_string to, const char *name, size_s max_length);
-extern my_string my_path(my_string to,const char *progname,
-			 const char *own_pathname_part);
-extern my_string my_load_path(my_string to, const char *path,
-			      const char *own_path_prefix);
-extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern);
-extern WF_PACK *wf_comp(my_string str);
-extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
-extern void wf_end(struct wild_file_pack *buffer);
-extern size_s strip_sp(my_string str);
-extern void get_date(my_string to,int timeflag,time_t use_time);
-extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage);
-extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
-			     uint reclength,enum cache_type type,
-			     pbool use_async_io);
-extern int read_cache_record(RECORD_CACHE *info,byte *to);
-extern int end_record_cache(RECORD_CACHE *info);
-extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
-			      const byte *record,uint length);
-extern int flush_write_cache(RECORD_CACHE *info);
-extern long my_clock(void);
-extern sig_handler sigtstp_handler(int signal_number);
-extern void handle_recived_signals(void);
-
-extern sig_handler my_set_alarm_variable(int signo);
-extern void my_string_ptr_sort(void *base,uint items,size_s size);
-extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
-				  size_s size_of_element,uchar *buffer[]);
-extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
-		      qsort2_cmp cmp, void *cmp_argument);
-extern qsort2_cmp get_ptr_compare(uint);
-void my_store_ptr(byte *buff, uint pack_length, my_off_t pos);
-my_off_t my_get_ptr(byte *ptr, uint pack_length);
-extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
-			 enum cache_type type,my_off_t seek_offset,
-			 pbool use_async_io, myf cache_myflags);
-extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
-			       my_off_t seek_offset,pbool use_async_io,
-			       pbool clear_cache);
-extern void setup_io_cache(IO_CACHE* info);
-extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count);
-#ifdef THREAD
-extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count);
-extern void init_io_cache_share(IO_CACHE *info,
-				IO_CACHE_SHARE *s, uint num_threads);
-extern void remove_io_thread(IO_CACHE *info);
-#endif
-extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count);
-extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
-extern int _my_b_get(IO_CACHE *info);
-extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count);
-extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count);
-extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count);
-extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count);
-
-extern int my_block_write(IO_CACHE *info, const byte *Buffer,
-			  uint Count, my_off_t pos);
-extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
-
-#define flush_io_cache(info) my_b_flush_io_cache((info),1)
-
-extern int end_io_cache(IO_CACHE *info);
-extern uint my_b_fill(IO_CACHE *info);
-extern void my_b_seek(IO_CACHE *info,my_off_t pos);
-extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
-extern my_off_t my_b_filelength(IO_CACHE *info);
-extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
-extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
-extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
-				 const char *prefix, uint cache_size,
-				 myf cache_myflags);
-extern my_bool real_open_cached_file(IO_CACHE *cache);
-extern void close_cached_file(IO_CACHE *cache);
-File create_temp_file(char *to, const char *dir, const char *pfx,
-		      int mode, myf MyFlags);
-#define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO)
-#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO)
-extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
-                                  uint init_alloc,uint alloc_increment
-                                  CALLER_INFO_PROTO);
-extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
-extern byte *alloc_dynamic(DYNAMIC_ARRAY *array);
-extern byte *pop_dynamic(DYNAMIC_ARRAY*);
-extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
-extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
-extern void delete_dynamic(DYNAMIC_ARRAY *array);
-extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
-extern void freeze_size(DYNAMIC_ARRAY *array);
-#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
-#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
-#define push_dynamic(A,B) insert_dynamic(A,B)
-#define reset_dynamic(array) ((array)->elements= 0)
-
-extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
-				   uint init_alloc,uint alloc_increment);
-extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
-my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
-			  uint length);
-extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
-extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
-extern void dynstr_free(DYNAMIC_STRING *str);
-#ifdef HAVE_MLOCK
-extern byte *my_malloc_lock(uint length,myf flags);
-extern void my_free_lock(byte *ptr,myf flags);
-#else
-#define my_malloc_lock(A,B) my_malloc((A),(B))
-#define my_free_lock(A,B) my_free((A),(B))
-#endif
-#define alloc_root_inited(A) ((A)->min_malloc != 0)
-#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
-#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
-extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
-			    uint pre_alloc_size);
-extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
-extern gptr multi_alloc_root(MEM_ROOT *mem_root, ...);
-extern void free_root(MEM_ROOT *root, myf MyFLAGS);
-extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
-extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
-                                uint prealloc_size);
-extern char *strdup_root(MEM_ROOT *root,const char *str);
-extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
-extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
-extern int get_defaults_options(int argc, char **argv,
-                                char **defaults, char **extra_defaults,
-                                char **group_suffix);
-extern int load_defaults(const char *conf_file, const char **groups,
-			 int *argc, char ***argv);
-extern int modify_defaults_file(const char *file_location, const char *option,
-                                const char *option_value,
-                                const char *section_name, int remove_option);
-extern int my_search_option_files(const char *conf_file, int *argc,
-                                  char ***argv, uint *args_used,
-                                  Process_option_func func, void *func_ctx);
-extern void free_defaults(char **argv);
-extern void my_print_default_files(const char *conf_file);
-extern void print_defaults(const char *conf_file, const char **groups);
-extern my_bool my_compress(byte *, ulong *, ulong *);
-extern my_bool my_uncompress(byte *, ulong *, ulong *);
-extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
-extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count);
-extern uint my_bit_log2(ulong value);
-extern uint my_count_bits(ulonglong v);
-extern uint my_count_bits_ushort(ushort v);
-extern void my_sleep(ulong m_seconds);
-extern ulong crc32(ulong crc, const uchar *buf, uint len);
-extern uint my_set_max_open_files(uint files);
-void my_free_open_file_info(void);
-
-ulonglong my_getsystime(void);
-my_bool my_gethwaddr(uchar *to);
-
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-
-#ifndef MAP_NOSYNC
-#define MAP_NOSYNC      0
-#endif
-
-#define my_mmap(a,b,c,d,e,f)    mmap(a,b,c,d,e,f)
-#ifdef HAVE_GETPAGESIZE
-#define my_getpagesize()        getpagesize()
-#else
-/* qnx ? */
-#define my_getpagesize()        8192
-#endif
-#define my_munmap(a,b)          munmap((a),(b))
-
-#else
-/* not a complete set of mmap() flags, but only those that nesessary */
-#define PROT_READ        1
-#define PROT_WRITE       2
-#define MAP_SHARED       0x0001
-#define MAP_NOSYNC       0x0800
-#define MAP_FAILED       ((void *)-1)
-#define MS_SYNC          0x0000
-
-#ifndef __NETWARE__
-#define HAVE_MMAP
-#endif
-
-int my_getpagesize(void);
-void *my_mmap(void *, size_t, int, int, int, my_off_t);
-int my_munmap(void *, size_t);
-#endif
-
-int my_msync(int, void *, size_t, int);
-
-/* character sets */
-extern uint get_charset_number(const char *cs_name, uint cs_flags);
-extern uint get_collation_number(const char *name);
-extern const char *get_charset_name(uint cs_number);
-
-extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
-extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
-extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
-					   uint cs_flags, myf my_flags);
-extern void free_charsets(void);
-extern char *get_charsets_dir(char *buf);
-extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
-extern my_bool init_compiled_charsets(myf flags);
-extern void add_compiled_collation(CHARSET_INFO *cs);
-extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
-                                     char *to, ulong to_length,
-                                     const char *from, ulong length);
-#ifdef __WIN__
-#define BACKSLASH_MBTAIL
-/* File system character set */
-extern CHARSET_INFO *fs_character_set(void);
-#endif
-extern ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info,
-                                     char *to, ulong to_length,
-                                     const char *from, ulong length);
-
-extern void thd_increment_bytes_sent(ulong length);
-extern void thd_increment_bytes_received(ulong length);
-extern void thd_increment_net_big_packet_count(ulong length);
-
-#ifdef __WIN__
-extern my_bool have_tcpip;		/* Is set if tcpip is used */
-
-/* implemented in my_windac.c */
-
-int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
-                            DWORD owner_rights, DWORD everybody_rights);
-
-void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
-
-/* implemented in my_conio.c */
-char* my_cgets(char *string, unsigned long clen, unsigned long* plen);
-
-#endif
-#ifdef __NETWARE__
-void netware_reg_user(const char *ip, const char *user,
-		      const char *application);
-#endif
-
-C_MODE_END
-#include "raid.h"
-#endif /* _my_sys_h */
diff --git a/3rdparty/mysql/include/mysql.h b/3rdparty/mysql/include/mysql.h
deleted file mode 100644
index 925a45253..000000000
--- a/3rdparty/mysql/include/mysql.h
+++ /dev/null
@@ -1,847 +0,0 @@
-/* Copyright (C) 2000-2003 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#ifndef _mysql_h
-#define _mysql_h
-
-#ifdef __CYGWIN__     /* CYGWIN implements a UNIX API */
-#undef WIN
-#undef _WIN
-#undef _WIN32
-#undef _WIN64
-#undef __WIN__
-#endif
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#ifndef _global_h				/* If not standard header */
-#include <sys/types.h>
-#ifdef __LCC__
-#include <winsock.h>				/* For windows */
-#endif
-typedef char my_bool;
-#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
-#define __WIN__
-#endif
-#if !defined(__WIN__)
-#define STDCALL
-#else
-#define STDCALL __stdcall
-#endif
-typedef char * gptr;
-
-#ifndef my_socket_defined
-#ifdef __WIN__
-#define my_socket SOCKET
-#else
-typedef int my_socket;
-#endif /* __WIN__ */
-#endif /* my_socket_defined */
-#endif /* _global_h */
-
-#include "mysql_com.h"
-#include "mysql_time.h"
-#include "mysql_version.h"
-#include "typelib.h"
-
-#include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
-
-extern unsigned int mysql_port;
-extern char *mysql_unix_port;
-
-#define CLIENT_NET_READ_TIMEOUT		365*24*3600	/* Timeout on read */
-#define CLIENT_NET_WRITE_TIMEOUT	365*24*3600	/* Timeout on write */
-
-#ifdef __NETWARE__
-#pragma pack(push, 8)		/* 8 byte alignment */
-#endif
-
-#define IS_PRI_KEY(n)	((n) & PRI_KEY_FLAG)
-#define IS_NOT_NULL(n)	((n) & NOT_NULL_FLAG)
-#define IS_BLOB(n)	((n) & BLOB_FLAG)
-#define IS_NUM(t)	((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR || (t) == FIELD_TYPE_NEWDECIMAL)
-#define IS_NUM_FIELD(f)	 ((f)->flags & NUM_FLAG)
-#define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR)
-
-
-typedef struct st_mysql_field {
-  char *name;                 /* Name of column */
-  char *org_name;             /* Original column name, if an alias */
-  char *table;                /* Table of column if column was a field */
-  char *org_table;            /* Org table name, if table was an alias */
-  char *db;                   /* Database for table */
-  char *catalog;	      /* Catalog for table */
-  char *def;                  /* Default value (set by mysql_list_fields) */
-  unsigned long length;       /* Width of column (create length) */
-  unsigned long max_length;   /* Max width for selected set */
-  unsigned int name_length;
-  unsigned int org_name_length;
-  unsigned int table_length;
-  unsigned int org_table_length;
-  unsigned int db_length;
-  unsigned int catalog_length;
-  unsigned int def_length;
-  unsigned int flags;         /* Div flags */
-  unsigned int decimals;      /* Number of decimals in field */
-  unsigned int charsetnr;     /* Character set */
-  enum enum_field_types type; /* Type of field. See mysql_com.h for types */
-} MYSQL_FIELD;
-
-typedef char **MYSQL_ROW;		/* return data as array of strings */
-typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
-
-#ifndef _global_h
-#if defined(NO_CLIENT_LONG_LONG)
-typedef unsigned long my_ulonglong;
-#elif defined (__WIN__)
-typedef unsigned __int64 my_ulonglong;
-#else
-typedef unsigned long long my_ulonglong;
-#endif
-#endif
-
-#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
-
-/* backward compatibility define - to be removed eventually */
-#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED
-
-typedef struct st_mysql_rows {
-  struct st_mysql_rows *next;		/* list of rows */
-  MYSQL_ROW data;
-  unsigned long length;
-} MYSQL_ROWS;
-
-typedef MYSQL_ROWS *MYSQL_ROW_OFFSET;	/* offset to current row */
-
-#include "my_alloc.h"
-
-typedef struct embedded_query_result EMBEDDED_QUERY_RESULT;
-typedef struct st_mysql_data {
-  my_ulonglong rows;
-  unsigned int fields;
-  MYSQL_ROWS *data;
-  MEM_ROOT alloc;
-  /* extra info for embedded library */
-  struct embedded_query_result *embedded_info;
-} MYSQL_DATA;
-
-enum mysql_option 
-{
-  MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
-  MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
-  MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
-  MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
-  MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT,
-  MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
-  MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
-  MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT
-};
-
-struct st_mysql_options {
-  unsigned int connect_timeout, read_timeout, write_timeout;
-  unsigned int port, protocol;
-  unsigned long client_flag;
-  char *host,*user,*password,*unix_socket,*db;
-  struct st_dynamic_array *init_commands;
-  char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
-  char *ssl_key;				/* PEM key file */
-  char *ssl_cert;				/* PEM cert file */
-  char *ssl_ca;					/* PEM CA file */
-  char *ssl_capath;				/* PEM directory of CA-s? */
-  char *ssl_cipher;				/* cipher to use */
-  char *shared_memory_base_name;
-  unsigned long max_allowed_packet;
-  my_bool use_ssl;				/* if to use SSL or not */
-  my_bool compress,named_pipe;
- /*
-   On connect, find out the replication role of the server, and
-   establish connections to all the peers
- */
-  my_bool rpl_probe;
- /*
-   Each call to mysql_real_query() will parse it to tell if it is a read
-   or a write, and direct it to the slave or the master
- */
-  my_bool rpl_parse;
- /*
-   If set, never read from a master, only from slave, when doing
-   a read that is replication-aware
- */
-  my_bool no_master_reads;
-#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
-  my_bool separate_thread;
-#endif
-  enum mysql_option methods_to_use;
-  char *client_ip;
-  /* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */
-  my_bool secure_auth;
-  /* 0 - never report, 1 - always report (default) */
-  my_bool report_data_truncation;
-
-  /* function pointers for local infile support */
-  int (*local_infile_init)(void **, const char *, void *);
-  int (*local_infile_read)(void *, char *, unsigned int);
-  void (*local_infile_end)(void *);
-  int (*local_infile_error)(void *, char *, unsigned int);
-  void *local_infile_userdata;
-};
-
-enum mysql_status 
-{
-  MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT
-};
-
-enum mysql_protocol_type 
-{
-  MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
-  MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
-};
-/*
-  There are three types of queries - the ones that have to go to
-  the master, the ones that go to a slave, and the adminstrative
-  type which must happen on the pivot connectioin
-*/
-enum mysql_rpl_type 
-{
-  MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
-};
-
-typedef struct character_set
-{
-  unsigned int      number;     /* character set number              */
-  unsigned int      state;      /* character set state               */
-  const char        *csname;    /* collation name                    */
-  const char        *name;      /* character set name                */
-  const char        *comment;   /* comment                           */
-  const char        *dir;       /* character set directory           */
-  unsigned int      mbminlen;   /* min. length for multibyte strings */
-  unsigned int      mbmaxlen;   /* max. length for multibyte strings */
-} MY_CHARSET_INFO;
-
-struct st_mysql_methods;
-
-typedef struct st_mysql
-{
-  NET		net;			/* Communication parameters */
-  gptr		connector_fd;		/* ConnectorFd for SSL */
-  char		*host,*user,*passwd,*unix_socket,*server_version,*host_info,*info;
-  char          *db;
-  struct charset_info_st *charset;
-  MYSQL_FIELD	*fields;
-  MEM_ROOT	field_alloc;
-  my_ulonglong affected_rows;
-  my_ulonglong insert_id;		/* id if insert on table with NEXTNR */
-  my_ulonglong extra_info;		/* Not used */
-  unsigned long thread_id;		/* Id for connection in server */
-  unsigned long packet_length;
-  unsigned int	port;
-  unsigned long client_flag,server_capabilities;
-  unsigned int	protocol_version;
-  unsigned int	field_count;
-  unsigned int 	server_status;
-  unsigned int  server_language;
-  unsigned int	warning_count;
-  struct st_mysql_options options;
-  enum mysql_status status;
-  my_bool	free_me;		/* If free in mysql_close */
-  my_bool	reconnect;		/* set to 1 if automatic reconnect */
-
-  /* session-wide random string */
-  char	        scramble[SCRAMBLE_LENGTH+1];
-
- /*
-   Set if this is the original connection, not a master or a slave we have
-   added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave()
- */
-  my_bool rpl_pivot;
-  /*
-    Pointers to the master, and the next slave connections, points to
-    itself if lone connection.
-  */
-  struct st_mysql* master, *next_slave;
-
-  struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
- /* needed for send/read/store/use result to work correctly with replication */
-  struct st_mysql* last_used_con;
-
-  LIST  *stmts;                     /* list of all statements */
-  const struct st_mysql_methods *methods;
-  void *thd;
-  /*
-    Points to boolean flag in MYSQL_RES  or MYSQL_STMT. We set this flag 
-    from mysql_stmt_close if close had to cancel result set of this object.
-  */
-  my_bool *unbuffered_fetch_owner;
-#if defined(EMBEDDED_LIBRARY) || defined(EMBEDDED_LIBRARY_COMPATIBLE) || MYSQL_VERSION_ID >= 50100
-  /* needed for embedded server - no net buffer to store the 'info' */
-  char *info_buffer;
-#endif
-} MYSQL;
-
-typedef struct st_mysql_res {
-  my_ulonglong row_count;
-  MYSQL_FIELD	*fields;
-  MYSQL_DATA	*data;
-  MYSQL_ROWS	*data_cursor;
-  unsigned long *lengths;		/* column lengths of current row */
-  MYSQL		*handle;		/* for unbuffered reads */
-  MEM_ROOT	field_alloc;
-  unsigned int	field_count, current_field;
-  MYSQL_ROW	row;			/* If unbuffered read */
-  MYSQL_ROW	current_row;		/* buffer to current row */
-  my_bool	eof;			/* Used by mysql_fetch_row */
-  /* mysql_stmt_close() had to cancel this result */
-  my_bool       unbuffered_fetch_cancelled;  
-  const struct st_mysql_methods *methods;
-} MYSQL_RES;
-
-#define MAX_MYSQL_MANAGER_ERR 256  
-#define MAX_MYSQL_MANAGER_MSG 256
-
-#define MANAGER_OK           200
-#define MANAGER_INFO         250
-#define MANAGER_ACCESS       401
-#define MANAGER_CLIENT_ERR   450
-#define MANAGER_INTERNAL_ERR 500
-
-#if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT)
-#define MYSQL_CLIENT
-#endif
-
-
-typedef struct st_mysql_manager
-{
-  NET net;
-  char *host,*user,*passwd;
-  unsigned int port;
-  my_bool free_me;
-  my_bool eof;
-  int cmd_status;
-  int last_errno;
-  char* net_buf,*net_buf_pos,*net_data_end;
-  int net_buf_size;
-  char last_error[MAX_MYSQL_MANAGER_ERR];
-} MYSQL_MANAGER;
-
-typedef struct st_mysql_parameters
-{
-  unsigned long *p_max_allowed_packet;
-  unsigned long *p_net_buffer_length;
-} MYSQL_PARAMETERS;
-
-#if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
-#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
-#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length)
-#endif
-
-/*
-  Set up and bring down the server; to ensure that applications will
-  work when linked against either the standard client library or the
-  embedded server library, these functions should be called.
-*/
-int STDCALL mysql_server_init(int argc, char **argv, char **groups);
-void STDCALL mysql_server_end(void);
-/*
-  mysql_server_init/end need to be called when using libmysqld or
-  libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
-  you don't need to call it explicitely; but you need to call
-  mysql_server_end() to free memory). The names are a bit misleading
-  (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
-  names which suit well whether you're using libmysqld or libmysqlclient. We
-  intend to promote these aliases over the mysql_server* ones.
-*/
-#define mysql_library_init mysql_server_init
-#define mysql_library_end mysql_server_end
-
-MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void);
-
-/*
-  Set up and bring down a thread; these function should be called
-  for each thread in an application which opens at least one MySQL
-  connection.  All uses of the connection(s) should be between these
-  function calls.
-*/
-my_bool STDCALL mysql_thread_init(void);
-void STDCALL mysql_thread_end(void);
-
-/*
-  Functions to get information from the MYSQL and MYSQL_RES structures
-  Should definitely be used if one uses shared libraries.
-*/
-
-my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res);
-unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
-my_bool STDCALL mysql_eof(MYSQL_RES *res);
-MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res,
-					      unsigned int fieldnr);
-MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
-MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res);
-MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res);
-
-unsigned int STDCALL mysql_field_count(MYSQL *mysql);
-my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
-my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
-unsigned int STDCALL mysql_errno(MYSQL *mysql);
-const char * STDCALL mysql_error(MYSQL *mysql);
-const char *STDCALL mysql_sqlstate(MYSQL *mysql);
-unsigned int STDCALL mysql_warning_count(MYSQL *mysql);
-const char * STDCALL mysql_info(MYSQL *mysql);
-unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
-const char * STDCALL mysql_character_set_name(MYSQL *mysql);
-int          STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname);
-
-MYSQL *		STDCALL mysql_init(MYSQL *mysql);
-my_bool		STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
-				      const char *cert, const char *ca,
-				      const char *capath, const char *cipher);
-my_bool		STDCALL mysql_change_user(MYSQL *mysql, const char *user, 
-					  const char *passwd, const char *db);
-MYSQL *		STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
-					   const char *user,
-					   const char *passwd,
-					   const char *db,
-					   unsigned int port,
-					   const char *unix_socket,
-					   unsigned long clientflag);
-int		STDCALL mysql_select_db(MYSQL *mysql, const char *db);
-int		STDCALL mysql_query(MYSQL *mysql, const char *q);
-int		STDCALL mysql_send_query(MYSQL *mysql, const char *q,
-					 unsigned long length);
-int		STDCALL mysql_real_query(MYSQL *mysql, const char *q,
-					unsigned long length);
-MYSQL_RES *     STDCALL mysql_store_result(MYSQL *mysql);
-MYSQL_RES *     STDCALL mysql_use_result(MYSQL *mysql);
-
-/* perform query on master */
-my_bool		STDCALL mysql_master_query(MYSQL *mysql, const char *q,
-					   unsigned long length);
-my_bool		STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
-						unsigned long length);
-/* perform query on slave */  
-my_bool		STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
-					  unsigned long length);
-my_bool		STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
-					       unsigned long length);
-void        STDCALL mysql_get_character_set_info(MYSQL *mysql,
-                           MY_CHARSET_INFO *charset);
-
-/* local infile support */
-
-#define LOCAL_INFILE_ERROR_LEN 512
-
-void
-mysql_set_local_infile_handler(MYSQL *mysql,
-                               int (*local_infile_init)(void **, const char *,
-                            void *),
-                               int (*local_infile_read)(void *, char *,
-							unsigned int),
-                               void (*local_infile_end)(void *),
-                               int (*local_infile_error)(void *, char*,
-							 unsigned int),
-                               void *);
-
-void
-mysql_set_local_infile_default(MYSQL *mysql);
-
-
-/*
-  enable/disable parsing of all queries to decide if they go on master or
-  slave
-*/
-void            STDCALL mysql_enable_rpl_parse(MYSQL* mysql);
-void            STDCALL mysql_disable_rpl_parse(MYSQL* mysql);
-/* get the value of the parse flag */  
-int             STDCALL mysql_rpl_parse_enabled(MYSQL* mysql);
-
-/*  enable/disable reads from master */
-void            STDCALL mysql_enable_reads_from_master(MYSQL* mysql);
-void            STDCALL mysql_disable_reads_from_master(MYSQL* mysql);
-/* get the value of the master read flag */  
-my_bool		STDCALL mysql_reads_from_master_enabled(MYSQL* mysql);
-
-enum mysql_rpl_type     STDCALL mysql_rpl_query_type(const char* q, int len);  
-
-/* discover the master and its slaves */  
-my_bool		STDCALL mysql_rpl_probe(MYSQL* mysql);
-
-/* set the master, close/free the old one, if it is not a pivot */
-int             STDCALL mysql_set_master(MYSQL* mysql, const char* host,
-					 unsigned int port,
-					 const char* user,
-					 const char* passwd);
-int             STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
-					unsigned int port,
-					const char* user,
-					const char* passwd);
-
-int		STDCALL mysql_shutdown(MYSQL *mysql,
-                                       enum mysql_enum_shutdown_level
-                                       shutdown_level);
-int		STDCALL mysql_dump_debug_info(MYSQL *mysql);
-int		STDCALL mysql_refresh(MYSQL *mysql,
-				     unsigned int refresh_options);
-int		STDCALL mysql_kill(MYSQL *mysql,unsigned long pid);
-int		STDCALL mysql_set_server_option(MYSQL *mysql,
-						enum enum_mysql_set_option
-						option);
-int		STDCALL mysql_ping(MYSQL *mysql);
-const char *	STDCALL mysql_stat(MYSQL *mysql);
-const char *	STDCALL mysql_get_server_info(MYSQL *mysql);
-const char *	STDCALL mysql_get_client_info(void);
-unsigned long	STDCALL mysql_get_client_version(void);
-const char *	STDCALL mysql_get_host_info(MYSQL *mysql);
-unsigned long	STDCALL mysql_get_server_version(MYSQL *mysql);
-unsigned int	STDCALL mysql_get_proto_info(MYSQL *mysql);
-MYSQL_RES *	STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
-MYSQL_RES *	STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
-MYSQL_RES *	STDCALL mysql_list_processes(MYSQL *mysql);
-int		STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
-				      const char *arg);
-void		STDCALL mysql_free_result(MYSQL_RES *result);
-void		STDCALL mysql_data_seek(MYSQL_RES *result,
-					my_ulonglong offset);
-MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result,
-						MYSQL_ROW_OFFSET offset);
-MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
-					   MYSQL_FIELD_OFFSET offset);
-MYSQL_ROW	STDCALL mysql_fetch_row(MYSQL_RES *result);
-unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result);
-MYSQL_FIELD *	STDCALL mysql_fetch_field(MYSQL_RES *result);
-MYSQL_RES *     STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
-					  const char *wild);
-unsigned long	STDCALL mysql_escape_string(char *to,const char *from,
-					    unsigned long from_length);
-unsigned long	STDCALL mysql_hex_string(char *to,const char *from,
-                                         unsigned long from_length);
-unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
-					       char *to,const char *from,
-					       unsigned long length);
-void		STDCALL mysql_debug(const char *debug);
-char *		STDCALL mysql_odbc_escape_string(MYSQL *mysql,
-						 char *to,
-						 unsigned long to_length,
-						 const char *from,
-						 unsigned long from_length,
-						 void *param,
-						 char *
-						 (*extend_buffer)
-						 (void *, char *to,
-						  unsigned long *length));
-void 		STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
-unsigned int	STDCALL mysql_thread_safe(void);
-my_bool		STDCALL mysql_embedded(void);
-MYSQL_MANAGER*  STDCALL mysql_manager_init(MYSQL_MANAGER* con);  
-MYSQL_MANAGER*  STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
-					      const char* host,
-					      const char* user,
-					      const char* passwd,
-					      unsigned int port);
-void            STDCALL mysql_manager_close(MYSQL_MANAGER* con);
-int             STDCALL mysql_manager_command(MYSQL_MANAGER* con,
-						const char* cmd, int cmd_len);
-int             STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
-						  char* res_buf,
-						 int res_buf_size);
-my_bool         STDCALL mysql_read_query_result(MYSQL *mysql);
-
-
-/*
-  The following definitions are added for the enhanced 
-  client-server protocol
-*/
-
-/* statement state */
-enum enum_mysql_stmt_state
-{
-  MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE,
-  MYSQL_STMT_FETCH_DONE
-};
-
-
-/*
-  This structure is used to define bind information, and
-  internally by the client library.
-  Public members with their descriptions are listed below
-  (conventionally `On input' refers to the binds given to
-  mysql_stmt_bind_param, `On output' refers to the binds given
-  to mysql_stmt_bind_result):
-
-  buffer_type    - One of the MYSQL_* types, used to describe
-                   the host language type of buffer.
-                   On output: if column type is different from
-                   buffer_type, column value is automatically converted
-                   to buffer_type before it is stored in the buffer.
-  buffer         - On input: points to the buffer with input data.
-                   On output: points to the buffer capable to store
-                   output data.
-                   The type of memory pointed by buffer must correspond
-                   to buffer_type. See the correspondence table in
-                   the comment to mysql_stmt_bind_param.
-
-  The two above members are mandatory for any kind of bind.
-
-  buffer_length  - the length of the buffer. You don't have to set
-                   it for any fixed length buffer: float, double,
-                   int, etc. It must be set however for variable-length
-                   types, such as BLOBs or STRINGs.
-
-  length         - On input: in case when lengths of input values
-                   are different for each execute, you can set this to
-                   point at a variable containining value length. This
-                   way the value length can be different in each execute.
-                   If length is not NULL, buffer_length is not used.
-                   Note, length can even point at buffer_length if
-                   you keep bind structures around while fetching:
-                   this way you can change buffer_length before
-                   each execution, everything will work ok.
-                   On output: if length is set, mysql_stmt_fetch will
-                   write column length into it.
-
-  is_null        - On input: points to a boolean variable that should
-                   be set to TRUE for NULL values.
-                   This member is useful only if your data may be
-                   NULL in some but not all cases.
-                   If your data is never NULL, is_null should be set to 0.
-                   If your data is always NULL, set buffer_type
-                   to MYSQL_TYPE_NULL, and is_null will not be used.
-
-  is_unsigned    - On input: used to signify that values provided for one
-                   of numeric types are unsigned.
-                   On output describes signedness of the output buffer.
-                   If, taking into account is_unsigned flag, column data
-                   is out of range of the output buffer, data for this column
-                   is regarded truncated. Note that this has no correspondence
-                   to the sign of result set column, if you need to find it out
-                   use mysql_stmt_result_metadata.
-  error          - where to write a truncation error if it is present.
-                   possible error value is:
-                   0  no truncation
-                   1  value is out of range or buffer is too small
-
-  Please note that MYSQL_BIND also has internals members.
-*/
-
-typedef struct st_mysql_bind
-{
-  unsigned long	*length;          /* output length pointer */
-  my_bool       *is_null;	  /* Pointer to null indicator */
-  void		*buffer;	  /* buffer to get/put data */
-  /* set this if you want to track data truncations happened during fetch */
-  my_bool       *error;
-  enum enum_field_types buffer_type;	/* buffer type */
-  /* output buffer length, must be set when fetching str/binary */
-  unsigned long buffer_length;
-  unsigned char *row_ptr;         /* for the current data position */
-  unsigned long offset;           /* offset position for char/binary fetch */
-  unsigned long	length_value;     /* Used if length is 0 */
-  unsigned int	param_number;	  /* For null count and error messages */
-  unsigned int  pack_length;	  /* Internal length for packed data */
-  my_bool       error_value;      /* used if error is 0 */
-  my_bool       is_unsigned;      /* set if integer type is unsigned */
-  my_bool	long_data_used;	  /* If used with mysql_send_long_data */
-  my_bool	is_null_value;    /* Used if is_null is 0 */
-  void (*store_param_func)(NET *net, struct st_mysql_bind *param);
-  void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *,
-                       unsigned char **row);
-  void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *,
-		      unsigned char **row);
-} MYSQL_BIND;
-
-
-/* statement handler */
-typedef struct st_mysql_stmt
-{
-  MEM_ROOT       mem_root;             /* root allocations */
-  LIST           list;                 /* list to keep track of all stmts */
-  MYSQL          *mysql;               /* connection handle */
-  MYSQL_BIND     *params;              /* input parameters */
-  MYSQL_BIND     *bind;                /* output parameters */
-  MYSQL_FIELD    *fields;              /* result set metadata */
-  MYSQL_DATA     result;               /* cached result set */
-  MYSQL_ROWS     *data_cursor;         /* current row in cached result */
-  /* copy of mysql->affected_rows after statement execution */
-  my_ulonglong   affected_rows;
-  my_ulonglong   insert_id;            /* copy of mysql->insert_id */
-  /*
-    mysql_stmt_fetch() calls this function to fetch one row (it's different
-    for buffered, unbuffered and cursor fetch).
-  */
-  int            (*read_row_func)(struct st_mysql_stmt *stmt, 
-                                  unsigned char **row);
-  unsigned long	 stmt_id;	       /* Id for prepared statement */
-  unsigned long  flags;                /* i.e. type of cursor to open */
-  unsigned long  prefetch_rows;        /* number of rows per one COM_FETCH */
-  /*
-    Copied from mysql->server_status after execute/fetch to know
-    server-side cursor status for this statement.
-  */
-  unsigned int   server_status;
-  unsigned int	 last_errno;	       /* error code */
-  unsigned int   param_count;          /* input parameter count */
-  unsigned int   field_count;          /* number of columns in result set */
-  enum enum_mysql_stmt_state state;    /* statement state */
-  char		 last_error[MYSQL_ERRMSG_SIZE]; /* error message */
-  char		 sqlstate[SQLSTATE_LENGTH+1];
-  /* Types of input parameters should be sent to server */
-  my_bool        send_types_to_server;
-  my_bool        bind_param_done;      /* input buffers were supplied */
-  unsigned char  bind_result_done;     /* output buffers were supplied */
-  /* mysql_stmt_close() had to cancel this result */
-  my_bool       unbuffered_fetch_cancelled;  
-  /*
-    Is set to true if we need to calculate field->max_length for 
-    metadata fields when doing mysql_stmt_store_result.
-  */
-  my_bool       update_max_length;     
-} MYSQL_STMT;
-
-enum enum_stmt_attr_type
-{
-  /*
-    When doing mysql_stmt_store_result calculate max_length attribute
-    of statement metadata. This is to be consistent with the old API, 
-    where this was done automatically.
-    In the new API we do that only by request because it slows down
-    mysql_stmt_store_result sufficiently.
-  */
-  STMT_ATTR_UPDATE_MAX_LENGTH,
-  /*
-    unsigned long with combination of cursor flags (read only, for update,
-    etc)
-  */
-  STMT_ATTR_CURSOR_TYPE,
-  /*
-    Amount of rows to retrieve from server per one fetch if using cursors.
-    Accepts unsigned long attribute in the range 1 - ulong_max
-  */
-  STMT_ATTR_PREFETCH_ROWS
-};
-
-
-typedef struct st_mysql_methods
-{
-  my_bool (*read_query_result)(MYSQL *mysql);
-  my_bool (*advanced_command)(MYSQL *mysql,
-			      enum enum_server_command command,
-			      const char *header,
-			      unsigned long header_length,
-			      const char *arg,
-			      unsigned long arg_length,
-			      my_bool skip_check);
-  MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
-			   unsigned int fields);
-  MYSQL_RES * (*use_result)(MYSQL *mysql);
-  void (*fetch_lengths)(unsigned long *to, 
-			MYSQL_ROW column, unsigned int field_count);
-  void (*flush_use_result)(MYSQL *mysql);
-#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
-  MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
-  my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
-  int (*stmt_execute)(MYSQL_STMT *stmt);
-  int (*read_binary_rows)(MYSQL_STMT *stmt);
-  int (*unbuffered_fetch)(MYSQL *mysql, char **row);
-  void (*free_embedded_thd)(MYSQL *mysql);
-  const char *(*read_statistics)(MYSQL *mysql);
-  my_bool (*next_result)(MYSQL *mysql);
-  int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd);
-  int (*read_rows_from_cursor)(MYSQL_STMT *stmt);
-#endif
-} MYSQL_METHODS;
-
-
-MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql);
-int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
-                               unsigned long length);
-int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
-int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
-int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, 
-                                    unsigned int column,
-                                    unsigned long offset);
-int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
-unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt);
-my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
-                                    enum enum_stmt_attr_type attr_type,
-                                    const void *attr);
-my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
-                                    enum enum_stmt_attr_type attr_type,
-                                    void *attr);
-my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
-my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
-my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
-my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt);
-my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);
-my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, 
-                                          unsigned int param_number,
-                                          const char *data, 
-                                          unsigned long length);
-MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt);
-MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt);
-unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt);
-const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt);
-const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt);
-MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, 
-                                             MYSQL_ROW_OFFSET offset);
-MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt);
-void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
-my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt);
-my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
-my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt);
-unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt);
-
-my_bool STDCALL mysql_commit(MYSQL * mysql);
-my_bool STDCALL mysql_rollback(MYSQL * mysql);
-my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
-my_bool STDCALL mysql_more_results(MYSQL *mysql);
-int STDCALL mysql_next_result(MYSQL *mysql);
-void STDCALL mysql_close(MYSQL *sock);
-
-
-/* status return codes */
-#define MYSQL_NO_DATA        100
-#define MYSQL_DATA_TRUNCATED 101
-
-#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
-
-#ifdef USE_OLD_FUNCTIONS
-MYSQL *		STDCALL mysql_connect(MYSQL *mysql, const char *host,
-				      const char *user, const char *passwd);
-int		STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
-int		STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
-#define	 mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
-#endif
-#define HAVE_MYSQL_REAL_CONNECT
-
-/*
-  The following functions are mainly exported because of mysqlbinlog;
-  They are not for general usage
-*/
-
-#define simple_command(mysql, command, arg, length, skip_check) \
-  (*(mysql)->methods->advanced_command)(mysql, command,         \
-					NullS, 0, arg, length, skip_check)
-unsigned long net_safe_read(MYSQL* mysql);
-
-#ifdef __NETWARE__
-#pragma pack(pop)		/* restore alignment */
-#endif
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif /* _mysql_h */
diff --git a/3rdparty/mysql/include/mysql_com.h b/3rdparty/mysql/include/mysql_com.h
deleted file mode 100644
index ec1c13379..000000000
--- a/3rdparty/mysql/include/mysql_com.h
+++ /dev/null
@@ -1,452 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/*
-** Common definition between mysql server & client
-*/
-
-#ifndef _mysql_com_h
-#define _mysql_com_h
-
-#define NAME_LEN	64		/* Field/table name length */
-#define HOSTNAME_LENGTH 60
-#define USERNAME_LENGTH 16
-#define SERVER_VERSION_LENGTH 60
-#define SQLSTATE_LENGTH 5
-
-/*
-  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
-  username and hostname parts of the user identifier with trailing zero in
-  MySQL standard format:
-  user_name_part@host_name_part\0
-*/
-#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
-
-#define LOCAL_HOST	"localhost"
-#define LOCAL_HOST_NAMEDPIPE "."
-
-
-#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
-#define MYSQL_NAMEDPIPE "MySQL"
-#define MYSQL_SERVICENAME "MySQL"
-#endif /* __WIN__ */
-
-/*
-  You should add new commands to the end of this list, otherwise old
-  servers won't be able to handle them as 'unsupported'.
-*/
-
-enum enum_server_command
-{
-  COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
-  COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
-  COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING,
-  COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
-  COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
-  COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
-  COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH,
-  /* don't forget to update const char *command_name[] in sql_parse.cc */
-
-  /* Must be last */
-  COM_END
-};
-
-
-/*
-  Length of random string sent by server on handshake; this is also length of
-  obfuscated password, recieved from client
-*/
-#define SCRAMBLE_LENGTH 20
-#define SCRAMBLE_LENGTH_323 8
-/* length of password stored in the db: new passwords are preceeded with '*' */
-#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
-#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
-
-
-#define NOT_NULL_FLAG	1		/* Field can't be NULL */
-#define PRI_KEY_FLAG	2		/* Field is part of a primary key */
-#define UNIQUE_KEY_FLAG 4		/* Field is part of a unique key */
-#define MULTIPLE_KEY_FLAG 8		/* Field is part of a key */
-#define BLOB_FLAG	16		/* Field is a blob */
-#define UNSIGNED_FLAG	32		/* Field is unsigned */
-#define ZEROFILL_FLAG	64		/* Field is zerofill */
-#define BINARY_FLAG	128		/* Field is binary   */
-
-/* The following are only sent to new clients */
-#define ENUM_FLAG	256		/* field is an enum */
-#define AUTO_INCREMENT_FLAG 512		/* field is a autoincrement field */
-#define TIMESTAMP_FLAG	1024		/* Field is a timestamp */
-#define SET_FLAG	2048		/* field is a set */
-#define NO_DEFAULT_VALUE_FLAG 4096	/* Field doesn't have default value */
-#define NUM_FLAG	32768		/* Field is num (for clients) */
-#define PART_KEY_FLAG	16384		/* Intern; Part of some key */
-#define GROUP_FLAG	32768		/* Intern: Group field */
-#define UNIQUE_FLAG	65536		/* Intern: Used by sql_yacc */
-#define BINCMP_FLAG	131072		/* Intern: Used by sql_yacc */
-
-#define REFRESH_GRANT		1	/* Refresh grant tables */
-#define REFRESH_LOG		2	/* Start on new log file */
-#define REFRESH_TABLES		4	/* close all tables */
-#define REFRESH_HOSTS		8	/* Flush host cache */
-#define REFRESH_STATUS		16	/* Flush status variables */
-#define REFRESH_THREADS		32	/* Flush thread cache */
-#define REFRESH_SLAVE           64      /* Reset master info and restart slave
-					   thread */
-#define REFRESH_MASTER          128     /* Remove all bin logs in the index
-					   and truncate the index */
-
-/* The following can't be set with mysql_refresh() */
-#define REFRESH_READ_LOCK	16384	/* Lock tables for read */
-#define REFRESH_FAST		32768	/* Intern flag */
-
-/* RESET (remove all queries) from query cache */
-#define REFRESH_QUERY_CACHE	65536
-#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
-#define REFRESH_DES_KEY_FILE	0x40000L
-#define REFRESH_USER_RESOURCES	0x80000L
-
-#define CLIENT_LONG_PASSWORD	1	/* new more secure passwords */
-#define CLIENT_FOUND_ROWS	2	/* Found instead of affected rows */
-#define CLIENT_LONG_FLAG	4	/* Get all column flags */
-#define CLIENT_CONNECT_WITH_DB	8	/* One can specify db on connect */
-#define CLIENT_NO_SCHEMA	16	/* Don't allow database.table.column */
-#define CLIENT_COMPRESS		32	/* Can use compression protocol */
-#define CLIENT_ODBC		64	/* Odbc client */
-#define CLIENT_LOCAL_FILES	128	/* Can use LOAD DATA LOCAL */
-#define CLIENT_IGNORE_SPACE	256	/* Ignore spaces before '(' */
-#define CLIENT_PROTOCOL_41	512	/* New 4.1 protocol */
-#define CLIENT_INTERACTIVE	1024	/* This is an interactive client */
-#define CLIENT_SSL              2048	/* Switch to SSL after handshake */
-#define CLIENT_IGNORE_SIGPIPE   4096    /* IGNORE sigpipes */
-#define CLIENT_TRANSACTIONS	8192	/* Client knows about transactions */
-#define CLIENT_RESERVED         16384   /* Old flag for 4.1 protocol  */
-#define CLIENT_SECURE_CONNECTION 32768  /* New 4.1 authentication */
-#define CLIENT_MULTI_STATEMENTS 65536   /* Enable/disable multi-stmt support */
-#define CLIENT_MULTI_RESULTS    131072  /* Enable/disable multi-results */
-#define CLIENT_REMEMBER_OPTIONS	(((ulong) 1) << 31)
-
-#define SERVER_STATUS_IN_TRANS     1	/* Transaction has started */
-#define SERVER_STATUS_AUTOCOMMIT   2	/* Server in auto_commit mode */
-#define SERVER_STATUS_MORE_RESULTS 4	/* More results on server */
-#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
-#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
-#define SERVER_QUERY_NO_INDEX_USED      32
-/*
-  The server was able to fulfill the clients request and opened a
-  read-only non-scrollable cursor for a query. This flag comes
-  in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
-*/
-#define SERVER_STATUS_CURSOR_EXISTS 64
-/*
-  This flag is sent when a read-only cursor is exhausted, in reply to
-  COM_STMT_FETCH command.
-*/
-#define SERVER_STATUS_LAST_ROW_SENT 128
-#define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
-#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
-
-#define MYSQL_ERRMSG_SIZE	512
-#define NET_READ_TIMEOUT	30		/* Timeout on read */
-#define NET_WRITE_TIMEOUT	60		/* Timeout on write */
-#define NET_WAIT_TIMEOUT	8*60*60		/* Wait for new query */
-
-#define ONLY_KILL_QUERY         1
-
-struct st_vio;					/* Only C */
-typedef struct st_vio Vio;
-
-#define MAX_TINYINT_WIDTH       3       /* Max width for a TINY w.o. sign */
-#define MAX_SMALLINT_WIDTH      5       /* Max width for a SHORT w.o. sign */
-#define MAX_MEDIUMINT_WIDTH     8       /* Max width for a INT24 w.o. sign */
-#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
-#define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
-#define MAX_CHAR_WIDTH		255	/* Max length for a CHAR colum */
-#define MAX_BLOB_WIDTH		8192	/* Default width for blob */
-
-typedef struct st_net {
-#if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
-  Vio* vio;
-  unsigned char *buff,*buff_end,*write_pos,*read_pos;
-  my_socket fd;					/* For Perl DBI/dbd */
-  unsigned long max_packet,max_packet_size;
-  unsigned int pkt_nr,compress_pkt_nr;
-  unsigned int write_timeout, read_timeout, retry_count;
-  int fcntl;
-  my_bool compress;
-  /*
-    The following variable is set if we are doing several queries in one
-    command ( as in LOAD TABLE ... FROM MASTER ),
-    and do not want to confuse the client with OK at the wrong time
-  */
-  unsigned long remain_in_buf,length, buf_length, where_b;
-  unsigned int *return_status;
-  unsigned char reading_or_writing;
-  char save_char;
-  my_bool no_send_ok;  /* For SPs and other things that do multiple stmts */
-  my_bool no_send_eof; /* For SPs' first version read-only cursors */
-  /*
-    Set if OK packet is already sent, and we do not need to send error
-    messages
-  */
-  my_bool no_send_error;
-  /*
-    Pointer to query object in query cache, do not equal NULL (0) for
-    queries in cache that have not stored its results yet
-  */
-#endif
-  char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1];
-  unsigned int last_errno;
-  unsigned char error;
-  gptr query_cache_query;
-  my_bool report_error; /* We should report error (we have unreported error) */
-  my_bool return_errno;
-} NET;
-
-#define packet_error (~(unsigned long) 0)
-
-enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
-			MYSQL_TYPE_SHORT,  MYSQL_TYPE_LONG,
-			MYSQL_TYPE_FLOAT,  MYSQL_TYPE_DOUBLE,
-			MYSQL_TYPE_NULL,   MYSQL_TYPE_TIMESTAMP,
-			MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
-			MYSQL_TYPE_DATE,   MYSQL_TYPE_TIME,
-			MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
-			MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
-			MYSQL_TYPE_BIT,
-                        MYSQL_TYPE_NEWDECIMAL=246,
-			MYSQL_TYPE_ENUM=247,
-			MYSQL_TYPE_SET=248,
-			MYSQL_TYPE_TINY_BLOB=249,
-			MYSQL_TYPE_MEDIUM_BLOB=250,
-			MYSQL_TYPE_LONG_BLOB=251,
-			MYSQL_TYPE_BLOB=252,
-			MYSQL_TYPE_VAR_STRING=253,
-			MYSQL_TYPE_STRING=254,
-			MYSQL_TYPE_GEOMETRY=255
-
-};
-
-/* For backward compatibility */
-#define CLIENT_MULTI_QUERIES    CLIENT_MULTI_STATEMENTS    
-#define FIELD_TYPE_DECIMAL     MYSQL_TYPE_DECIMAL
-#define FIELD_TYPE_NEWDECIMAL  MYSQL_TYPE_NEWDECIMAL
-#define FIELD_TYPE_TINY        MYSQL_TYPE_TINY
-#define FIELD_TYPE_SHORT       MYSQL_TYPE_SHORT
-#define FIELD_TYPE_LONG        MYSQL_TYPE_LONG
-#define FIELD_TYPE_FLOAT       MYSQL_TYPE_FLOAT
-#define FIELD_TYPE_DOUBLE      MYSQL_TYPE_DOUBLE
-#define FIELD_TYPE_NULL        MYSQL_TYPE_NULL
-#define FIELD_TYPE_TIMESTAMP   MYSQL_TYPE_TIMESTAMP
-#define FIELD_TYPE_LONGLONG    MYSQL_TYPE_LONGLONG
-#define FIELD_TYPE_INT24       MYSQL_TYPE_INT24
-#define FIELD_TYPE_DATE        MYSQL_TYPE_DATE
-#define FIELD_TYPE_TIME        MYSQL_TYPE_TIME
-#define FIELD_TYPE_DATETIME    MYSQL_TYPE_DATETIME
-#define FIELD_TYPE_YEAR        MYSQL_TYPE_YEAR
-#define FIELD_TYPE_NEWDATE     MYSQL_TYPE_NEWDATE
-#define FIELD_TYPE_ENUM        MYSQL_TYPE_ENUM
-#define FIELD_TYPE_SET         MYSQL_TYPE_SET
-#define FIELD_TYPE_TINY_BLOB   MYSQL_TYPE_TINY_BLOB
-#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
-#define FIELD_TYPE_LONG_BLOB   MYSQL_TYPE_LONG_BLOB
-#define FIELD_TYPE_BLOB        MYSQL_TYPE_BLOB
-#define FIELD_TYPE_VAR_STRING  MYSQL_TYPE_VAR_STRING
-#define FIELD_TYPE_STRING      MYSQL_TYPE_STRING
-#define FIELD_TYPE_CHAR        MYSQL_TYPE_TINY
-#define FIELD_TYPE_INTERVAL    MYSQL_TYPE_ENUM
-#define FIELD_TYPE_GEOMETRY    MYSQL_TYPE_GEOMETRY
-#define FIELD_TYPE_BIT         MYSQL_TYPE_BIT
-
-
-/* Shutdown/kill enums and constants */ 
-
-/* Bits for THD::killable. */
-#define MYSQL_SHUTDOWN_KILLABLE_CONNECT    (unsigned char)(1 << 0)
-#define MYSQL_SHUTDOWN_KILLABLE_TRANS      (unsigned char)(1 << 1)
-#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
-#define MYSQL_SHUTDOWN_KILLABLE_UPDATE     (unsigned char)(1 << 3)
-
-enum mysql_enum_shutdown_level {
-  /*
-    We want levels to be in growing order of hardness (because we use number
-    comparisons). Note that DEFAULT does not respect the growing property, but
-    it's ok.
-  */
-  SHUTDOWN_DEFAULT = 0,
-  /* wait for existing connections to finish */
-  SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
-  /* wait for existing trans to finish */
-  SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
-  /* wait for existing updates to finish (=> no partial MyISAM update) */
-  SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
-  /* flush InnoDB buffers and other storage engines' buffers*/
-  SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
-  /* don't flush InnoDB buffers, flush other storage engines' buffers*/
-  SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
-  /* Now the 2 levels of the KILL command */
-#if MYSQL_VERSION_ID >= 50000
-  KILL_QUERY= 254,
-#endif
-  KILL_CONNECTION= 255
-};
-
-
-enum enum_cursor_type
-{
-  CURSOR_TYPE_NO_CURSOR= 0,
-  CURSOR_TYPE_READ_ONLY= 1,
-  CURSOR_TYPE_FOR_UPDATE= 2,
-  CURSOR_TYPE_SCROLLABLE= 4
-};
-
-
-/* options for mysql_set_option */
-enum enum_mysql_set_option
-{
-  MYSQL_OPTION_MULTI_STATEMENTS_ON,
-  MYSQL_OPTION_MULTI_STATEMENTS_OFF
-};
-
-#define net_new_transaction(net) ((net)->pkt_nr=0)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-my_bool	my_net_init(NET *net, Vio* vio);
-void	my_net_local_init(NET *net);
-void	net_end(NET *net);
-void	net_clear(NET *net);
-my_bool net_realloc(NET *net, unsigned long length);
-my_bool	net_flush(NET *net);
-my_bool	my_net_write(NET *net,const char *packet,unsigned long len);
-my_bool	net_write_command(NET *net,unsigned char command,
-			  const char *header, unsigned long head_len,
-			  const char *packet, unsigned long len);
-int	net_real_write(NET *net,const char *packet,unsigned long len);
-unsigned long my_net_read(NET *net);
-
-/*
-  The following function is not meant for normal usage
-  Currently it's used internally by manager.c
-*/
-struct sockaddr;
-int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
-	       unsigned int timeout);
-
-struct rand_struct {
-  unsigned long seed1,seed2,max_value;
-  double max_value_dbl;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-  /* The following is for user defined functions */
-
-enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
-                  DECIMAL_RESULT};
-
-typedef struct st_udf_args
-{
-  unsigned int arg_count;		/* Number of arguments */
-  enum Item_result *arg_type;		/* Pointer to item_results */
-  char **args;				/* Pointer to argument */
-  unsigned long *lengths;		/* Length of string arguments */
-  char *maybe_null;			/* Set to 1 for all maybe_null args */
-  char **attributes;                    /* Pointer to attribute name */
-  unsigned long *attribute_lengths;     /* Length of attribute arguments */
-} UDF_ARGS;
-
-  /* This holds information about the result */
-
-typedef struct st_udf_init
-{
-  my_bool maybe_null;			/* 1 if function can return NULL */
-  unsigned int decimals;		/* for real functions */
-  unsigned long max_length;		/* For string functions */
-  char	  *ptr;				/* free pointer for function data */
-  my_bool const_item;			/* 0 if result is independent of arguments */
-} UDF_INIT;
-
-  /* Constants when using compression */
-#define NET_HEADER_SIZE 4		/* standard header size */
-#define COMP_HEADER_SIZE 3		/* compression header extra size */
-
-  /* Prototypes to password functions */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
-  These functions are used for authentication by client and server and
-  implemented in sql/password.c
-*/
-
-void randominit(struct rand_struct *, unsigned long seed1,
-                unsigned long seed2);
-double my_rnd(struct rand_struct *);
-void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
-
-void hash_password(unsigned long *to, const char *password, unsigned int password_len);
-void make_scrambled_password_323(char *to, const char *password);
-void scramble_323(char *to, const char *message, const char *password);
-my_bool check_scramble_323(const char *, const char *message,
-                           unsigned long *salt);
-void get_salt_from_password_323(unsigned long *res, const char *password);
-void make_password_from_salt_323(char *to, const unsigned long *salt);
-
-void make_scrambled_password(char *to, const char *password);
-void scramble(char *to, const char *message, const char *password);
-my_bool check_scramble(const char *reply, const char *message,
-                       const unsigned char *hash_stage2);
-void get_salt_from_password(unsigned char *res, const char *password);
-void make_password_from_salt(char *to, const unsigned char *hash_stage2);
-char *octet2hex(char *to, const char *str, unsigned int len);
-
-/* end of password.c */
-
-char *get_tty_password(char *opt_message);
-const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
-
-/* Some other useful functions */
-
-my_bool my_init(void);
-extern int modify_defaults_file(const char *file_location, const char *option,
-                                const char *option_value,
-                                const char *section_name, int remove_option);
-int load_defaults(const char *conf_file, const char **groups,
-		  int *argc, char ***argv);
-my_bool my_thread_init(void);
-void my_thread_end(void);
-
-#ifdef _global_h
-ulong STDCALL net_field_length(uchar **packet);
-my_ulonglong net_field_length_ll(uchar **packet);
-char *net_store_length(char *pkg, ulonglong length);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
-#define MYSQL_STMT_HEADER       4
-#define MYSQL_LONG_DATA_HEADER  6
-
-#endif
diff --git a/3rdparty/mysql/include/mysql_time.h b/3rdparty/mysql/include/mysql_time.h
deleted file mode 100644
index 5f4fc12c0..000000000
--- a/3rdparty/mysql/include/mysql_time.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (C) 2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#ifndef _mysql_time_h_
-#define _mysql_time_h_
-
-/*
-  Time declarations shared between the server and client API:
-  you should not add anything to this header unless it's used
-  (and hence should be visible) in mysql.h.
-  If you're looking for a place to add new time-related declaration,
-  it's most likely my_time.h. See also "C API Handling of Date
-  and Time Values" chapter in documentation.
-*/
-
-enum enum_mysql_timestamp_type
-{
-  MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
-  MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
-};
-
-
-/*
-  Structure which is used to represent datetime values inside MySQL.
-
-  We assume that values in this structure are normalized, i.e. year <= 9999,
-  month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions
-  in server such as my_system_gmt_sec() or make_time() family of functions
-  rely on this (actually now usage of make_*() family relies on a bit weaker
-  restriction). Also functions that produce MYSQL_TIME as result ensure this.
-  There is one exception to this rule though if this structure holds time
-  value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold
-  bigger values.
-*/
-typedef struct st_mysql_time
-{
-  unsigned int  year, month, day, hour, minute, second;
-  unsigned long second_part;
-  my_bool       neg;
-  enum enum_mysql_timestamp_type time_type;
-} MYSQL_TIME;
-
-#endif /* _mysql_time_h_ */
diff --git a/3rdparty/mysql/include/mysql_version.h b/3rdparty/mysql/include/mysql_version.h
deleted file mode 100644
index 473a19987..000000000
--- a/3rdparty/mysql/include/mysql_version.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright Abandoned 1996, 1999, 2001 MySQL AB
-   This file is public domain and comes with NO WARRANTY of any kind */
-
-/* Version numbers for protocol & mysqld */
-
-#ifndef _mysql_version_h
-#define _mysql_version_h
-#ifdef _CUSTOMCONFIG_
-#include <custom_conf.h>
-#else
-#define PROTOCOL_VERSION		10
-#define MYSQL_SERVER_VERSION		"5.0.20"
-#define MYSQL_BASE_VERSION		"mysqld-5.0"
-#define MYSQL_SERVER_SUFFIX_DEF	"-community-max-nt"
-#define FRM_VER				6
-#define MYSQL_VERSION_ID		50020
-#define MYSQL_PORT			3306
-#define MYSQL_UNIX_ADDR			"/tmp/mysql.sock"
-#define MYSQL_CONFIG_NAME		"my"
-#define MYSQL_COMPILATION_COMMENT	"MySQL Community Edition - Max (GPL)"
-
-/* mysqld compile time options */
-#endif /* _CUSTOMCONFIG_ */
-
-#ifndef LICENSE
-#define LICENSE				GPL
-#endif /* LICENSE */
-
-#endif /* _mysql_version_h */
diff --git a/3rdparty/mysql/include/raid.h b/3rdparty/mysql/include/raid.h
deleted file mode 100644
index c840afcba..000000000
--- a/3rdparty/mysql/include/raid.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/* Parser needs these defines  always, even if USE_RAID is not defined */
-#define RAID_TYPE_0 1       /* Striping */
-#define RAID_TYPE_x 2       /* Some new modes */
-#define RAID_TYPE_y 3
-
-#define RAID_DEFAULT_CHUNKS 4
-#define RAID_DEFAULT_CHUNKSIZE 256*1024 /* 256kB */
-
-C_MODE_START
-#define my_raid_type(raid_type)  raid_type_string[(int)(raid_type)]
-extern const char *raid_type_string[];
-C_MODE_END
-
-#ifdef DONT_USE_RAID
-#undef USE_RAID
-#endif
-#if defined(USE_RAID)
-
-#include "my_dir.h"
-
-/* Trap all occurences of my_...() in source and use our wrapper around this function */
-
-#ifdef MAP_TO_USE_RAID
-#define my_read(A,B,C,D)     my_raid_read(A,B,C,D)
-#define my_write(A,B,C,D)    my_raid_write(A,B,C,D)
-#define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E)
-#define my_pread(A,B,C,D,E)  my_raid_pread(A,B,C,D,E)
-#define my_chsize(A,B,C,D)   my_raid_chsize(A,B,C,D)
-#define my_close(A,B)        my_raid_close(A,B)
-#define my_tell(A,B)         my_raid_tell(A,B)
-#define my_seek(A,B,C,D)     my_raid_seek(A,B,C,D)
-#define my_lock(A,B,C,D,E)     my_raid_lock(A,B,C,D,E)
-#define my_fstat(A,B,C)     my_raid_fstat(A,B,C)
-#endif /* MAP_TO_USE_RAID */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-  void init_raid(void);
-  void end_raid(void);
-
-  bool is_raid(File fd);
-  File my_raid_create(const char *FileName, int CreateFlags, int access_flags,
-		      uint raid_type, uint raid_chunks, ulong raid_chunksize,
-		      myf MyFlags);
-  File my_raid_open(const char *FileName, int Flags,
-		    uint raid_type, uint raid_chunks, ulong raid_chunksize,
-		    myf MyFlags);
-  int my_raid_rename(const char *from, const char *to, uint raid_chunks,
-		     myf MyFlags);
-  int my_raid_delete(const char *from, uint raid_chunks, myf MyFlags);
-  int my_raid_redel(const char *old_name, const char *new_name,
-		    uint raid_chunks, myf MyFlags);
-
-  my_off_t my_raid_seek(File fd, my_off_t pos, int whence, myf MyFlags);
-  my_off_t my_raid_tell(File fd, myf MyFlags);
-
-  uint my_raid_write(File,const byte *Buffer, uint Count, myf MyFlags);
-  uint my_raid_read(File Filedes, byte *Buffer, uint Count, myf MyFlags);
-
-  uint my_raid_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
-		     myf MyFlags);
-  uint my_raid_pwrite(int Filedes, const byte *Buffer, uint Count,
-		      my_off_t offset, myf MyFlags);
-
-  int my_raid_lock(File,int locktype, my_off_t start, my_off_t length,
-		   myf MyFlags);
-  int my_raid_chsize(File fd, my_off_t newlength, int filler, myf MyFlags);
-  int my_raid_close(File, myf MyFlags);
-  int my_raid_fstat(int Filedes, struct stat *buf,  myf MyFlags);
-
-#ifdef __cplusplus
-}
-
-#ifdef USE_PRAGMA_INTERFACE
-#pragma interface			/* gcc class implementation */
-#endif
-
-class RaidName {
-  public:
-    RaidName(const char *FileName);
-    ~RaidName();
-    bool IsRaid();
-    int Rename(const char * from, const char * to, myf MyFlags);
-  private:
-    uint _raid_type;       /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */
-    uint _raid_chunks;     /* 1..n */
-    ulong _raid_chunksize; /* 1..n in bytes */
-};
-
-class RaidFd {
-  public:
-    RaidFd(uint raid_type, uint raid_chunks , ulong raid_chunksize);
-    ~RaidFd();
-    File Create(const char *FileName, int CreateFlags, int access_flags,
-		myf MyFlags);
-    File Open(const char *FileName, int Flags, myf MyFlags);
-    my_off_t Seek(my_off_t pos,int whence,myf MyFlags);
-    my_off_t Tell(myf MyFlags);
-    int Write(const byte *Buffer, uint Count, myf MyFlags);
-    int Read(const byte *Buffer, uint Count, myf MyFlags);
-    int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags);
-    int Chsize(File fd, my_off_t newlength, int filler, myf MyFlags);
-    int Fstat(int fd, MY_STAT *stat_area, myf MyFlags );
-    int Close(myf MyFlags);
-    static bool IsRaid(File fd);
-    static DYNAMIC_ARRAY _raid_map;		/* Map of RaidFD* */
-  private:
-
-    uint _raid_type;       /* RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5 */
-    uint _raid_chunks;     /* 1..n */
-    ulong _raid_chunksize; /* 1..n in bytes */
-
-    ulong _total_block;    /* We are operating with block no x (can be 0..many). */
-    uint _this_block;      /* can be 0.._raid_chunks */
-    uint _remaining_bytes; /* Maximum bytes that can be written in this block */
-
-    my_off_t _position;
-    my_off_t _size;        /* Cached file size for faster seek(SEEK_END) */
-    File _fd;
-    File *_fd_vector;		/* Array of File */
-    off_t *_seek_vector;	/* Array of cached seek positions */
-
-    inline void Calculate()
-    {
-      DBUG_ENTER("RaidFd::_Calculate");
-      DBUG_PRINT("info",("_position: %lu _raid_chunksize: %d, _size: %lu",
-			 (ulong) _position, _raid_chunksize, (ulong) _size));
-
-      _total_block = (ulong) (_position / _raid_chunksize);
-      _this_block = _total_block % _raid_chunks;    /* can be 0.._raid_chunks */
-      _remaining_bytes = (uint) (_raid_chunksize -
-				 (_position - _total_block * _raid_chunksize));
-      DBUG_PRINT("info",
-		 ("_total_block: %d  this_block: %d  _remaining_bytes:%d",
-		  _total_block, _this_block, _remaining_bytes));
-      DBUG_VOID_RETURN;
-    }
-};
-
-#endif /* __cplusplus */
-#endif /* USE_RAID */
diff --git a/3rdparty/mysql/include/typelib.h b/3rdparty/mysql/include/typelib.h
deleted file mode 100644
index 4d6a90ad5..000000000
--- a/3rdparty/mysql/include/typelib.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-
-#ifndef _typelib_h
-#define _typelib_h
-
-typedef struct st_typelib {	/* Different types saved here */
-  unsigned int count;		/* How many types */
-  const char *name;		/* Name of typelib */
-  const char **type_names;
-  unsigned int *type_lengths;
-} TYPELIB;
-
-extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name);
-extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
-extern const char *get_type(TYPELIB *typelib,unsigned int nr);
-
-extern TYPELIB sql_protocol_typelib;
-
-#endif /* _typelib_h */
diff --git a/3rdparty/mysql/lib/libmysql.lib b/3rdparty/mysql/lib/libmysql.lib
deleted file mode 100644
index aa99dc3b8..000000000
Binary files a/3rdparty/mysql/lib/libmysql.lib and /dev/null differ
diff --git a/3rdparty/mysql/mysql-5.0.20 b/3rdparty/mysql/mysql-5.0.20
deleted file mode 100644
index e69de29bb..000000000
diff --git a/libmariadb.dll b/libmariadb.dll
new file mode 100644
index 000000000..8011e2abb
Binary files /dev/null and b/libmariadb.dll differ
diff --git a/libmysql.dll b/libmysql.dll
deleted file mode 100644
index f86e8ef5b..000000000
Binary files a/libmysql.dll and /dev/null differ
diff --git a/src/common/sql.c b/src/common/sql.c
index 0b5b7fa07..0efc54564 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -94,6 +94,9 @@ static struct Sql *Sql_Malloc(void)
 	{
 		my_bool reconnect = 1;
 		mysql_options(&self->handle, MYSQL_OPT_RECONNECT, &reconnect);
+#ifdef WIN32
+		mysql_optionsv(&self->handle, MYSQL_PLUGIN_DIR, MARIADB_PLUGINDIR);
+#endif
 	}
 	return self;
 }
diff --git a/vcproj-14/char-server.vcxproj b/vcproj-14/char-server.vcxproj
index bc5014b9c..4df78b3e5 100644
--- a/vcproj-14/char-server.vcxproj
+++ b/vcproj-14/char-server.vcxproj
@@ -54,7 +54,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessToFile>false</PreprocessToFile>
       <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -74,9 +74,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -97,7 +97,7 @@
       <OmitFramePointers>true</OmitFramePointers>
       <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -112,9 +112,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
diff --git a/vcproj-14/login-server.vcxproj b/vcproj-14/login-server.vcxproj
index 3b5e13373..d2b0d8da6 100644
--- a/vcproj-14/login-server.vcxproj
+++ b/vcproj-14/login-server.vcxproj
@@ -53,7 +53,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessToFile>false</PreprocessToFile>
       <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -73,9 +73,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -96,7 +96,7 @@
       <OmitFramePointers>true</OmitFramePointers>
       <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -115,9 +115,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
diff --git a/vcproj-14/map-server.vcxproj b/vcproj-14/map-server.vcxproj
index ed91f231d..38153c908 100644
--- a/vcproj-14/map-server.vcxproj
+++ b/vcproj-14/map-server.vcxproj
@@ -52,7 +52,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessToFile>false</PreprocessToFile>
       <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -72,9 +72,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -95,7 +95,7 @@
       <OmitFramePointers>true</OmitFramePointers>
       <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -110,9 +110,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
diff --git a/vcproj-15/char-server.vcxproj b/vcproj-15/char-server.vcxproj
index 6756fc25e..71e666d51 100644
--- a/vcproj-15/char-server.vcxproj
+++ b/vcproj-15/char-server.vcxproj
@@ -54,7 +54,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessToFile>false</PreprocessToFile>
       <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -74,9 +74,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -97,7 +97,7 @@
       <OmitFramePointers>true</OmitFramePointers>
       <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -112,9 +112,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
diff --git a/vcproj-15/login-server.vcxproj b/vcproj-15/login-server.vcxproj
index f045fa290..f57ce0bb4 100644
--- a/vcproj-15/login-server.vcxproj
+++ b/vcproj-15/login-server.vcxproj
@@ -54,7 +54,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessToFile>false</PreprocessToFile>
       <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -74,9 +74,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -97,7 +97,7 @@
       <OmitFramePointers>true</OmitFramePointers>
       <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -116,9 +116,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
diff --git a/vcproj-15/map-server.vcxproj b/vcproj-15/map-server.vcxproj
index 8becb90cc..6495c0afb 100644
--- a/vcproj-15/map-server.vcxproj
+++ b/vcproj-15/map-server.vcxproj
@@ -53,7 +53,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessToFile>false</PreprocessToFile>
       <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -73,9 +73,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -96,7 +96,7 @@
       <OmitFramePointers>true</OmitFramePointers>
       <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -111,9 +111,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
diff --git a/vcproj-16/char-server.vcxproj b/vcproj-16/char-server.vcxproj
index fd53a34ad..68973d2bf 100644
--- a/vcproj-16/char-server.vcxproj
+++ b/vcproj-16/char-server.vcxproj
@@ -54,7 +54,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessToFile>false</PreprocessToFile>
       <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -74,9 +74,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -97,7 +97,7 @@
       <OmitFramePointers>true</OmitFramePointers>
       <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -112,9 +112,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
diff --git a/vcproj-16/login-server.vcxproj b/vcproj-16/login-server.vcxproj
index b5137bf29..efc5253ad 100644
--- a/vcproj-16/login-server.vcxproj
+++ b/vcproj-16/login-server.vcxproj
@@ -54,7 +54,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessToFile>false</PreprocessToFile>
       <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -74,9 +74,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -97,7 +97,7 @@
       <OmitFramePointers>true</OmitFramePointers>
       <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -116,9 +116,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
diff --git a/vcproj-16/map-server.vcxproj b/vcproj-16/map-server.vcxproj
index 8d84af347..abf839abb 100644
--- a/vcproj-16/map-server.vcxproj
+++ b/vcproj-16/map-server.vcxproj
@@ -53,7 +53,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessToFile>false</PreprocessToFile>
       <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -73,9 +73,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -96,7 +96,7 @@
       <OmitFramePointers>true</OmitFramePointers>
       <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
       <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mariadb\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -111,9 +111,9 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmariadb.lib;zdll.lib;pcre.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
-      <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\3rdparty\mariadb\lib;..\3rdparty\zlib\lib;..\3rdparty\pcre\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
-- 
cgit v1.2.3-70-g09d2