--- a/include/sys_main.h	2018-01-19 05:36:38.000000000 -0500
+++ b/include/sys_main.h	2018-03-01 11:40:04.554713079 -0500
@@ -20,6 +20,8 @@
 extern "C" {
 #endif
 
+#include "sys/mysql/psi/psi_memory.h"
+
 #define MY_FAE		8	/* Fatal if any error */
 #define MY_WME		16	/* Write message on error */
 #define MY_ZEROFILL	32	/* my_malloc(), fill array with zero */
--- a/driver/connect.c	2018-01-19 05:36:38.000000000 -0500
+++ b/driver/connect.c	2018-03-01 11:39:51.458676373 -0500
@@ -179,7 +179,7 @@
   /* Set other connection options */
 
   if (ds->allow_big_results || ds->safe)
-#if MYSQL_VERSION_ID >= 50709
+#if MYSQL_VERSION_ID >= 50709 && !defined(MARIADB_BASE_VERSION)
     mysql_options(mysql, MYSQL_OPT_MAX_ALLOWED_PACKET, &max_long);
 #else
     /* max_allowed_packet is a magical mysql macro. */
@@ -252,7 +252,7 @@
                   ds_get_utf8attr(ds->rsakey, &ds->rsakey8));
   }
 #endif
-#if MYSQL_VERSION_ID >= 50710
+#if MYSQL_VERSION_ID >= 50710 && !defined(MARIADB_BASE_VERSION)
   {
     char tls_options[128] = { 0 };
     if (!ds->no_tls_1)
@@ -323,7 +323,7 @@
 #endif
 
   mysql->options.use_ssl = !ds->disable_ssl_default;
-#if MYSQL_VERSION_ID >= 50703
+#if MYSQL_VERSION_ID >= 50703 && !defined(MARIADB_BASE_VERSION)
   {
     if (ds->ssl_enforce)
     {
@@ -332,7 +332,7 @@
   }
 #endif
 
-#if MYSQL_VERSION_ID >= 50711
+#if MYSQL_VERSION_ID >= 50711 && !defined(MARIADB_BASE_VERSION)
   if (ds->sslmode)
   {
     unsigned int mode = 0;
@@ -510,7 +510,7 @@
     }
   }
 
-#if MYSQL_VERSION_ID >= 50709
+#if MYSQL_VERSION_ID >= 50709 && !defined(MARIADB_BASE_VERSION)
   mysql_get_option(mysql, MYSQL_OPT_NET_BUFFER_LENGTH, &dbc->net_buffer_len);
 #else
   // for older versions just use net_buffer_length() macro
