Blob Blame History Raw
This patch fixes compatibility with gcc compiler by:

* Replacing "swap" in mariadb library with my_swap to avoid conflict with C++ standard headers
* Adding necessary, missing headers for histogram.cc file

This changes should be included in upstream. Tracking for them needs to be resolved in future.

Update 8/2021
* Add missing includes to histogram.cc file.
  prometheus-cpp version used by proxysql is quite old and fixes
  from upstream are yet not present is this version.
  This part of the patch should be removed when prometheus-cpp library is updated.

diff --git a/deps/Makefile b/deps/Makefile
index 6f049c8..6b0b6ea 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -149,6 +149,8 @@
 #	cd mariadb-client-library/mariadb_client && patch libmariadb/ma_pvio.c < ../ma_pvio.c.patch
 	cd mariadb-client-library/mariadb_client && patch unittest/libmariadb/basic-t.c < ../unittest_basic-t.c.patch
 	cd mariadb-client-library/mariadb_client && patch unittest/libmariadb/charset.c < ../unittest_charset.c.patch
+	cd mariadb-client-library/mariadb_client && patch include/ma_global.h  < ../ma_global.h.patch
+	cd mariadb-client-library/mariadb_client && patch libmariadb/ma_compress.c  < ../ma_compress.c.patch
 	cd mariadb-client-library/mariadb_client && patch -p0 < ../client_deprecate_eof.patch
 	cd mariadb-client-library/mariadb_client && patch -p0 < ../cr_new_stmt_metadata_removal.patch
 	cd mariadb-client-library/mariadb_client && patch -p0 < ../ps_buffer_stmt_read_all_rows.patch
diff --git a/deps/mariadb-client-library/ma_compress.c.patch b/deps/mariadb-client-library/ma_compress.c.patch
new file mode 100644
index 0000000..a50c412
--- /dev/null
+++ b/deps/mariadb-client-library/ma_compress.c.patch
@@ -0,0 +1,13 @@
+diff --git a/libmariadb/ma_compress.c b/libmariadb/ma_compress.c
+index 55184a0..a16bb8a 100644
+--- a/libmariadb/ma_compress.c
++++ b/libmariadb/ma_compress.c
+@@ -64,7 +64,7 @@ unsigned char *_mariadb_compress_alloc(const unsigned char *packet, size_t *len,
+     free(compbuf);
+     return 0;
+   }
+-  swap(size_t,*len,*complen);			/* *len is now packet length */
++  my_swap(size_t,*len,*complen);			/* *len is now packet length */
+   return compbuf;
+ }
+ 
--- /dev/null	2021-08-09 01:14:50.972746909 +0000
+++ b/deps/mariadb-client-library/ma_global.h.patch	2021-08-10 11:41:37.210999217 +0000
@@ -0,0 +1,11 @@
+--- ma_global.h	2020-06-18 15:16:18.000000000 +0000
++++ ma_global.h	2021-08-10 11:39:55.603901813 +0000
+@@ -272,7 +272,7 @@
+ #endif
+ 
+ #define sgn(a)		(((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
+-#define swap(t,a,b)	do{register t dummy; dummy = a; a = b; b = dummy;}while(0)
++#define my_swap(t,a,b)	do{register t dummy; dummy = a; a = b; b = dummy;}while(0)
+ #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)
--- /dev/null	2021-08-09 01:14:50.972746909 +0000
+++ b/deps/prometheus-cpp/histogram.cc.patch	2021-08-10 14:16:20.496146369 +0000
@@ -0,0 +1,11 @@
+--- a/core/src/histogram.cc	2020-02-11 18:07:45.000000000 +0000
++++ b/core/src/histogram.cc	2021-08-10 14:14:16.744004996 +0000
+@@ -5,6 +5,8 @@
+ #include <iterator>
+ #include <numeric>
+ #include <ostream>
++#include <stdexcept>
++#include <limits>
+ 
+ namespace prometheus {
+