diff --git a/.gitignore b/.gitignore index 3647d93615..a047d63ea8 100644 --- a/.gitignore +++ b/.gitignore @@ -110,6 +110,10 @@ heaptrack.* #vscode .vscode/ +# test deps +test/deps/mariadb-connector-c/mariadb-connector-c-*/ +test/deps/mysql-connector-c/mysql-5.7.*/ + #tap tests test/tap/tap/cpp-dotenv/cpp-dotenv-* test/tap/tap/cpp-dotenv/static/cpp-dotenv-* diff --git a/Makefile b/Makefile index 34626ce6e2..eaf16c5d35 100644 --- a/Makefile +++ b/Makefile @@ -9,12 +9,10 @@ ### export GIT_VERSION=2.x-dev ### ``` -ifndef GIT_VERSION -GIT_VERSION := $(shell git describe --long --abbrev=7) +GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION $(error GIT_VERSION is not set) endif -endif ### NOTES: ### to compile without jemalloc, set environment variable NOJEMALLOC=1 @@ -28,26 +26,39 @@ endif ### ### ** to use on-demand coredump generation feature, compile code without ASAN option (WITHASAN=0). -O0=-O0 -O2=-O2 -O1=-O1 -O3=-O3 -mtune=native -#OPTZ=$(O2) -EXTRALINK=#-pg -ALL_DEBUG=-ggdb -DDEBUG -NO_DEBUG= -DEBUG=${ALL_DEBUG} +O0 := -O0 +O2 := -O2 +O1 := -O1 +O3 := -O3 -mtune=native + +#EXTRALINK := #-pg +ALL_DEBUG := $(O0) -ggdb -DDEBUG +NO_DEBUG := $(O2) -ggdb +DEBUG := $(ALL_DEBUG) +CURVER ?= 2.6.0 #export DEBUG -#export OPTZ #export EXTRALINK export MAKE -export CURVER?=2.6.0 +export CURVER + +### detect compiler support for c++11/17 +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201703L) + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') + LEGACY_BUILD := 1 +ifneq ($(CPLUSPLUS),201103L) + $(error Compiler must support at least c++11) +endif +endif +STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) + +### detect distro +DISTRO := Unknown ifneq (,$(wildcard /etc/os-release)) DISTRO := $(shell awk -F= '/^NAME/{print $$2}' /etc/os-release) -else - DISTRO := Unknown endif +### multiprocessing NPROCS := 1 OS := $(shell uname -s) ifeq ($(OS),Linux) @@ -56,20 +67,22 @@ endif ifeq ($(OS),Darwin) NPROCS := $(shell sysctl -n hw.ncpu) endif +export MAKEOPT := -j${NPROCS} -export MAKEOPT=-j ${NPROCS} - +### systemd +SYSTEMD := 0 ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system) - SYSTEMD=1 -else - SYSTEMD=0 + SYSTEMD := 1 endif + +### check user/group USERCHECK := $(shell getent passwd proxysql) GROUPCHECK := $(shell getent group proxysql) ### main targets +.DEFAULT: default .PHONY: default default: build_src @@ -108,25 +121,49 @@ debug_clickhouse: build_src_debug_clickhouse ### helper targets .PHONY: build_deps -build_deps: - cd deps && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE} +build_deps: $(if $(LEGACY_BUILD),build_deps_legacy,build_deps_default) .PHONY: build_lib -build_lib: build_deps - cd lib && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE} +build_lib: $(if $(LEGACY_BUILD),build_lib_legacy,build_lib_default) .PHONY: build_src -build_src: build_lib - cd src && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE} +build_src: $(if $(LEGACY_BUILD),build_src_legacy,build_src_default) .PHONY: build_deps_debug -build_deps_debug: - cd deps && OPTZ="${O0} -ggdb -DDEBUG" PROXYDEBUG=1 CC=${CC} CXX=${CXX} ${MAKE} +build_deps_debug: $(if $(LEGACY_BUILD),build_deps_debug_legacy,build_deps_debug_default) .PHONY: build_lib_debug -build_lib_debug: build_deps_debug +build_lib_debug: $(if $(LEGACY_BUILD),build_lib_debug_legacy,build_lib_debug_default) + +.PHONY: build_src_debug +build_src_debug: $(if $(LEGACY_BUILD),build_src_debug_legacy,build_src_debug_default) + +# legacy build targets (pre c++17) +.PHONY: build_deps_legacy +build_deps_legacy: + cd deps && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE} + +.PHONY: build_lib_legacy +build_lib_legacy: build_deps_legacy + cd lib && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE} + +.PHONY: build_src_legacy +build_src_legacy: build_lib_legacy + cd src && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE} + +.PHONY: build_deps_debug_legacy +build_deps_debug_legacy: + cd deps && OPTZ="${O0} -ggdb -DDEBUG" PROXYDEBUG=1 CC=${CC} CXX=${CXX} ${MAKE} + +.PHONY: build_lib_debug_legacy +build_lib_debug_legacy: build_deps_debug_legacy cd lib && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE} +.PHONY: build_src_debug_legacy +build_src_debug_legacy: build_lib_debug_legacy + cd src && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE} +#-- + .PHONY: build_src_testaurora build_src_testaurora: build_lib_testaurora cd src && OPTZ="${O0} -ggdb -DDEBUG -DTEST_AURORA" CC=${CC} CXX=${CXX} ${MAKE} @@ -176,44 +213,67 @@ build_lib_testall: build_deps_debug cd lib && OPTZ="${O0} -ggdb -DDEBUG -DTEST_AURORA -DTEST_GALERA -DTEST_GROUPREP -DTEST_READONLY -DTEST_REPLICATIONLAG" CC=${CC} CXX=${CXX} ${MAKE} .PHONY: build_tap_test -build_tap_test: build_src - cd test/tap && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE} +build_tap_test: build_tap_tests +.PHONY: build_tap_tests +build_tap_tests: build_src + cd test/tap && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE} .PHONY: build_tap_test_debug -build_tap_test_debug: build_src_debug +build_tap_test_debug: build_tap_tests_debug +.PHONY: build_tap_tests_debug +build_tap_tests_debug: build_src_debug cd test/tap && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE} debug -.PHONY: build_src_debug -build_src_debug: build_lib_debug - cd src && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE} - +# ClickHouse build targets are now default build targets. +# To maintain backward compatibility, ClickHouse targets are still available. .PHONY: build_deps_clickhouse -build_deps_clickhouse: - cd deps && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE} +build_deps_clickhouse: build_deps_default .PHONY: build_deps_debug_clickhouse -build_deps_debug_clickhouse: - cd deps && OPTZ="${O0} -ggdb -DDEBUG" PROXYSQLCLICKHOUSE=1 PROXYDEBUG=1 CC=${CC} CXX=${CXX} ${MAKE} +build_deps_debug_clickhouse: build_deps_debug_default .PHONY: build_lib_clickhouse -build_lib_clickhouse: build_deps_clickhouse - cd lib && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE} +build_lib_clickhouse: build_lib_default .PHONY: build_lib_debug_clickhouse -build_lib_debug_clickhouse: build_deps_debug_clickhouse - cd lib && OPTZ="${O0} -ggdb -DDEBUG" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE} +build_lib_debug_clickhouse: build_lib_debug_default .PHONY: build_src_clickhouse -build_src_clickhouse: build_lib_clickhouse - cd src && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE} +build_src_clickhouse: build_src_default .PHONY: build_src_debug_clickhouse -build_src_debug_clickhouse: build_lib_debug_clickhouse +build_src_debug_clickhouse: build_src_debug_default +#-- + +.PHONY: build_deps_default +build_deps_default: + cd deps && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE} + +PHONY: build_deps_debug_default +build_deps_debug_default: + cd deps && OPTZ="${O0} -ggdb -DDEBUG" PROXYSQLCLICKHOUSE=1 PROXYDEBUG=1 CC=${CC} CXX=${CXX} ${MAKE} + +.PHONY: build_lib_default +build_lib_default: build_deps_default + cd lib && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE} + +.PHONY: build_lib_debug_default +build_lib_debug_default: build_deps_debug_default + cd lib && OPTZ="${O0} -ggdb -DDEBUG" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE} + +.PHONY: build_src_default +build_src_default: build_lib_default + cd src && OPTZ="${O2} -ggdb" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE} + +.PHONY: build_src_debug_default +build_src_debug_default: build_lib_debug_default cd src && OPTZ="${O0} -ggdb -DDEBUG" PROXYSQLCLICKHOUSE=1 CC=${CC} CXX=${CXX} ${MAKE} ### packaging targets +SYS_KERN := $(shell uname -s) +#SYS_DIST := $(shell source /etc/os-release &>/dev/null; if [ -z ${NAME} ]; then head -1 /etc/redhat-release; else echo ${NAME}; fi | awk '{ print $1 }) SYS_ARCH := $(shell uname -m) REL_ARCH := $(subst x86_64,amd64,$(subst aarch64,arm64,$(SYS_ARCH))) RPM_ARCH := .$(SYS_ARCH) @@ -281,6 +341,8 @@ clean: cd lib && ${MAKE} clean cd src && ${MAKE} clean cd test/tap && ${MAKE} clean + cd test/deps && ${MAKE} clean + rm -f pkgroot || true .PHONY: cleanall cleanall: @@ -288,9 +350,11 @@ cleanall: cd lib && ${MAKE} clean cd src && ${MAKE} clean cd test/tap && ${MAKE} clean + cd test/deps && ${MAKE} cleanall rm -f binaries/*deb || true rm -f binaries/*rpm || true rm -f binaries/*id-hash || true + rm -rf pkgroot || true .PHONY: cleanbuild cleanbuild: @@ -331,7 +395,7 @@ ifeq ($(DISTRO),"Debian GNU/Linux") update-rc.d proxysql defaults else ifeq ($(DISTRO),"Unknown") - $(warning Not sure how to install proxysql service on this OS) + $(warning Not sure how to install proxysql service on this OS) endif endif endif @@ -368,7 +432,7 @@ ifeq ($(DISTRO),"Debian GNU/Linux") update-rc.d proxysql remove else ifeq ($(DISTRO),"Unknown") - $(warning Not sure how to uninstall proxysql service on this OS) +$(warning Not sure how to uninstall proxysql service on this OS) endif endif endif diff --git a/deps/Makefile b/deps/Makefile index 94b2e7627e..2e8a8333b5 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -1,72 +1,57 @@ #!/bin/make -f -UNAME_S := $(shell uname -s) -UNAME_MS := $(word 2, $(shell uname -ms)) +SYS_KERN := $(shell uname -s) +SYS_ARCH := $(shell uname -m) +CENTOSVER := Unknown ifneq (,$(wildcard /etc/system-release)) CENTOSVER := $(shell rpm --eval %rhel) -else - CENTOSVER := Unknown endif -IS_ARM = $(if $(findstring aarch64, $(arch)),true,false) -IS_CENTOS = $(if $(findstring Unknown, $(CENTOSVER)),false,true) +IS_ARM := $(if $(findstring aarch64, $(SYS_ARCH)),true,false) +IS_CENTOS := $(if $(findstring Unknown, $(CENTOSVER)),false,true) # to compile libmariadb_client with support for valgrind enabled, run: # export USEVALGRIND=1 -# -USEVALGRIND := $(shell echo $(USEVALGRIND)) -PROXYDEBUG := $(shell echo $(PROXYDEBUG)) ifeq ($(PROXYDEBUG),1) -MYCFLAGS=-O0 -MYJEOPT=--enable-xmalloc --enable-prof --enable-fill --enable-debug - + MYCFLAGS := -O0 + MYJEOPT := --enable-xmalloc --enable-prof --enable-fill --enable-debug +else + MYCFLAGS := -O2 + MYJEOPT := --enable-xmalloc --enable-prof +endif ifeq ($(and $(IS_ARM),$(IS_CENTOS)),true) - MYJEOPT+=--with-lg-page=16 + MYJEOPT += --with-lg-page=16 endif -else -MYCFLAGS=-O2 -MYJEOPT=--enable-xmalloc --enable-prof -ifeq ($(and $(IS_ARM),$(IS_CENTOS)),true) - MYJEOPT+=--with-lg-page=16 +### detect compiler support for c++11/17 +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201703L) + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201103L) + $(error Compiler must support at least c++11) endif - endif +STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) -# determine good compiler version for stdc++17 -#IS_CXX17 := 0 -#ifeq ($(CXX),clang++) -# CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -# CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -#ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER)))) -# IS_CXX17 := 1 -#endif -#else -# GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -# GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -#ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER)))) -# IS_CXX17 := 1 -#endif -#endif - - -PROXYSQLCLICKHOUSE := $(shell echo $(PROXYSQLCLICKHOUSE)) -tmpdefault=libconfig libdaemon jemalloc mariadb_client re2 sqlite3 pcre lz4 cityhash microhttpd curl ev libssl libhttpserver libinjection prometheus-cpp -ifeq ($(UNAME_S),Linux) - tmpdefault+= coredumper +targets := libconfig libdaemon jemalloc mariadb_client re2 sqlite3 pcre lz4 cityhash microhttpd curl ev libssl libhttpserver libinjection prometheus-cpp +ifeq ($(SYS_KERN),Linux) + targets += coredumper endif ifeq ($(PROXYSQLCLICKHOUSE),1) - tmpdefault+= clickhouse-cpp + targets += clickhouse-cpp endif -default: $(tmpdefault) + + +default: $(targets) .PHONY: default +### deps targets libinjection/libinjection/src/libinjection.a: cd libinjection && rm -rf libinjection-*/ || true @@ -75,7 +60,7 @@ ifneq ($(CENTOSVER),6) cd libinjection/libinjection && patch -p1 < ../update-build-py3.diff cd libinjection/libinjection && patch -p1 < ../libinjection_sqli.c.patch endif -ifeq ($(UNAME_S),Darwin) +ifeq ($(SYS_KERN),Darwin) sed -i '' 's/CC=/CC?=/' libinjection/libinjection/src/Makefile else sed -i -e 's/CC=/CC?=/' libinjection/libinjection/src/Makefile @@ -93,27 +78,16 @@ libssl/openssl/libssl.a: # cd libssl/openssl && patch crypto/asn1/a_time.c < ../a_time.c-multiplication-overflow.patch cd libssl/openssl && ./config no-ssl3 no-tests cd libssl/openssl && CC=${CC} CXX=${CXX} ${MAKE} - cd libssl/openssl && ln -s . lib # curl wants this path + cd libssl/openssl && ln -fsT . lib # curl wants this path libssl: libssl/openssl/libssl.a -MIN_VERSION := 4.9.0 -GCC_VERSION := $(shell gcc -dumpversion) -SORTED_VERSIONS := $(shell echo -e "$(GCC_VERSION)\n$(MIN_VERSION)" | sort -V) - -REQUIRE_PATCH = false -ifeq ($(MIN_VERSION),$(lastword $(SORTED_VERSIONS))) - REQUIRE_PATCH = true -endif - libhttpserver/libhttpserver/build/src/.libs/libhttpserver.a: libmicrohttpd/libmicrohttpd/src/microhttpd/.libs/libmicrohttpd.a re2/re2/obj/libre2.a cd libhttpserver && rm -rf libhttpserver-*/ || true cd libhttpserver && tar -zxf libhttpserver-*.tar.gz -#ifeq ($(REQUIRE_PATCH), true) cd libhttpserver/libhttpserver && patch -p1 < ../noexcept.patch cd libhttpserver/libhttpserver && patch -p1 < ../re2_regex.patch -#endif cd libhttpserver/libhttpserver && patch -p1 < ../final_val_post_process.patch cd libhttpserver/libhttpserver && patch -p1 < ../empty_uri_log_crash.patch cd libhttpserver/libhttpserver && patch -p0 < ../expose_raw_url.patch @@ -150,7 +124,7 @@ curl/curl/lib/.libs/libcurl.a: libssl/openssl/libssl.a cd curl && tar -zxf curl-*.tar.gz # cd curl/curl && ./configure --disable-debug --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-ipv6 --disable-sspi --disable-crypto-auth --disable-ntlm-wb --disable-tls-srp --without-nghttp2 --without-libidn2 --without-libssh2 --without-brotli --with-ssl=$(shell pwd)/../../libssl/openssl/ && CC=${CC} CXX=${CXX} ${MAKE} cd curl/curl && autoreconf -fi -ifeq ($(UNAME_S),Darwin) +ifeq ($(SYS_KERN),Darwin) cd curl/curl && patch configure < ../configure.patch endif cd curl/curl && CFLAGS=-fPIC ./configure --disable-debug --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-ipv6 --disable-sspi --disable-ntlm-wb --disable-tls-srp --without-nghttp2 --without-libidn2 --without-libssh2 --without-brotli --without-librtmp --without-libpsl --without-zstd --with-ssl=$(shell pwd)/libssl/openssl/ --enable-shared=yes && LD_LIBRARY_PATH=$(shell pwd)/libssl/openssl CC=${CC} CXX=${CXX} ${MAKE} @@ -186,17 +160,9 @@ lz4: lz4/lz4/lib/liblz4.a clickhouse-cpp/clickhouse-cpp/clickhouse/libclickhouse-cpp-lib-static.a: cd clickhouse-cpp && rm -rf clickhouse-cpp-*/ || true -#ifeq ($(IS_CXX17), 1) -# echo ">>> Clickhouse CXX17" - cd clickhouse-cpp && ln -fs clickhouse-cpp-2.3.0 clickhouse-cpp + cd clickhouse-cpp && ln -fsT clickhouse-cpp-2.3.0 clickhouse-cpp cd clickhouse-cpp && tar -zxf v2.3.0.tar.gz && sync cd clickhouse-cpp/clickhouse-cpp && patch clickhouse/base/wire_format.h < ../wire_format.patch -#else -# echo ">>> Clickhouse CXX11" -# cd clickhouse-cpp && ln -fs clickhouse-cpp-1.0.0 clickhouse-cpp -# cd clickhouse-cpp && tar -zxf v1.0.0.tar.gz && sync -# cd clickhouse-cpp && sed -i -e 's/SET (CMAKE_CXX_STANDARD_REQUIRED ON)//' clickhouse-cpp/cmake/cpp17.cmake -#endif cd clickhouse-cpp/clickhouse-cpp && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo . cd clickhouse-cpp/clickhouse-cpp && CC=${CC} CXX=${CXX} ${MAKE} @@ -225,8 +191,6 @@ jemalloc/jemalloc/lib/libjemalloc.a: jemalloc: jemalloc/jemalloc/lib/libjemalloc.a -WITHASAN := $(shell echo $(WITHASAN)) - mariadb-client-library/mariadb_client/libmariadb/libmariadbclient.a: libssl/openssl/libssl.a cd mariadb-client-library && rm -rf mariadb-connector-c-*/ || true cd mariadb-client-library && tar -zxf mariadb-connector-c-3.1.9-src.tar.gz @@ -321,11 +285,11 @@ re2/re2/obj/libre2.a: # cd re2/re2 && sed -i -e 's/-O3 -g /-O3 -fPIC /' Makefile # cd re2/re2 && patch util/mutex.h < ../mutex.h.patch cd re2/re2 && patch re2/onepass.cc < ../onepass.cc-multiplication-overflow.patch -ifeq ($(UNAME_S),Darwin) - cd re2/re2 && sed -i '' -e 's/-O3 -g/-O3 -g -std=c++11 -fPIC -DMEMORY_SANITIZER -DRE2_ON_VALGRIND /' Makefile +ifeq ($(SYS_KERN),Darwin) + cd re2/re2 && sed -i '' -e 's/-O3 -g/-O3 -g -${STDCPP} -fPIC -DMEMORY_SANITIZER -DRE2_ON_VALGRIND /' Makefile # cd re2/re2 && sed -i '' -e 's/RE2_CXXFLAGS?=-std=c++11 /RE2_CXXFLAGS?=-std=c++11 -fPIC /' Makefile else - cd re2/re2 && sed -i -e 's/-O3 -g/-O3 -g -std=c++11 -fPIC -DMEMORY_SANITIZER -DRE2_ON_VALGRIND /' Makefile + cd re2/re2 && sed -i -e 's/-O3 -g/-O3 -g ${STDCPP} -fPIC -DMEMORY_SANITIZER -DRE2_ON_VALGRIND /' Makefile # cd re2/re2 && sed -i -e 's/RE2_CXXFLAGS?=-std=c++11 /RE2_CXXFLAGS?=-std=c++11 -fPIC /' Makefile endif cd re2/re2 && CC=${CC} CXX=${CXX} ${MAKE} @@ -343,6 +307,7 @@ pcre/pcre/.libs/libpcre.a: pcre: pcre/pcre/.libs/libpcre.a +### clean targets cleanpart: cd mariadb-client-library && rm -rf mariadb-connector-c-*/ || true diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index 644d351b40..b7bba6d348 100644 --- a/include/proxysql_admin.h +++ b/include/proxysql_admin.h @@ -1,9 +1,9 @@ #ifndef __CLASS_PROXYSQL_ADMIN_H #define __CLASS_PROXYSQL_ADMIN_H -#include -#include -#include +#include "prometheus/exposer.h" +#include "prometheus/counter.h" +#include "prometheus/gauge.h" #include "query_processor.h" #include "proxy_defines.h" diff --git a/include/proxysql_glovars.hpp b/include/proxysql_glovars.hpp index fe23e756fd..119d336c6a 100644 --- a/include/proxysql_glovars.hpp +++ b/include/proxysql_glovars.hpp @@ -5,7 +5,7 @@ #define CLUSTER_SYNC_INTERFACES_MYSQL "('mysql-interfaces')" #include -#include +#include "prometheus/registry.h" #include "configfile.hpp" #include "proxy_defines.h" diff --git a/lib/Makefile b/lib/Makefile index 23d5190f04..032dea04b1 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,153 +1,130 @@ #!/bin/make -f -ifndef GIT_VERSION - GIT_VERSION := $(shell git describe --long --abbrev=7) +GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION $(error GIT_VERSION is not set) endif -endif -DEPS_PATH=../deps +DEPS_PATH := ../deps UNAME_S := $(shell uname -s) -MARIADB_PATH=$(DEPS_PATH)/mariadb-client-library/mariadb_client -MARIADB_IDIR=$(MARIADB_PATH)/include -JEMALLOC_PATH=$(DEPS_PATH)/jemalloc/jemalloc -JEMALLOC_IDIR=$(JEMALLOC_PATH)/include/jemalloc +MARIADB_PATH := $(DEPS_PATH)/mariadb-client-library/mariadb_client +MARIADB_IDIR := $(MARIADB_PATH)/include + +JEMALLOC_PATH := $(DEPS_PATH)/jemalloc/jemalloc +JEMALLOC_IDIR := $(JEMALLOC_PATH)/include/jemalloc -LIBCONFIG_PATH=$(DEPS_PATH)/libconfig/libconfig -LIBCONFIG_IDIR=-I$(LIBCONFIG_PATH)/lib +LIBCONFIG_PATH := $(DEPS_PATH)/libconfig/libconfig +LIBCONFIG_IDIR := -I$(LIBCONFIG_PATH)/lib -#INJECTION_PATH=$(DEPS_PATH)/libinjection -#INJECTION_IDIR=$(INJECTION_PATH) +#INJECTION_PATH := $(DEPS_PATH)/libinjection +#INJECTION_IDIR := $(INJECTION_PATH) -RE2_PATH=$(DEPS_PATH)/re2/re2 -RE2_IDIR=$(RE2_PATH) +RE2_PATH := $(DEPS_PATH)/re2/re2 +RE2_IDIR := $(RE2_PATH) -PCRE_PATH=$(DEPS_PATH)/pcre/pcre +PCRE_PATH := $(DEPS_PATH)/pcre/pcre -SQLITE3_DIR=$(DEPS_PATH)/sqlite3/sqlite3 +SQLITE3_DIR := $(DEPS_PATH)/sqlite3/sqlite3 -CLICKHOUSE_CPP_DIR=$(DEPS_PATH)/clickhouse-cpp/clickhouse-cpp +CLICKHOUSE_CPP_DIR := $(DEPS_PATH)/clickhouse-cpp/clickhouse-cpp -LIBINJECTION_DIR=$(DEPS_PATH)/libinjection/libinjection -LIBINJECTION_IDIR=-I$(LIBINJECTION_DIR)/src +LIBINJECTION_DIR := $(DEPS_PATH)/libinjection/libinjection +LIBINJECTION_IDIR := -I$(LIBINJECTION_DIR)/src -LIBHTTPSERVER_DIR=$(DEPS_PATH)/libhttpserver/libhttpserver -LIBHTTPSERVER_IDIR=-I$(LIBHTTPSERVER_DIR)/src +LIBHTTPSERVER_DIR := $(DEPS_PATH)/libhttpserver/libhttpserver +LIBHTTPSERVER_IDIR := -I$(LIBHTTPSERVER_DIR)/src -MICROHTTPD_DIR=$(DEPS_PATH)/libmicrohttpd/libmicrohttpd -MICROHTTPD_IDIR=-I$(MICROHTTPD_DIR) -I$(MICROHTTPD_DIR)/src/include +MICROHTTPD_DIR := $(DEPS_PATH)/libmicrohttpd/libmicrohttpd +MICROHTTPD_IDIR := -I$(MICROHTTPD_DIR) -I$(MICROHTTPD_DIR)/src/include -COREDUMPER_DIR=$(DEPS_PATH)/coredumper/coredumper -COREDUMPER_IDIR=$(COREDUMPER_DIR)/include +COREDUMPER_DIR := $(DEPS_PATH)/coredumper/coredumper +COREDUMPER_IDIR := $(COREDUMPER_DIR)/include -CURL_DIR=$(DEPS_PATH)/curl/curl -CURL_IDIR=$(CURL_DIR)/include +CURL_DIR := $(DEPS_PATH)/curl/curl +CURL_IDIR := $(CURL_DIR)/include -SSL_DIR=$(DEPS_PATH)/libssl/openssl/ -SSL_IDIR=$(SSL_DIR)/include +SSL_DIR := $(DEPS_PATH)/libssl/openssl/ +SSL_IDIR := $(SSL_DIR)/include +EV_DIR := $(DEPS_PATH)/libev/libev/ +EV_IDIR := $(EV_DIR) -EV_DIR=$(DEPS_PATH)/libev/libev/ -EV_IDIR=$(EV_DIR) +PROMETHEUS_PATH := $(DEPS_PATH)/prometheus-cpp/prometheus-cpp +PROMETHEUS_IDIR := $(PROMETHEUS_PATH)/pull/include -I$(PROMETHEUS_PATH)/core/include +PROMETHEUS_LDIR := $(PROMETHEUS_PATH)/lib -PROMETHEUS_PATH=$(DEPS_PATH)/prometheus-cpp/prometheus-cpp -PROMETHEUS_IDIR=$(PROMETHEUS_PATH)/pull/include -I$(PROMETHEUS_PATH)/core/include -PROMETHEUS_LDIR=$(PROMETHEUS_PATH)/lib -IDIR=../include +IDIR := ../include -IDIRS=-I$(IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) $(LIBCONFIG_IDIR) -I$(RE2_IDIR) -I$(SQLITE3_DIR) -I$(PCRE_PATH) -I/usr/local/include -I$(CLICKHOUSE_CPP_DIR) -I$(CLICKHOUSE_CPP_DIR)/contrib/ $(MICROHTTPD_IDIR) $(LIBHTTPSERVER_IDIR) $(LIBINJECTION_IDIR) -I$(CURL_IDIR) -I$(EV_DIR) -I$(SSL_IDIR) -I$(PROMETHEUS_IDIR) +IDIRS := -I$(IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) $(LIBCONFIG_IDIR) -I$(RE2_IDIR) -I$(SQLITE3_DIR) -I$(PCRE_PATH) -I/usr/local/include -I$(CLICKHOUSE_CPP_DIR) -I$(CLICKHOUSE_CPP_DIR)/contrib/ $(MICROHTTPD_IDIR) $(LIBHTTPSERVER_IDIR) $(LIBINJECTION_IDIR) -I$(CURL_IDIR) -I$(EV_DIR) -I$(SSL_IDIR) -I$(PROMETHEUS_IDIR) ifeq ($(UNAME_S),Linux) - IDIRS+= -I$(COREDUMPER_IDIR) + IDIRS += -I$(COREDUMPER_IDIR) endif -LDIRS=-L$(JEMALLOC_PATH)/lib -L$(RE2_PATH)/obj -L$(INJECTION_PATH) -L$(PROMETHEUS_LDIR) +LDIRS := -L$(JEMALLOC_PATH)/lib -L$(RE2_PATH)/obj -L$(INJECTION_PATH) -L$(PROMETHEUS_LDIR) -#LIBS=-rdynamic -Wl,-Bstatic -ljemalloc_pic -lre2 -Wl,-Bdynamic -ldl -lpthread -lm -lz -lrt $(EXTRALINK) -#LIBS=-Wl,--export-dynamic -Wl,-Bstatic -ljemalloc_pic -lre2 -Wl,-Bdynamic -ldl -lpthread -lm -lz -lrt $(EXTRALINK) +#LIBS := -rdynamic -Wl,-Bstatic -ljemalloc_pic -lre2 -Wl,-Bdynamic -ldl -lpthread -lm -lz -lrt $(EXTRALINK) +#LIBS := -Wl,--export-dynamic -Wl,-Bstatic -ljemalloc_pic -lre2 -Wl,-Bdynamic -ldl -lpthread -lm -lz -lrt $(EXTRALINK) -ODIR= obj +ODIR := obj -#CC=gcc -#CXX=g++ -#CC=clang -WITHASANVAR := $(shell echo $(WITHASAN)) -ifeq ($(WITHASANVAR),1) -WASAN=-fsanitize=address -# Force the disable of JEMALLOC, since ASAN isn't compatible. -export NOJEMALLOC = 1 -else -WASAN= +WASAN := +ifeq ($(WITHASAN),1) + WASAN := -fsanitize=address + # Force the disable of JEMALLOC, since ASAN isn't compatible. + export NOJEMALLOC=1 endif -#CFLAGS=$(IDIRS) $(OPTZ) $(DEBUG) -Wall #-lcrypto -#CXXFLAGS=-std=c++11 $(CFLAGS) $(LDIRS) $(LIBS) -NOJEMALLOC := $(shell echo $(NOJEMALLOC)) +NOJEM := ifeq ($(NOJEMALLOC),1) -NOJEM=-DNOJEM -else -NOJEM= + NOJEM := -DNOJEM endif -WITHGCOVVAR := $(shell echo $(WITHGCOV)) -ifeq ($(WITHGCOVVAR),1) -WGCOV=-DWITHGCOV --coverage -lgcov -else -WGCOV= +WGCOV := +ifeq ($(WITHGCOV),1) + WGCOV := -DWITHGCOV --coverage -lgcov endif -# determine good compiler version for stdc++17 -IS_CXX17 := 0 -ifeq ($(CXX),clang++) - CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') - CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER)))) - IS_CXX17 := 1 -endif -else - GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') - GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER)))) - IS_CXX17 := 1 +### detect compiler support for c++11/17 +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201703L) + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201103L) +$(error Compiler must support at least c++11) endif endif +STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) -PROXYSQLCLICKHOUSE := $(shell echo $(PROXYSQLCLICKHOUSE)) -PSQLCH= +PSQLCH := ifeq ($(PROXYSQLCLICKHOUSE),1) - PSQLCH=-DPROXYSQLCLICKHOUSE -ifeq ($(IS_CXX17),1) - PSQLCH=-DPROXYSQLCLICKHOUSE -std=c++17 -DCXX17 -endif + PSQLCH := -DPROXYSQLCLICKHOUSE endif # 'libhttpserver': Add 'ENABLE_EPOLL' by default for all platforms except # for 'Darwin'. This is required when compiling 'libhttpserver' for avoiding # internal use of 'SELECT' in favor of 'EPOLL'. See #3591. +ENABLE_EPOLL := -DENABLE_EPOLL ifeq ($(UNAME_S),Darwin) -ENABLE_EPOLL= -else -ENABLE_EPOLL=-DENABLE_EPOLL + ENABLE_EPOLL := endif -MYCFLAGS=$(IDIRS) $(OPTZ) $(DEBUG) -Wall -DGITVERSION=\"$(GIT_VERSION)\" $(NOJEM) $(WGCOV) $(WASAN) -MYCXXFLAGS=-std=c++11 $(MYCFLAGS) $(PSQLCH) $(ENABLE_EPOLL) +MYCFLAGS := $(IDIRS) $(OPTZ) $(DEBUG) -Wall -DGITVERSION=\"$(GIT_VERSION)\" $(NOJEM) $(WGCOV) $(WASAN) +MYCXXFLAGS := $(STDCPP) $(MYCFLAGS) $(PSQLCH) $(ENABLE_EPOLL) default: libproxysql.a .PHONY: default -_OBJ_CXX = ProxySQL_GloVars.oo network.oo debug.oo configfile.oo Query_Cache.oo SpookyV2.oo MySQL_Authentication.oo gen_utils.oo sqlite3db.oo mysql_connection.oo MySQL_HostGroups_Manager.oo mysql_data_stream.oo MySQL_Thread.oo MySQL_Session.oo MySQL_Protocol.oo mysql_backend.oo Query_Processor.oo ProxySQL_Admin.oo ProxySQL_Config.oo ProxySQL_Restapi.oo MySQL_Monitor.oo MySQL_Logger.oo thread.oo MySQL_PreparedStatement.oo ProxySQL_Cluster.oo ClickHouse_Authentication.oo ClickHouse_Server.oo ProxySQL_Statistics.oo Chart_bundle_js.oo ProxySQL_HTTP_Server.oo ProxySQL_RESTAPI_Server.oo font-awesome.min.css.oo main-bundle.min.css.oo set_parser.oo MySQL_Variables.oo c_tokenizer.oo proxysql_utils.oo proxysql_coredump.oo proxysql_sslkeylog.oo \ +_OBJ_CXX := ProxySQL_GloVars.oo network.oo debug.oo configfile.oo Query_Cache.oo SpookyV2.oo MySQL_Authentication.oo gen_utils.oo sqlite3db.oo mysql_connection.oo MySQL_HostGroups_Manager.oo mysql_data_stream.oo MySQL_Thread.oo MySQL_Session.oo MySQL_Protocol.oo mysql_backend.oo Query_Processor.oo ProxySQL_Admin.oo ProxySQL_Config.oo ProxySQL_Restapi.oo MySQL_Monitor.oo MySQL_Logger.oo thread.oo MySQL_PreparedStatement.oo ProxySQL_Cluster.oo ClickHouse_Authentication.oo ClickHouse_Server.oo ProxySQL_Statistics.oo Chart_bundle_js.oo ProxySQL_HTTP_Server.oo ProxySQL_RESTAPI_Server.oo font-awesome.min.css.oo main-bundle.min.css.oo set_parser.oo MySQL_Variables.oo c_tokenizer.oo proxysql_utils.oo proxysql_coredump.oo proxysql_sslkeylog.oo \ proxysql_find_charset.oo ProxySQL_Poll.oo -OBJ_CXX = $(patsubst %,$(ODIR)/%,$(_OBJ_CXX)) -HEADERS = ../include/*.h ../include/*.hpp +OBJ_CXX := $(patsubst %,$(ODIR)/%,$(_OBJ_CXX)) +HEADERS := ../include/*.h ../include/*.hpp %.ko: %.cpp $(HEADERS) $(CXX) -fPIC -c -o $@ $< $(MYCXXFLAGS) $(CXXFLAGS) diff --git a/lib/set_parser.cpp b/lib/set_parser.cpp index 729dfa6c2c..521808d642 100644 --- a/lib/set_parser.cpp +++ b/lib/set_parser.cpp @@ -71,8 +71,9 @@ void SetParser::set_query(const std::string& nq) { #define VAR_VALUE_P1 "(" VAR_VALUE_P1_1 VAR_VALUE_P1_2 VAR_VALUE_P1_3 VAR_VALUE_P1_4 VAR_VALUE_P1_5 VAR_VALUE_P1_6 ")" std::map> SetParser::parse1() { - +#ifdef DEBUG proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str()); +#endif // DEBUG re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet); opt2->set_case_sensitive(false); opt2->set_longest_match(false); @@ -85,9 +86,13 @@ std::map> SetParser::parse1() { std::map> result; const std::string pattern="(?:" NAMES SPACES QUOTES NAME_VALUE QUOTES "(?: +COLLATE +" QUOTES NAME_VALUE QUOTES "|)" "|" SESSION_P1 VAR_P1 SPACES "(?:|:)=" SPACES QUOTES VAR_VALUE_P1 QUOTES ") *,? *"; +#ifdef DEBUG VALGRIND_DISABLE_ERROR_REPORTING; +#endif // DEBUG re2::RE2 re(pattern, *opt2); +#ifdef DEBUG VALGRIND_ENABLE_ERROR_REPORTING; +#endif // DEBUG std::string var; std::string value1, value2, value3, value4, value5; re2::StringPiece input(query); @@ -289,9 +294,10 @@ void SetParser::generateRE_parse1v2() { var_value += s; } var_value += ")"; - +#ifdef DEBUG proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str()); +#endif // DEBUG parse1v2_opt2 = new re2::RE2::Options(RE2::Quiet); parse1v2_opt2->set_case_sensitive(false); parse1v2_opt2->set_longest_match(false); @@ -339,7 +345,9 @@ void SetParser::generateRE_parse1v2() { //const std::string pattern="(?:" NAMES SPACES QUOTES NAME_VALUE QUOTES "(?: +COLLATE +" QUOTES NAME_VALUE QUOTES "|)" "|" SESSION_P1 VAR_P1 SPACES "(?:|:)=" SPACES QUOTES VAR_VALUE_P1 QUOTES ") *,? *"; const std::string pattern="(?:" NAMES SPACES + name_value + "(?: +COLLATE +" + name_value + "|)" "|" + var_1 + SPACES "(?:|:)=" SPACES + var_value + ") *,? *"; //const std::string pattern=var_1 + SPACES "(?:|:)=" SPACES + var_value; +#ifdef DEBUG VALGRIND_DISABLE_ERROR_REPORTING; +#endif // DEBUG #ifdef PARSERDEBUG if (verbosity > 0) { cout << pattern << endl; @@ -364,7 +372,9 @@ std::map> SetParser::parse1v2() { re2::RE2 re1("(\\s|;)+$", *parse1v2_opt2); // remove trailing spaces and semicolon re2::RE2::Replace(&query, re1, ""); +#ifdef DEBUG VALGRIND_ENABLE_ERROR_REPORTING; +#endif // DEBUG std::string var; std::string value1, value2, value3, value4, value5; re2::StringPiece input(query); @@ -420,7 +430,9 @@ VALGRIND_ENABLE_ERROR_REPORTING; std::map> SetParser::parse2() { +#ifdef DEBUG proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str()); +#endif // DEBUG re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet); opt2->set_case_sensitive(false); opt2->set_longest_match(false); @@ -471,7 +483,9 @@ std::map> SetParser::parse2() { } std::string SetParser::parse_character_set() { +#ifdef DEBUG proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Parsing query %s\n", query.c_str()); +#endif // DEBUG re2::RE2::Options *opt2=new re2::RE2::Options(RE2::Quiet); opt2->set_case_sensitive(false); opt2->set_longest_match(false); diff --git a/src/Makefile b/src/Makefile index 8e58b1c120..a3adbb3448 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,224 +1,222 @@ #!/bin/make -f -ifndef GIT_VERSION - GIT_VERSION := $(shell git describe --long --abbrev=7) +GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION $(error GIT_VERSION is not set) endif -endif - -DEPS_PATH=../deps +CENTOSVER := Unknown ifneq (,$(wildcard /etc/system-release)) CENTOSVER := $(shell rpm --eval %rhel) -else - CENTOSVER := Unknown endif -MARIADB_PATH=$(DEPS_PATH)/mariadb-client-library/mariadb_client -MARIADB_IDIR=$(MARIADB_PATH)/include -MARIADB_LDIR=$(MARIADB_PATH)/libmariadb +PROXYSQL_PATH := .. +PROXYSQL_IDIR := $(PROXYSQL_PATH)/include +PROXYSQL_LDIR := $(PROXYSQL_PATH)/lib -DAEMONPATH=$(DEPS_PATH)/libdaemon/libdaemon -DAEMONPATH_IDIR=$(DAEMONPATH) -DAEMONPATH_LDIR=$(DAEMONPATH)/libdaemon/.libs +DEPS_PATH := $(PROXYSQL_PATH)/deps -JEMALLOC_PATH=$(DEPS_PATH)/jemalloc/jemalloc -JEMALLOC_IDIR=$(JEMALLOC_PATH)/include/jemalloc -JEMALLOC_LDIR=$(JEMALLOC_PATH)/lib +MARIADB_PATH := $(DEPS_PATH)/mariadb-client-library/mariadb_client +MARIADB_IDIR := $(MARIADB_PATH)/include +MARIADB_LDIR := $(MARIADB_PATH)/libmariadb -LIBCONFIG_PATH=$(DEPS_PATH)/libconfig/libconfig -LIBCONFIG_IDIR=-I$(LIBCONFIG_PATH)/lib -LIBCONFIG_LDIR=-L$(LIBCONFIG_PATH)/lib/.libs +LIBDAEMON_PATH := $(DEPS_PATH)/libdaemon/libdaemon +LIBDAEMON_IDIR := $(LIBDAEMON_PATH) +LIBDAEMON_LDIR := $(LIBDAEMON_PATH)/libdaemon/.libs -PROMETHEUS_PATH=$(DEPS_PATH)/prometheus-cpp/prometheus-cpp -PROMETHEUS_IDIR=$(PROMETHEUS_PATH)/pull/include -I$(PROMETHEUS_PATH)/core/include -PROMETHEUS_LDIR=$(PROMETHEUS_PATH)/lib +JEMALLOC_PATH := $(DEPS_PATH)/jemalloc/jemalloc +JEMALLOC_IDIR := $(JEMALLOC_PATH)/include/jemalloc +JEMALLOC_LDIR := $(JEMALLOC_PATH)/lib -RE2_PATH=$(DEPS_PATH)/re2/re2 -RE2_IDIR=$(RE2_PATH) +LIBCONFIG_PATH := $(DEPS_PATH)/libconfig/libconfig +LIBCONFIG_IDIR := $(LIBCONFIG_PATH)/lib +LIBCONFIG_LDIR := $(LIBCONFIG_PATH)/lib/.libs -PCRE_PATH=$(DEPS_PATH)/pcre/pcre -PCRE_LDIR=$(PCRE_PATH)/.libs +PROMETHEUS_PATH := $(DEPS_PATH)/prometheus-cpp/prometheus-cpp +PROMETHEUS_IDIR := $(PROMETHEUS_PATH)/pull/include -I$(PROMETHEUS_PATH)/core/include +PROMETHEUS_LDIR := $(PROMETHEUS_PATH)/lib -SQLITE3_DIR=$(DEPS_PATH)/sqlite3/sqlite3 +RE2_PATH := $(DEPS_PATH)/re2/re2 +RE2_IDIR := $(RE2_PATH) +RE2_LDIR := $(RE2_PATH)/obj -CITYHASH_DIR=$(DEPS_PATH)/cityhash/cityhash/src/.libs +PCRE_PATH := $(DEPS_PATH)/pcre/pcre +PCRE_IDIR := $(PCRE_PATH) +PCRE_LDIR := $(PCRE_PATH)/.libs -LZ4_DIR=$(DEPS_PATH)/lz4/lz4/lib +SQLITE3_PATH := $(DEPS_PATH)/sqlite3/sqlite3 +SQLITE3_IDIR := $(SQLITE3_PATH) +SQLITE3_LDIR := $(SQLITE3_PATH) -CLICKHOUSE_CPP_DIR=$(DEPS_PATH)/clickhouse-cpp/clickhouse-cpp +CITYHASH_PATH := $(DEPS_PATH)/cityhash/cityhash +CITYHASH_LDIR := $(CITYHASH_PATH)/src/.libs -LIBINJECTION_DIR=$(DEPS_PATH)/libinjection/libinjection -LIBINJECTION_IDIR=$(LIBINJECTION_DIR)/src -LIBINJECTION_LDIR=$(LIBINJECTION_DIR)/src +LZ4_PATH := $(DEPS_PATH)/lz4/lz4 +LZ4_LDIR := $(LZ4_PATH)/lib -LIBHTTPSERVER_DIR=$(DEPS_PATH)/libhttpserver/libhttpserver -LIBHTTPSERVER_IDIR=$(LIBHTTPSERVER_DIR)/src -LIBHTTPSERVER_LDIR=$(LIBHTTPSERVER_DIR)/build/src/.libs/ +CLICKHOUSE_CPP_PATH := $(DEPS_PATH)/clickhouse-cpp/clickhouse-cpp +CLICKHOUSE_CPP_CDIR := $(CLICKHOUSE_CPP_PATH)/contrib +CLICKHOUSE_CPP_IDIR := $(CLICKHOUSE_CPP_PATH) +CLICKHOUSE_CPP_LDIR := $(CLICKHOUSE_CPP_PATH)/clickhouse -MICROHTTPD_DIR=$(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src -MICROHTTPD_IDIR=$(MICROHTTPD_DIR)/include -MICROHTTPD_LDIR=$(MICROHTTPD_DIR)/microhttpd/.libs +LIBINJECTION_PATH := $(DEPS_PATH)/libinjection/libinjection +LIBINJECTION_IDIR := $(LIBINJECTION_PATH)/src +LIBINJECTION_LDIR := $(LIBINJECTION_PATH)/src -COREDUMPER_DIR=$(DEPS_PATH)/coredumper/coredumper -COREDUMPER_IDIR=$(COREDUMPER_DIR)/include -COREDUMPER_LDIR=$(COREDUMPER_DIR)/src +LIBHTTPSERVER_PATH := $(DEPS_PATH)/libhttpserver/libhttpserver +LIBHTTPSERVER_IDIR := $(LIBHTTPSERVER_PATH)/src +LIBHTTPSERVER_LDIR := $(LIBHTTPSERVER_PATH)/build/src/.libs/ -CURL_DIR=$(DEPS_PATH)/curl/curl -CURL_IDIR=$(CURL_DIR)/include -CURL_LDIR=$(CURL_DIR)/lib/.libs +MICROHTTPD_PATH := $(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src +MICROHTTPD_IDIR := $(MICROHTTPD_PATH)/include +MICROHTTPD_LDIR := $(MICROHTTPD_PATH)/microhttpd/.libs -SSL_DIR=$(DEPS_PATH)/libssl/openssl/ -SSL_IDIR=$(SSL_DIR)/include -SSL_LDIR=$(SSL_DIR) +COREDUMPER_PATH := $(DEPS_PATH)/coredumper/coredumper +COREDUMPER_IDIR := $(COREDUMPER_PATH)/include +COREDUMPER_LDIR := $(COREDUMPER_PATH)/src +CURL_PATH := $(DEPS_PATH)/curl/curl +CURL_IDIR := $(CURL_PATH)/include +CURL_LDIR := $(CURL_PATH)/lib/.libs -EV_DIR=$(DEPS_PATH)/libev/libev/ -EV_IDIR=$(EV_DIR) -EV_LDIR=$(EV_DIR)/.libs +SSL_PATH := $(DEPS_PATH)/libssl/openssl/ +SSL_IDIR := $(SSL_PATH)/include +SSL_LDIR := $(SSL_PATH) -IDIR=../include -LDIR=../lib -IDIRS=-I$(IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) $(LIBCONFIG_IDIR) -I$(DAEMONPATH_IDIR) -I$(SQLITE3_DIR) -I$(CLICKHOUSE_CPP_DIR) -I$(CLICKHOUSE_CPP_DIR)/contrib/ -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(LIBINJECTION_IDIR) -I$(CURL_IDIR) -I$(EV_IDIR) -I$(SSL_IDIR) -I$(RE2_IDIR) -I$(PROMETHEUS_IDIR) -LDIRS=-L$(LDIR) -L$(JEMALLOC_LDIR) $(LIBCONFIG_LDIR) -L$(RE2_PATH)/obj -L$(MARIADB_LDIR) -L$(DAEMONPATH_LDIR) -L$(PCRE_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(LIBINJECTION_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(SSL_LDIR) -L$(PROMETHEUS_LDIR) +EV_PATH := $(DEPS_PATH)/libev/libev/ +EV_IDIR := $(EV_PATH) +EV_LDIR := $(EV_PATH)/.libs + + +IDIRS := -I$(PROXYSQL_IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) -I$(LIBCONFIG_IDIR) -I$(LIBDAEMON_IDIR) -I$(RE2_IDIR) -L$(PCRE_IDIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(LIBINJECTION_IDIR) -I$(CURL_IDIR) -I$(EV_IDIR) -I$(SSL_IDIR) -I$(PROMETHEUS_IDIR) -I$(SQLITE3_IDIR) -I$(CLICKHOUSE_CPP_IDIR) -I$(CLICKHOUSE_CPP_CDIR) -I$(0) +LDIRS := -L$(PROXYSQL_LDIR) -L$(JEMALLOC_LDIR) -L$(MARIADB_LDIR) -L$(LIBCONFIG_LDIR) -L$(LIBDAEMON_LDIR) -L$(RE2_LDIR) -L$(PCRE_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(LIBINJECTION_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(SSL_LDIR) -L$(PROMETHEUS_LDIR) -UNAME_S := $(shell uname -s) +UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) - LDIRS+= -L$(COREDUMPER_LDIR) + LDIRS += -L$(COREDUMPER_LDIR) endif - ifeq ($(UNAME_S),Darwin) - IDIRS+= -I/usr/local/include - LDIRS+= -L/usr/local/lib -L/opt/homebrew/lib + IDIRS += -I/usr/local/include + LDIRS += -L/usr/local/lib -L/opt/homebrew/lib endif -# determine good compiler version for stdc++17 -IS_CXX17 := 0 -ifeq ($(CXX),clang++) - CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') - CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER)))) - IS_CXX17 := 1 -endif -else - GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') - GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }') -ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER)))) - IS_CXX17 := 1 +### detect compiler support for c++11/17 +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201703L) + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201103L) +$(error Compiler must support at least c++11) endif endif +STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) -PROXYSQLCLICKHOUSE := $(shell echo $(PROXYSQLCLICKHOUSE)) -PSQLCH= +PSQLCH := ifeq ($(PROXYSQLCLICKHOUSE),1) - PSQLCH=-DPROXYSQLCLICKHOUSE -ifeq ($(IS_CXX17),1) - PSQLCH=-DPROXYSQLCLICKHOUSE -std=c++17 -DCXX17 -endif + PSQLCH := -DPROXYSQLCLICKHOUSE endif - -WITHGCOVVAR := $(shell echo $(WITHGCOV)) -ifeq ($(WITHGCOVVAR),1) -WGCOV=-DWITHGCOV --coverage -else -WGCOV= +WGCOV := +ifeq ($(WITHGCOV),1) + WGCOV := -DWITHGCOV -lgcov --coverage endif -WITHASANVAR := $(shell echo $(WITHASAN)) -ifeq ($(WITHASANVAR),1) -WASAN= -fsanitize=address -# Force the disable of JEMALLOC, since ASAN isn't compatible. -export NOJEMALLOC = 1 -else -WASAN= +WASAN := +ifeq ($(WITHASAN),1) + WASAN := -fsanitize=address + # Force the disable of JEMALLOC, since ASAN isn't compatible. + export NOJEMALLOC=1 endif - -TEST_WITHASANVAR := $(shell echo $(TEST_WITHASAN)) -ifeq ($(TEST_WITHASANVAR),1) -WASAN+= -DTEST_WITHASAN +ifeq ($(TEST_WITHASAN),1) + WASAN += -DTEST_WITHASAN endif -MYCXXFLAGS=-std=c++11 +MYCXXFLAGS := $(STDCPP) ifeq ($(CXX),clang++) - MYCXXFLAGS+= -fuse-ld=lld + MYCXXFLAGS += -fuse-ld=lld endif -MYCXXFLAGS+= $(IDIRS) $(OPTZ) $(DEBUG) $(PSQLCH) -DGITVERSION=\"$(GIT_VERSION)\" $(WGCOV) $(WASAN) +MYCXXFLAGS += $(IDIRS) $(OPTZ) $(DEBUG) $(PSQLCH) -DGITVERSION=\"$(GIT_VERSION)\" $(WGCOV) $(WASAN) -ifeq ($(WITHGCOVVAR),1) -LDFLAGS+= -lgcov --coverage -endif -ifeq ($(WITHASANVAR),1) -LDFLAGS+= -fsanitize=address -endif - -NOJEMALLOC := $(shell echo $(NOJEMALLOC)) -STATICMYLIBS=-Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lcurl -lssl -lcrypto -lev -ifeq ($(NOJEMALLOC),1) -else - STATICMYLIBS+= -ljemalloc +STATICMYLIBS := -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lcurl -lssl -lcrypto -lev +ifneq ($(NOJEMALLOC),1) + STATICMYLIBS += -ljemalloc endif ifeq ($(UNAME_S),Linux) - STATICMYLIBS+= -lcoredumper + STATICMYLIBS += -lcoredumper endif -MYLIBS=-Wl,--export-dynamic $(STATICMYLIBS) -Wl,-Bdynamic -lgnutls -lpthread -lm -lz -lrt -lprometheus-cpp-pull -lprometheus-cpp-core -luuid $(EXTRALINK) +MYLIBS := -Wl,--export-dynamic $(STATICMYLIBS) -Wl,-Bdynamic -lgnutls -lpthread -lm -lz -lrt -lprometheus-cpp-pull -lprometheus-cpp-core -luuid $(EXTRALINK) ifeq ($(UNAME_S),Darwin) - MYLIBS=-lre2 -lmariadbclient -lpthread -lm -lz -liconv -lgnutls -lprometheus-cpp-pull -lprometheus-cpp-core -luuid + MYLIBS :=-lre2 -lmariadbclient -lpthread -lm -lz -liconv -lgnutls -lprometheus-cpp-pull -lprometheus-cpp-core -luuid else - CURL_DIR=$(DEPS_PATH)/curl/curl - IDIRS+= -L$(CURL_DIR)/include - LDIRS+= -L$(CURL_DIR)/lib/.libs + CURL_DIR := $(DEPS_PATH)/curl/curl + IDIRS += -L$(CURL_DIR)/include + LDIRS += -L$(CURL_DIR)/lib/.libs endif ifeq ($(UNAME_S),Linux) - MYLIBS+= -ldl + MYLIBS += -ldl endif ifeq ($(UNAME_S),FreeBSD) - MYLIBS+= -lexecinfo + MYLIBS += -lexecinfo endif ifeq ($(CENTOSVER),6) - MYLIBS+= -lgcrypt + MYLIBS += -lgcrypt endif -LIBPROXYSQLAR=$(LDIR)/libproxysql.a +LIBPROXYSQLAR := $(PROXYSQL_LDIR)/libproxysql.a ifeq ($(UNAME_S),Darwin) - LIBPROXYSQLAR=$(LDIR)/libproxysql.a ../deps/jemalloc/jemalloc/lib/libjemalloc.a ../deps/libmicrohttpd/libmicrohttpd/src/microhttpd/.libs/libmicrohttpd.a ../deps/libhttpserver/libhttpserver/build/src/.libs/libhttpserver.a ../deps/pcre/pcre/.libs/libpcre.a ../deps/pcre/pcre/.libs/libpcrecpp.a ../deps/libdaemon/libdaemon/libdaemon/.libs/libdaemon.a ../deps/libconfig/libconfig/lib/.libs/libconfig++.a ../deps/libconfig/libconfig/lib/.libs/libconfig.a ../deps/curl/curl/lib/.libs/libcurl.a ../deps/sqlite3/sqlite3/sqlite3.o ../deps/libinjection/libinjection/src/libinjection.a ../deps/libhttpserver/libhttpserver/build/src/.libs/libhttpserver.a ../deps/libev/libev/.libs/libev.a -endif - -LIBPROXYSQLAR+= $(SSL_LDIR)/libssl.a $(SSL_LDIR)/libcrypto.a $(CITYHASH_DIR)/libcityhash.a -ODIR= obj - -EXECUTABLE=proxysql - -_OBJ = main.o proxysql_global.o SQLite3_Server.o proxy_tls.o -OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) + LIBPROXYSQLAR += $(JEMALLOC_LDIR)/libjemalloc.a + LIBPROXYSQLAR += $(MICROHTTPD_LDIR)/libmicrohttpd.a + LIBPROXYSQLAR += $(LIBHTTPSERVER_LDIR)/libhttpserver.a + LIBPROXYSQLAR += $(PCRE_LDIR)/libpcre.a + LIBPROXYSQLAR += $(PCRE_LDIR)/libpcrecpp.a + LIBPROXYSQLAR += $(LIBDAEMON_LDIR)/libdaemon.a + LIBPROXYSQLAR += $(LIBCONFIG_LDIR)/libconfig++.a + LIBPROXYSQLAR += $(LIBCONFIG_LDIR)/libconfig.a + LIBPROXYSQLAR += $(CURL_LDIR)/libcurl.a + LIBPROXYSQLAR += $(SQLITE3_LDIR)/sqlite3.o + LIBPROXYSQLAR += $(LIBINJECTION_LDIR)/libinjection.a + LIBPROXYSQLAR += $(EV_LDIR)/libev.a +endif +LIBPROXYSQLAR += $(SSL_LDIR)/libssl.a +LIBPROXYSQLAR += $(SSL_LDIR)/libcrypto.a +LIBPROXYSQLAR += $(CITYHASH_LDIR)/libcityhash.a + +ODIR := obj + +EXECUTABLE := proxysql + +_OBJ := main.o proxysql_global.o SQLite3_Server.o proxy_tls.o +OBJ := $(patsubst %,$(ODIR)/%,$(_OBJ)) $(ODIR)/%.o: %.cpp $(CXX) -c -o $@ $< $(MYCXXFLAGS) $(CXXFLAGS) -Wall $(EXECUTABLE): $(ODIR) $(OBJ) $(LIBPROXYSQLAR) ifeq ($(PROXYSQLCLICKHOUSE),1) - $(CXX) -o $@ $(OBJ) $(LIBPROXYSQLAR) $(CLICKHOUSE_CPP_DIR)/clickhouse/libclickhouse-cpp-lib-static.a $(LZ4_DIR)/liblz4.a $(MYCXXFLAGS) $(CXXFLAGS) $(LDIRS) $(LIBS) $(LDFLAGS) $(MYLIBS) + $(CXX) -o $@ $(OBJ) $(LIBPROXYSQLAR) $(CLICKHOUSE_CPP_LDIR)/libclickhouse-cpp-lib-static.a $(LZ4_LDIR)/liblz4.a $(MYCXXFLAGS) $(CXXFLAGS) $(LDIRS) $(LIBS) $(MYLIBS) else - $(CXX) -o $@ $(OBJ) $(LIBPROXYSQLAR) $(MYCXXFLAGS) $(CXXFLAGS) $(LDIRS) $(LIBS) $(LDFLAGS) $(MYLIBS) + $(CXX) -o $@ $(OBJ) $(LIBPROXYSQLAR) $(MYCXXFLAGS) $(CXXFLAGS) $(LDIRS) $(LIBS) $(MYLIBS) endif ifeq ($(UNAME_S),Darwin) shasum $(EXECUTABLE) > $(EXECUTABLE).sha1 else sha1sum $(EXECUTABLE) > $(EXECUTABLE).sha1 endif + $(ODIR): mkdir $(ODIR) $(LIBPROXYSQLAR): - cd $(LDIR) && ${MAKE} + cd $(PROXYSQL_LDIR) && ${MAKE} + + +### main targets default: $(EXECUTABLE) diff --git a/test/Makefile b/test/Makefile index e50df910d9..9842ffd591 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,50 +1,73 @@ -DEPS_PATH=../deps +#!/bin/make -f -MARIADB_PATH=$(DEPS_PATH)/mariadb-client-library/mariadb_client -MARIADB_IDIR=$(MARIADB_PATH)/include +PROXYSQL_PATH := $(shell while [ ! -f ./src/proxysql_global.cpp ]; do cd ..; done; pwd) +PROXYSQL_IDIR := $(PROXYSQL_PATH)/include -JEMALLOC_PATH=$(DEPS_PATH)/jemalloc/jemalloc -JEMALLOC_IDIR=$(JEMALLOC_PATH)/include/jemalloc +DEPS_PATH := $(PROXYSQL_PATH)/deps -LIBCONFIG_PATH=$(DEPS_PATH)/libconfig/libconfig -LIBCONFIG_IDIR=-I$(LIBCONFIG_PATH)/lib -#INJECTION_PATH=$(DEPS_PATH)/libinjection -#INJECTION_IDIR=$(INJECTION_PATH) +MARIADB_PATH := $(DEPS_PATH)/mariadb-client-library/mariadb_client +MARIADB_IDIR := $(MARIADB_PATH)/include -RE2_PATH=$(DEPS_PATH)/re2/re2 -RE2_IDIR=$(RE2_PATH) +JEMALLOC_PATH := $(DEPS_PATH)/jemalloc/jemalloc +JEMALLOC_IDIR := $(JEMALLOC_PATH)/include/jemalloc -PCRE_PATH=$(DEPS_PATH)/pcre/pcre +LIBCONFIG_PATH := $(DEPS_PATH)/libconfig/libconfig +LIBCONFIG_IDIR := $(LIBCONFIG_PATH)/lib -SQLITE3_DIR=$(DEPS_PATH)/sqlite3/sqlite3 +#INJECTION_PATH := $(DEPS_PATH)/libinjection +#INJECTION_IDIR := $(INJECTION_PATH) -CLICKHOUSE_CPP_DIR=$(DEPS_PATH)/clickhouse-cpp/clickhouse-cpp +RE2_PATH := $(DEPS_PATH)/re2/re2 +RE2_IDIR := $(RE2_PATH) -LIBINJECTION_DIR=$(DEPS_PATH)/libinjection/libinjection -LIBINJECTION_IDIR=-I$(LIBINJECTION_DIR)/src +PCRE_PATH := $(DEPS_PATH)/pcre/pcre +PCRE_IDIR := $(PCRE_PATH) -LIBHTTPSERVER_DIR=$(DEPS_PATH)/libhttpserver/libhttpserver -LIBHTTPSERVER_IDIR=-I$(LIBHTTPSERVER_DIR)/src +SQLITE3_PATH := $(DEPS_PATH)/sqlite3/sqlite3 +SQLITE3_IDIR := $(SQLITE3_PATH) -MICROHTTPD_DIR=$(DEPS_PATH)/libmicrohttpd/libmicrohttpd -MICROHTTPD_IDIR=-I$(MICROHTTPD_DIR) -I$(MICROHTTPD_DIR)/src/include +CLICKHOUSE_CPP_PATH := $(DEPS_PATH)/clickhouse-cpp/clickhouse-cpp +CLICKHOUSE_CPP_IDIR := $(CLICKHOUSE_CPP_PATH) -CURL_DIR=$(DEPS_PATH)/curl/curl -CURL_IDIR=-I$(CURL_DIR)/include +LIBINJECTION_PATH := $(DEPS_PATH)/libinjection/libinjection +LIBINJECTION_IDIR := -I$(LIBINJECTION_PATH)/src -SSL_DIR=$(DEPS_PATH)/libssl/openssl/ -SSL_IDIR=$(SSL_DIR)/include +LIBHTTPSERVER_PATH := $(DEPS_PATH)/libhttpserver/libhttpserver +LIBHTTPSERVER_IDIR := -I$(LIBHTTPSERVER_PATH)/src +MICROHTTPD_PATH := $(DEPS_PATH)/libmicrohttpd/libmicrohttpd +MICROHTTPD_IDIR := $(MICROHTTPD_PATH)/src/include -EV_DIR=$(DEPS_PATH)/libev/libev/ -EV_IDIR=$(EV_DIR) +CURL_PATH := $(DEPS_PATH)/curl/curl +CURL_IDIR := -I$(CURL_PATH)/include -IDIR=../include +SSL_PATH := $(DEPS_PATH)/libssl/openssl/ +SSL_IDIR := $(SSL_PATH)/include -IDIRS=-I$(IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) $(LIBCONFIG_IDIR) -I$(RE2_IDIR) -I$(SQLITE3_DIR) -I$(PCRE_PATH) -I/usr/local/include -I$(CLICKHOUSE_CPP_DIR) $(MICROHTTPD_IDIR) $(LIBHTTPSERVER_IDIR) $(LIBINJECTION_IDIR) $(CURL_IDIR) -I$(EV_DIR) -I$(SSL_IDIR) +EV_PATH := $(DEPS_PATH)/libev/libev/ +EV_IDIR := $(EV_PATH) +LOCAL_IDIR := /usr/local/include + + +IDIRS := -I$(PROXYSQL_IDIR) +IDIRS += -I$(JEMALLOC_IDIR) +IDIRS += -I$(MARIADB_IDIR) +IDIRS += -I$(LIBCONFIG_IDIR) +IDIRS += -I$(RE2_IDIR) +IDIRS += -I$(SQLITE3_IDIR) +IDIRS += -I$(PCRE_IDIR) +IDIRS += -I$(LOCAL_IDIR) +IDIRS += -I$(CLICKHOUSE_CPP_DIR) +IDIRS += -I$(MICROHTTPD_PATH) +IDIRS += -I$(MICROHTTPD_IDIR) +IDIRS += -I$(LIBHTTPSERVER_IDIR) +IDIRS += -I$(LIBINJECTION_IDIR) +IDIRS += -I$(CURL_IDIR) +IDIRS += -I$(EV_DIR) +IDIRS += -I$(SSL_IDIR) sqlite_history_convert: sqlite_history_convert.cpp diff --git a/test/deps/Makefile b/test/deps/Makefile new file mode 100644 index 0000000000..d045a0212b --- /dev/null +++ b/test/deps/Makefile @@ -0,0 +1,66 @@ +#!/bin/make -f + + +PROXYSQL_PATH := $(shell while [ ! -f ./src/proxysql_global.cpp ]; do cd ..; done; pwd) +DEPS_PATH := $(PROXYSQL_PATH)/deps + + +.DEFAULT: default +.PHONY: default +default: all + +.PHONY: all +all: mariadb_client mysql_client + + +### test deps targets + +mariadb-connector-c/mariadb-connector-c/libmariadb/libmariadbclient.a: + cd mariadb-connector-c && rm -rf mariadb-connector-c-*/ || true + cd mariadb-connector-c && tar -zxf mariadb-connector-c-*.tar.gz + cd mariadb-connector-c/mariadb-connector-c && patch -p0 < ../CMakeLists.txt.patch + cd mariadb-connector-c/mariadb-connector-c && patch -p0 < ../ConnectorName.cmake.patch + cd mariadb-connector-c/mariadb-connector-c && cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(DEPS_PATH)/libssl/openssl/ + cd mariadb-connector-c/mariadb-connector-c && CC=${CC} CXX=${CXX} ${MAKE} mariadbclient + +mariadb_client: mariadb-connector-c/mariadb-connector-c/libmariadb/libmariadbclient.a + + +#mysql-connector-c/mysql-connector-c/libmysql/libmysqlclient.a: +# cd mysql-connector-c && rm -rf mysql-connector-c-*-src/ || true +# cd mysql-connector-c && tar -zxf mysql-connector-c-*-src.tar.gz +# cd mysql-connector-c/mysql-connector-c && patch -p0 < ../CMakeLists.txt.patch +# cd mysql-connector-c/mysql-connector-c && patch -p0 < ../install_macros.cmake.patch +# cd mysql-connector-c/mysql-connector-c && cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(DEPS_PATH)/libssl/openssl +# cd mysql-connector-c/mysql-connector-c && CC=${CC} CXX=${CXX} ${MAKE} mysqlclient mysql + +mysql-connector-c/mysql-connector-c/libmysql/libmysqlclient.a: + cd mysql-connector-c && curl -C - -O -s https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.44.tar.gz || true + cd mysql-connector-c && wget -nc -q https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.44.tar.gz || true + cd mysql-connector-c && rm -rf mysql-*/ || true + cd mysql-connector-c && tar -zxf mysql-boost-5.7.*.tar.gz + cd mysql-connector-c && ln -fsT $$(ls -1d mysql-5.7.*/) mysql-connector-c + cd mysql-connector-c/mysql-connector-c && cmake . -DWITH_BOOST=./boost -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O0 -ggdb -DNDEBUG -fPIC" -DOPENSSL_ROOT_DIR=$(DEPS_PATH)/libssl/openssl +# cd mysql-connector-c/mysql-connector-c && cmake . -DWITH_BOOST=./boost -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG="-O0 -ggdb -fPIC" -DOPENSSL_ROOT_DIR=$(DEPS_PATH)/libssl/openssl + cd mysql-connector-c/mysql-connector-c && CC=${CC} CXX=${CXX} ${MAKE} mysqlclient mysql + cd mysql-connector-c/mysql-connector-c && cp archive_output_directory/libmysqlclient.a libmysql/ + +mysql_client: mysql-connector-c/mysql-connector-c/libmysql/libmysqlclient.a + + +### clean targets + +.PHONY: cleanall +.SILENT: cleanall +cleanall: + cd mariadb-connector-c && rm -rf mariadb-connector-c-*/ || true + cd mysql-connector-c && rm -rf mysql-5.7.*/ || true + +.PHONY: clean +.SILENT: clean +clean: + cd mariadb-connector-c/mariadb-connector-c && $(MAKE) --no-print-directory clean || true + cd mariadb-connector-c/mariadb-connector-c && rm -f CMakeCache.txt || true + cd mysql-connector-c/mysql-connector-c && $(MAKE) --no-print-directory clean || true + cd mysql-connector-c/mysql-connector-c && rm -f CMakeCache.txt || true + cd mysql-connector-c/mysql-connector-c && rm -f libmysql/libmysqlclient.a || true diff --git a/test/deps/mariadb-connector-c/CMakeLists.txt.patch b/test/deps/mariadb-connector-c/CMakeLists.txt.patch new file mode 100644 index 0000000000..de55d09ad8 --- /dev/null +++ b/test/deps/mariadb-connector-c/CMakeLists.txt.patch @@ -0,0 +1,13 @@ +--- ./CMakeLists.txt 2020-02-27 15:01:10.993225716 +0100 ++++ ./CMakeLists.txt 2020-02-27 15:00:57.705257256 +0100 +@@ -132,8 +132,8 @@ + # Disable dbug information for release builds + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") +-SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") +-SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") ++SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF -ggdb -O0") ++SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF -ggdb -O0") + + IF(CMAKE_COMPILER_IS_GNUCC) + INCLUDE(CheckCCompilerFlag) diff --git a/test/deps/mariadb-connector-c/ConnectorName.cmake.patch b/test/deps/mariadb-connector-c/ConnectorName.cmake.patch new file mode 100644 index 0000000000..5aa3e9666d --- /dev/null +++ b/test/deps/mariadb-connector-c/ConnectorName.cmake.patch @@ -0,0 +1,11 @@ +--- cmake/ConnectorName.cmake 2020-10-29 22:16:20.000000000 +0000 ++++ cmake/ConnectorName.cmake 2022-11-06 08:31:22.615513943 +0000 +@@ -22,7 +22,7 @@ + SET(MACHINE_NAME "x64") + ELSE() + SET(MACHINE_NAME "32") +- END() ++ ENDIF() + ENDIF() + + SET(product_name "mysql-connector-c-${CPACK_PACKAGE_VERSION}-${PLATFORM_NAME}${CONCAT_SIGN}${MACHINE_NAME}") diff --git a/test/deps/mariadb-connector-c/mariadb-connector-c b/test/deps/mariadb-connector-c/mariadb-connector-c new file mode 120000 index 0000000000..a92e60f909 --- /dev/null +++ b/test/deps/mariadb-connector-c/mariadb-connector-c @@ -0,0 +1 @@ +mariadb-connector-c-3.1.9 \ No newline at end of file diff --git a/test/deps/mariadb-connector-c/mariadb-connector-c-3.1.9.tar.gz b/test/deps/mariadb-connector-c/mariadb-connector-c-3.1.9.tar.gz new file mode 100644 index 0000000000..6af78adefc Binary files /dev/null and b/test/deps/mariadb-connector-c/mariadb-connector-c-3.1.9.tar.gz differ diff --git a/test/deps/mysql-connector-c/mysql-connector-c b/test/deps/mysql-connector-c/mysql-connector-c new file mode 120000 index 0000000000..7b32ab211a --- /dev/null +++ b/test/deps/mysql-connector-c/mysql-connector-c @@ -0,0 +1 @@ +mysql-5.7.44/ \ No newline at end of file diff --git a/test/tap/Makefile b/test/tap/Makefile index 39bab26d1c..ee93f10b31 100644 --- a/test/tap/Makefile +++ b/test/tap/Makefile @@ -1,20 +1,34 @@ +#!/bin/make -f + + +.DEFAULT: all .PHONY: all -all: tap tests tests_with_deps +all: tests tests_with_deps -.PHONY: clean -clean: - cd tap && ${MAKE} clean - cd tests && ${MAKE} clean - cd tests_with_deps && ${MAKE} clean +.PHONY: debug +debug: tests tests_with_deps -debug: tap tests tests_with_deps +.PHONY: test_deps +test_deps: + cd ../deps && CC=${CC} CXX=${CXX} ${MAKE} .PHONY: tap -tap: - cd tap && CC=${CC} CXX=${CXX} ${MAKE} $(MAKECMDGOALS) +tap: + cd tap && CC=${CC} CXX=${CXX} ${MAKE} -tests: tap +.PHONY: tests +tests: tap test_deps cd tests && CC=${CC} CXX=${CXX} ${MAKE} $(MAKECMDGOALS) -tests_with_deps: tap tests +.PHONY: tests_with_deps +tests_with_deps: tap test_deps cd tests_with_deps && CC=${CC} CXX=${CXX} ${MAKE} $(MAKECMDGOALS) + + +.PHONY: clean +.SILENT: clean +clean: + cd ../deps && ${MAKE} -s clean + cd tap && ${MAKE} -s clean + cd tests && ${MAKE} -s clean + cd tests_with_deps && ${MAKE} -s clean diff --git a/test/tap/tap/Makefile b/test/tap/tap/Makefile index 9e58496e42..47df6e1188 100644 --- a/test/tap/tap/Makefile +++ b/test/tap/tap/Makefile @@ -1,58 +1,91 @@ -DEPS_PATH=../../../deps +#!/bin/make -f -JSON_IDIR=$(DEPS_PATH)/json -MARIADB_PATH=$(DEPS_PATH)/mariadb-client-library/mariadb_client -MARIADB_IDIR=$(MARIADB_PATH)/include -MARIADB_LDIR=$(MARIADB_PATH)/libmariadb +GIT_VERSION ?= $(shell git describe --long --abbrev=7) +ifndef GIT_VERSION + $(error GIT_VERSION is not set) +endif -CURL_DIR=$(DEPS_PATH)/curl/curl -CURL_IDIR=$(CURL_DIR)/include -CURL_LDIR=$(CURL_DIR)/lib/.libs -SQLITE3_DIR=$(DEPS_PATH)/sqlite3/sqlite3 -SQLITE3_IDIR=$(SQLITE3_DIR) -SQLITE3_LDIR=$(SQLITE3_DIR) +PROXYSQL_PATH := ../../.. +PROXYSQL_IDIR := $(PROXYSQL_PATH)/include +PROXYSQL_LDIR := $(PROXYSQL_PATH)/lib -DOTENV_DIR=./cpp-dotenv/static/cpp-dotenv -DOTENV_IDIR=$(DOTENV_DIR)/include -DOTENV_LDIR=$(DOTENV_DIR) +DEPS_PATH := $(PROXYSQL_PATH)/deps -IDIR=../../../include -LDIR=../../../lib +JSON_PATH := $(DEPS_PATH)/json +JSON_IDIR := $(JSON_PATH) -LIBPROXYSQLAR=$(LDIR)/libproxysql.a -INCLUDEDIRS=-I$(IDIR) -I$(JSON_IDIR) -I$(MARIADB_IDIR) -I${CURL_IDIR} -I${SQLITE3_IDIR} -I$(DOTENV_IDIR) +MARIADB_PATH := $(DEPS_PATH)/mariadb-client-library/mariadb_client +MARIADB_IDIR := $(MARIADB_PATH)/include +MARIADB_LDIR := $(MARIADB_PATH)/libmariadb + +CURL_PATH := $(DEPS_PATH)/curl/curl +CURL_IDIR := $(CURL_PATH)/include +CURL_LDIR := $(CURL_PATH)/lib/.libs + +SQLITE3_PATH := $(DEPS_PATH)/sqlite3/sqlite3 +SQLITE3_IDIR := $(SQLITE3_PATH) +SQLITE3_LDIR := $(SQLITE3_PATH) + +DOTENV_PATH := ./cpp-dotenv/static/cpp-dotenv +DOTENV_IDIR := $(DOTENV_PATH)/include +DOTENV_LDIR := $(DOTENV_PATH) + + +LIBPROXYSQLAR := $(PROXYSQL_LDIR)/libproxysql.a + +IDIRS := -I$(PROXYSQL_IDIR) -I$(JSON_IDIR) -I$(MARIADB_IDIR) -I${CURL_IDIR} -I${SQLITE3_IDIR} -I$(DOTENV_IDIR) + +### detect compiler support for c++11/17 +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201703L) + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201103L) + $(error Compiler must support at least c++11) +endif +endif +STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) + +WASAN := +ifeq ($(WITHASAN),1) + WASAN := -fsanitize=address +endif + +OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed $(WASAN) + + +### main targets + +.PHONY: default +default: all .PHONY: all all: libtap.a libtap.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so -.PHONY: clean -clean: - rm -f *.o libtap.a libtap.so || true - find . -name '*.so' -type f -delete || true - find cpp-dotenv/dynamic -name '*.o' -or -name '*.a' -delete || true - find cpp-dotenv/static -name '*.o' -or -name '*.a' -delete || true +debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WASAN) +debug: libtap.a libtap.so -OPT=-O2 -debug: OPT = -O0 -DDEBUG -ggdb -debug: libtap.a libtap.so +### helper targets command_line.o: command_line.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so - g++ -fPIC -c command_line.cpp -std=c++11 $(INCLUDEDIRS) $(OPT) + g++ -fPIC -c command_line.cpp $(IDIRS) $(OPT) utils.o: utils.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so - g++ -fPIC -c utils.cpp -std=c++11 $(INCLUDEDIRS) $(OPT) + g++ -fPIC -c utils.cpp $(IDIRS) $(OPT) tap.o: tap.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so - g++ -fPIC -c tap.cpp -std=c++11 $(INCLUDEDIRS) $(OPT) + g++ -fPIC -c tap.cpp $(IDIRS) $(OPT) -libtap.a: tap.cpp tap.h command_line.cpp command_line.h utils.cpp utils.h tap.o command_line.o utils.o cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a +libtap.a: tap.o command_line.o utils.o cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a ar rcs libtap.a tap.o command_line.o utils.o $(SQLITE3_LDIR)/sqlite3.o libtap.so: libtap.a cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so - gcc -shared -o libtap.so -Wl,--whole-archive libtap.a ../../../deps/curl/curl/lib/.libs/libcurl.a ../../../deps/libssl/openssl/libcrypto.a ../../../deps/libssl/openssl/libssl.a -Wl,--no-whole-archive + gcc -shared -o libtap.so -Wl,--whole-archive libtap.a -Wl,--no-whole-archive + + +### tap deps targets libssl.so.3: $(DEPS_PATH)/libssl/openssl/libssl.so.3 cp -a $(DEPS_PATH)/libssl/openssl/libssl.so* . @@ -81,3 +114,14 @@ cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so: cd cpp-dotenv/dynamic/cpp-dotenv && patch include/dotenv.h < ../../dotenv.h.patch cd cpp-dotenv/dynamic/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug cd cpp-dotenv/dynamic/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE} + + +### clean targets + +.SILENT: clean +.PHONY: clean +clean: + find . -name '*.a' -delete || true + find . -name '*.o' -delete || true + find . -name '*.so' -delete || true + find . -name '*.so.*' -delete || true diff --git a/test/tap/tests/Makefile b/test/tap/tests/Makefile index 5a4d57bc0c..422ead51cc 100644 --- a/test/tap/tests/Makefile +++ b/test/tap/tests/Makefile @@ -1,147 +1,210 @@ -DEPS_PATH=../../../deps +#!/bin/make -f -MARIADB_PATH=$(DEPS_PATH)/mariadb-client-library/mariadb_client -MARIADB_IDIR=$(MARIADB_PATH)/include -MARIADB_LDIR=$(MARIADB_PATH)/libmariadb -JEMALLOC_PATH=$(DEPS_PATH)/jemalloc/jemalloc -JEMALLOC_IDIR=$(JEMALLOC_PATH)/include/jemalloc -JEMALLOC_LDIR=$(JEMALLOC_PATH)/lib +GIT_VERSION ?= $(shell git describe --long --abbrev=7) +ifndef GIT_VERSION + $(error GIT_VERSION is not set) +endif + + +PROXYSQL_PATH := $(shell while [ ! -f ./src/proxysql_global.cpp ]; do cd ..; done; pwd) +PROXYSQL_IDIR := $(PROXYSQL_PATH)/include +PROXYSQL_LDIR := $(PROXYSQL_PATH)/lib + +DEPS_PATH := $(PROXYSQL_PATH)/deps + +MARIADB_PATH := $(DEPS_PATH)/mariadb-client-library/mariadb_client +MARIADB_IDIR := $(MARIADB_PATH)/include +MARIADB_LDIR := $(MARIADB_PATH)/libmariadb -PROXYSQL_PATH=../../.. -PROXYSQL_IDIR=$(PROXYSQL_PATH)/include +JEMALLOC_PATH := $(DEPS_PATH)/jemalloc/jemalloc +JEMALLOC_IDIR := $(JEMALLOC_PATH)/include/jemalloc +JEMALLOC_LDIR := $(JEMALLOC_PATH)/lib -JSON_IDIR=$(DEPS_PATH)/json +JSON_IDIR := $(DEPS_PATH)/json -RE2_PATH=$(DEPS_PATH)/re2/re2 -RE2_IDIR=$(RE2_PATH) +RE2_PATH := $(DEPS_PATH)/re2/re2 +RE2_IDIR := $(RE2_PATH) +RE2_LDIR := $(RE2_PATH)/obj -SQLITE3_DIR=$(DEPS_PATH)/sqlite3/sqlite3 +SQLITE3_PATH := $(DEPS_PATH)/sqlite3/sqlite3 +SQLITE3_IDIR := $(SQLITE3_PATH) +SQLITE3_LDIR := $(SQLITE3_PATH) -LIBHTTPSERVER_DIR=$(DEPS_PATH)/libhttpserver/libhttpserver -LIBHTTPSERVER_IDIR=$(LIBHTTPSERVER_DIR)/src -LIBHTTPSERVER_LDIR=$(LIBHTTPSERVER_DIR)/build/src/.libs/ +LIBHTTPSERVER_DIR := $(DEPS_PATH)/libhttpserver/libhttpserver +LIBHTTPSERVER_IDIR := $(LIBHTTPSERVER_DIR)/src +LIBHTTPSERVER_LDIR := $(LIBHTTPSERVER_DIR)/build/src/.libs/ -LIBCONFIG_PATH=$(DEPS_PATH)/libconfig/libconfig -LIBCONFIG_IDIR=$(LIBCONFIG_PATH)/lib -LIBCONFIG_LDIR=-L$(LIBCONFIG_PATH)/lib/.libs +LIBCONFIG_PATH := $(DEPS_PATH)/libconfig/libconfig +LIBCONFIG_IDIR := $(LIBCONFIG_PATH)/lib +LIBCONFIG_LDIR := $(LIBCONFIG_PATH)/lib/.libs -CURL_DIR=$(DEPS_PATH)/curl/curl -CURL_IDIR=$(CURL_DIR)/include -CURL_LDIR=$(CURL_DIR)/lib/.libs +CURL_DIR := $(DEPS_PATH)/curl/curl +CURL_IDIR := $(CURL_DIR)/include +CURL_LDIR := $(CURL_DIR)/lib/.libs -DAEMONPATH=$(DEPS_PATH)/libdaemon/libdaemon -DAEMONPATH_IDIR=$(DAEMONPATH) -DAEMONPATH_LDIR=$(DAEMONPATH)/libdaemon/.libs +DAEMONPATH := $(DEPS_PATH)/libdaemon/libdaemon +DAEMONPATH_IDIR := $(DAEMONPATH) +DAEMONPATH_LDIR := $(DAEMONPATH)/libdaemon/.libs -PCRE_PATH=$(DEPS_PATH)/pcre/pcre -PCRE_LDIR=$(PCRE_PATH)/.libs +PCRE_PATH := $(DEPS_PATH)/pcre/pcre +PCRE_LDIR := $(PCRE_PATH)/.libs -MICROHTTPD_DIR=$(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src -MICROHTTPD_IDIR=$(MICROHTTPD_DIR)/include -MICROHTTPD_LDIR=$(MICROHTTPD_DIR)/microhttpd/.libs +MICROHTTPD_DIR := $(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src +MICROHTTPD_IDIR := $(MICROHTTPD_DIR)/include +MICROHTTPD_LDIR := $(MICROHTTPD_DIR)/microhttpd/.libs -LIBINJECTION_DIR=$(DEPS_PATH)/libinjection/libinjection -LIBINJECTION_IDIR=$(LIBINJECTION_DIR)/src -LIBINJECTION_LDIR=$(LIBINJECTION_DIR)/src +LIBINJECTION_DIR := $(DEPS_PATH)/libinjection/libinjection +LIBINJECTION_IDIR := $(LIBINJECTION_DIR)/src +LIBINJECTION_LDIR := $(LIBINJECTION_DIR)/src -SSL_DIR=$(DEPS_PATH)/libssl/openssl/ -SSL_IDIR=$(SSL_DIR)/include -SSL_LDIR=$(SSL_DIR) +SSL_DIR := $(DEPS_PATH)/libssl/openssl/ +SSL_IDIR := $(SSL_DIR)/include +SSL_LDIR := $(SSL_DIR) -EV_DIR=$(DEPS_PATH)/libev/libev/ -EV_IDIR=$(EV_DIR) -EV_LDIR=$(EV_DIR)/.libs +EV_DIR := $(DEPS_PATH)/libev/libev/ +EV_IDIR := $(EV_DIR) +EV_LDIR := $(EV_DIR)/.libs -PROMETHEUS_PATH=$(DEPS_PATH)/prometheus-cpp/prometheus-cpp -PROMETHEUS_IDIR=$(PROMETHEUS_PATH)/pull/include -I$(PROMETHEUS_PATH)/core/include -PROMETHEUS_LDIR=$(PROMETHEUS_PATH)/lib +PROMETHEUS_PATH := $(DEPS_PATH)/prometheus-cpp/prometheus-cpp +PROMETHEUS_IDIR := $(PROMETHEUS_PATH)/pull/include -I$(PROMETHEUS_PATH)/core/include +PROMETHEUS_LDIR := $(PROMETHEUS_PATH)/lib -CITYHASH_DIR=$(DEPS_PATH)/cityhash/cityhash/ -CITYHASH_IDIR=$(CITYHASH_DIR) -CITYHASH_LDIR=$(CITYHASH_DIR)/src/.libs +CITYHASH_DIR := $(DEPS_PATH)/cityhash/cityhash/ +CITYHASH_IDIR := $(CITYHASH_DIR) +CITYHASH_LDIR := $(CITYHASH_DIR)/src/.libs -COREDUMPER_DIR=$(DEPS_PATH)/coredumper/coredumper -COREDUMPER_IDIR=$(COREDUMPER_DIR)/include -COREDUMPER_LDIR=$(COREDUMPER_DIR)/src +COREDUMPER_DIR := $(DEPS_PATH)/coredumper/coredumper +COREDUMPER_IDIR := $(COREDUMPER_DIR)/include +COREDUMPER_LDIR := $(COREDUMPER_DIR)/src -IDIR=../../../include -LDIR=../../../lib -TAP_LIBDIR=../tap +TAP_PATH := ../tap +TAP_IDIR := ../tap +TAP_LDIR := ../tap -DOTENV_DYN_DIR=../tap/cpp-dotenv/dynamic/cpp-dotenv -DOTENV_DYN_IDIR=$(DOTENV_DYN_DIR)/include -#DOTENV_DYN_LDIR=$(DOTENV_DYN_DIR) -DOTENV_DYN_LDIR=$(TAP_LIBDIR) +DOTENV_DYN_PATH := $(TAP_LDIR)/cpp-dotenv/dynamic/cpp-dotenv +DOTENV_DYN_IDIR := $(DOTENV_DYN_PATH)/include +#DOTENV_DYN_LDIR := $(DOTENV_DYN_PATH) +DOTENV_DYN_LDIR := $(TAP_LDIR) -LIBPROXYSQLAR=$(LDIR)/libproxysql.a +TEST_DEPS_PATH := $(PROXYSQL_PATH)/test/deps -ODIR=../../../obj +TEST_MARIADB_PATH := $(TEST_DEPS_PATH)/mariadb-connector-c/mariadb-connector-c +TEST_MARIADB_IDIR := $(TEST_MARIADB_PATH)/include +TEST_MARIADB_LDIR := $(TEST_MARIADB_PATH)/libmariadb -EXECUTABLE=proxysql +TEST_MYSQL_PATH := $(TEST_DEPS_PATH)/mysql-connector-c/mysql-connector-c +TEST_MYSQL_IDIR := $(TEST_MYSQL_PATH)/include +TEST_MYSQL_EDIR := $(TEST_MYSQL_PATH)/libbinlogevents/export/ +TEST_MYSQL_LDIR := $(TEST_MYSQL_PATH)/libmysql -OBJ=../../../src/obj/proxysql_global.o ../../../src/obj/main.o ../../../src/obj/proxy_tls.o +LIBPROXYSQLAR := $(PROXYSQL_LDIR)/libproxysql.a -INCLUDEDIRS=-I../tap -I$(RE2_PATH) -I$(IDIR) -I$(JEMALLOC_IDIR) -I$(SQLITE3_DIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(CURL_IDIR) -I$(DAEMONPATH_IDIR) -I$(MARIADB_IDIR) -I$(SSL_IDIR) -I$(JSON_IDIR) -I$(LIBCONFIG_IDIR) -I$(PROMETHEUS_IDIR) -I$(EV_IDIR) -I$(DOTENV_DYN_IDIR) -LDIRS=-L$(TAP_LIBDIR) -L$(DOTENV_DYN_LDIR) -L$(LDIR) -L$(JEMALLOC_LDIR) $(LIBCONFIG_LDIR) -L$(RE2_PATH)/obj -L$(MARIADB_LDIR) -L$(DAEMONPATH_LDIR) -L$(PCRE_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(LIBINJECTION_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(PROMETHEUS_LDIR) +ODIR := $(PROXYSQL_PATH)/obj + +EXECUTABLE := proxysql + +OBJ := $(PROXYSQL_PATH)/src/obj/proxysql_global.o $(PROXYSQL_PATH)/src/obj/main.o $(PROXYSQL_PATH)/src/obj/proxy_tls.o + +IDIRS := -I$(TAP_IDIR) -I$(RE2_IDIR) -I$(PROXYSQL_IDIR) -I$(JEMALLOC_IDIR) -I$(LIBCONFIG_IDIR) -I$(MARIADB_IDIR) -I$(DAEMONPATH_IDIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(CURL_IDIR) -I$(EV_IDIR) -I$(PROMETHEUS_IDIR) -I$(DOTENV_DYN_IDIR) -I$(SSL_IDIR) -I$(SQLITE3_IDIR) -I$(JSON_IDIR) +LDIRS := -L$(TAP_LDIR) -L$(RE2_LDIR) -L$(PROXYSQL_LDIR) -L$(JEMALLOC_LDIR) -L$(LIBCONFIG_LDIR) -L$(MARIADB_LDIR) -L$(DAEMONPATH_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(PROMETHEUS_LDIR) -L$(DOTENV_DYN_LDIR) -L$(SSL_LDIR) -L$(PCRE_LDIR) -L$(LIBINJECTION_LDIR) UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) - LDIRS+= -L$(COREDUMPER_LDIR) + LDIRS += -L$(COREDUMPER_LDIR) endif -MYLIBS=-Wl,--export-dynamic -Wl,-Bdynamic -lssl -lcrypto -lgnutls -ltap -lcpp_dotenv -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lcurl -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl $(EXTRALINK) -#MYLIBS=-Wl,--export-dynamic -Wl,-Bdynamic -lssl -lcrypto -lgnutls -ltap -lcpp_dotenv -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl $(EXTRALINK) -MYLIBSJEMALLOC=-Wl,-Bstatic -ljemalloc -STATIC_LIBS= $(CITYHASH_LDIR)/libcityhash.a -#STATIC_LIBS= $(SSL_LDIR)/libssl.a $(SSL_LDIR)/libcrypto.a $(CITYHASH_LDIR)/libcityhash.a - -LIBCOREDUMPERAR= +MYLIBS := -Wl,--export-dynamic +MYLIBS += -Wl,-Bdynamic -lgnutls -ltap -lcpp_dotenv -lcurl -lssl -lcrypto +MYLIBS += -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid +MYLIBS += -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl $(EXTRALINK) +#MYLIBS := -Wl,--export-dynamic -Wl,-Bdynamic -lssl -lcrypto -lgnutls -ltap -lcpp_dotenv -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl $(EXTRALINK) +MYLIBSJEMALLOC := -Wl,-Bstatic -ljemalloc +STATIC_LIBS := $(CITYHASH_LDIR)/libcityhash.a +#STATIC_LIBS := $(SSL_LDIR)/libssl.a $(SSL_LDIR)/libcrypto.a $(CITYHASH_LDIR)/libcityhash.a +LIBCOREDUMPERAR := ifeq ($(UNAME_S),Linux) - LIBCOREDUMPERAR=$(COREDUMPER_LDIR)/libcoredumper.a - STATIC_LIBS+= $(LIBCOREDUMPERAR) + LIBCOREDUMPERAR := $(COREDUMPER_LDIR)/libcoredumper.a + STATIC_LIBS += $(LIBCOREDUMPERAR) endif -.PHONY: all -all: tests - -.PHONY: clean -clean: - rm -f *-t galera_1_timeout_count galera_2_timeout_no_count aurora generate_set_session_csv set_testing-240.csv clickhouse_php_conn-t reg_test_3992_fast_forward_malformed_packet-pymysql-t || true +### detect compiler support for c++11/17 +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201703L) + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201103L) + $(error Compiler must support at least c++11) +endif +endif +STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) -WITHGCOVVAR := $(shell echo $(WITHGCOV)) -ifeq ($(WITHGCOVVAR),1) -WGCOV=-DWITHGCOV --coverage -lgcov -else -WGCOV= +WGCOV := +ifeq ($(WITHGCOV),1) + WGCOV := -DWITHGCOV --coverage -lgcov endif -WITHASANVAR := $(shell echo $(WITHASAN)) -ifeq ($(WITHASANVAR),1) -WASAN=-fsanitize=address -DTEST_WITHASAN -else -WASAN= +WASAN := +ifeq ($(WITHASAN),1) + WASAN := -fsanitize=address -DTEST_WITHASAN endif -OPT=-O2 $(WGCOV) -Wl,--no-as-needed -debug: OPT=-O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WGCOV) $(WASAN) +OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed -Wl,-rpath,$(TAP_LDIR) $(WGCOV) $(WASAN) -DGITVERSION=\"$(GIT_VERSION)\" + + +### main targets + +.DEFAULT: default +.PHONY: default +default: all + +.PHONY: all +all: tests + +debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed -Wl,-rpath,$(TAP_LDIR) $(WGCOV) $(WASAN) -DGITVERSION=\"$(GIT_VERSION)\" debug: tests -tests: tests-cpp tests-php tests-py \ - setparser_test reg_test_3504-change_user_libmariadb_helper reg_test_3504-change_user_libmysql_helper \ +#tests: build_test_deps +tests: tests-cpp \ + tests-php \ + tests-py \ + setparser_test \ + reg_test_3504-change_user_libmariadb_helper \ + reg_test_3504-change_user_libmysql_helper \ setparser_test2 setparser_test2-t \ setparser_test3 setparser_test3-t \ - set_testing-240.csv test_clickhouse_server_libmysql-t reg_test_stmt_resultset_err_no_rows_libmysql-t \ - prepare_statement_err3024_libmysql-t prepare_statement_err3024_async-t reg_test_mariadb_stmt_store_result_libmysql-t \ + set_testing-240.csv \ + test_clickhouse_server_libmysql-t \ + reg_test_stmt_resultset_err_no_rows_libmysql-t \ + prepare_statement_err3024_libmysql-t \ + prepare_statement_err3024_async-t \ + reg_test_mariadb_stmt_store_result_libmysql-t \ reg_test_mariadb_stmt_store_result_async-t + tests-cpp: $(patsubst %.cpp,%,$(wildcard *-t.cpp)) tests-php: $(patsubst %,php-%,$(wildcard *-t.php)) tests-py: $(patsubst %,py-%,$(wildcard *-t.py)) testgalera: galera_1_timeout_count galera_2_timeout_no_count testaurora: aurora + +### test deps targets + +#build_test_deps: $(TAP_LDIR)/libtap.so $(TEST_MARIADB_LDIR)/libmariadbclient.a $(TEST_MYSQL_LDIR)/libmysqlclient.a + +$(TAP_LDIR)/libtap.so: + cd $(TAP_PATH) && CC=${CC} CXX=${CXX} ${MAKE} + +$(TEST_MARIADB_LDIR)/libmariadbclient.a: + cd $(TEST_DEPS_PATH) && CC=${CC} CXX=${CXX} ${MAKE} mariadb_client + +$(TEST_MYSQL_LDIR)/libmysqlclient.a: + cd $(TEST_DEPS_PATH) && CC=${CC} CXX=${CXX} ${MAKE} mysql_client + + +### helper targets + set_testing-240.csv: generate_set_session_csv ./generate_set_session_csv > set_testing-240.csv @@ -153,82 +216,100 @@ py-%: cp $(patsubst py-%,%,$@) $(patsubst py-%.py,%,$@) chmod +x $(patsubst py-%.py,%,$@) -%-t: %-t.cpp $(TAP_LIBDIR)/libtap.so - $(CXX) -std=c++11 $< $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ -# $(CXX) -std=c++11 $< $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl $(STATIC_LIBS) $(TAP_LIBDIR)/libtap.a -o $@ +%-t: %-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ +# $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl $(STATIC_LIBS) $(TAP_LDIR)/libtap.so -o $@ -galera_1_timeout_count: galera_1_timeout_count.cpp $(TAP_LIBDIR)/libtap.a - g++ -DTEST_GALERA -DDEBUG galera_1_timeout_count.cpp ../tap/SQLite3_Server.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o galera_1_timeout_count -DGITVERSION=\"$(GIT_VERSION)\" +galera_1_timeout_count: galera_1_timeout_count.cpp $(TAP_LDIR)/libtap.so + g++ -DTEST_GALERA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ -galera_2_timeout_no_count: galera_2_timeout_no_count.cpp $(TAP_LIBDIR)/libtap.a - g++ -DTEST_GALERA -DDEBUG galera_2_timeout_no_count.cpp ../tap/SQLite3_Server.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o galera_2_timeout_no_count -DGITVERSION=\"$(GIT_VERSION)\" +galera_2_timeout_no_count: galera_2_timeout_no_count.cpp $(TAP_LDIR)/libtap.so + g++ -DTEST_GALERA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ generate_set_session_csv: generate_set_session_csv.cpp - g++ -o generate_set_session_csv generate_set_session_csv.cpp -O0 -ggdb + g++ $< $(OPT) -o $@ -aurora: aurora.cpp $(TAP_LIBDIR)/libtap.a - g++ -DTEST_AURORA -DDEBUG aurora.cpp ../tap/SQLite3_Server.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o aurora -DGITVERSION=\"$(GIT_VERSION)\" +aurora: aurora.cpp $(TAP_LDIR)/libtap.so + g++ -DTEST_AURORA $< ../tap/SQLite3_Server.cpp $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBSJEMALLOC) $(MYLIBS) $(STATIC_LIBS) -o $@ -test_tokenizer-t: test_tokenizer-t.cpp $(TAP_LIBDIR)/libtap.a - g++ test_tokenizer-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) -o test_tokenizer-t -DGITVERSION=\"$(GIT_VERSION)\" +test_tokenizer-t: test_tokenizer-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ -test_mysql_query_digests_stages-t: test_mysql_query_digests_stages-t.cpp $(TAP_LIBDIR)/libtap.a - g++ test_mysql_query_digests_stages-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) -o test_mysql_query_digests_stages-t -DGITVERSION=\"$(GIT_VERSION)\" +test_mysql_query_digests_stages-t: test_mysql_query_digests_stages-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ -sqlite3-t: sqlite3-t.cpp $(TAP_LIBDIR)/libtap.a - g++ sqlite3-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) $(LIBCOREDUMPERAR) -o sqlite3-t -DGITVERSION=\"$(GIT_VERSION)\" +sqlite3-t: sqlite3-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ -test_gtid_forwarding-t: test_gtid_forwarding-t.cpp $(TAP_LIBDIR)/libtap.a - g++ test_gtid_forwarding-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) -o test_gtid_forwarding-t -DGITVERSION=\"$(GIT_VERSION)\" +test_gtid_forwarding-t: test_gtid_forwarding-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ -test_admin_prometheus_metrics_dump-t: test_admin_prometheus_metrics_dump-t.cpp $(TAP_LIBDIR)/libtap.a - g++ test_admin_prometheus_metrics_dump-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) -o test_admin_prometheus_metrics_dump-t -DGITVERSION=\"$(GIT_VERSION)\" +test_admin_prometheus_metrics_dump-t: test_admin_prometheus_metrics_dump-t.cpp $(TAP_LDIR)/libtap.so + g++ $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -o $@ -create_connection_annotation: test_connection_annotation-t.cpp - g++ -DTEST_AURORA -DDEBUG test_connection_annotation-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(OBJ) $(MYLIBS) $(STATIC_LIBS) -o test_connection_annotation-t -DGITVERSION=\"$(GIT_VERSION)\" +create_connection_annotation: test_connection_annotation-t.cpp $(TAP_LDIR)/libtap.so + g++ -DTEST_AURORA $< $(IDIRS) $(LDIRS) $(OPT) $(OBJ) $(MYLIBS) $(STATIC_LIBS) -o $@ -setparser_test: setparser_test.cpp $(TAP_LIBDIR)/libtap.a $(RE2_PATH)/util/test.cc $(LDIR)/set_parser.cpp $(LIBPROXYSQLAR) $(LIBCOREDUMPERAR) - g++ -DDEBUG setparser_test.cpp $(RE2_PATH)/util/test.cc $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o setparser_test -DGITVERSION=\"$(GIT_VERSION)\" +setparser_test: setparser_test.cpp $(TAP_LDIR)/libtap.so $(RE2_PATH)/util/test.cc $(PROXYSQL_LDIR)/set_parser.cpp $(LIBPROXYSQLAR) $(LIBCOREDUMPERAR) + g++ $< $(RE2_PATH)/util/test.cc $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ setparser_test2-t: setparser_test2 rm setparser_test2-t || true - ln -s setparser_test2 setparser_test2-t + ln -fs setparser_test2 setparser_test2-t -setparser_test2: setparser_test2.cpp $(TAP_LIBDIR)/libtap.a $(LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) - g++ -DDEBUG setparser_test2.cpp $(LDIR)/set_parser.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o setparser_test2 -DGITVERSION=\"$(GIT_VERSION)\" +setparser_test2: setparser_test2.cpp $(TAP_LDIR)/libtap.so $(PROXYSQL_LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) + g++ $< $(PROXYSQL_LDIR)/set_parser.cpp $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ setparser_test3-t: setparser_test3 rm setparser_test3-t || true - ln -s setparser_test3 setparser_test3-t + ln -fs setparser_test3 setparser_test3-t + +setparser_test3: setparser_test3.cpp $(TAP_LDIR)/libtap.so $(PROXYSQL_LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) + g++ -DPARSERDEBUG $< $(PROXYSQL_LDIR)/set_parser.cpp $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(LIBCOREDUMPERAR) -o $@ + -setparser_test3: setparser_test3.cpp $(TAP_LIBDIR)/libtap.a $(LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR) - g++ -DDEBUG -DPARSERDEBUG setparser_test3.cpp $(LDIR)/set_parser.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o setparser_test3 -DGITVERSION=\"$(GIT_VERSION)\" +CUSTOMARGS := -I$(TAP_IDIR) -I$(CURL_IDIR) -I$(SQLITE3_IDIR) -I$(PROXYSQL_IDIR) -I$(JSON_IDIR) -I$(SSL_IDIR) +CUSTOMARGS += -L$(TAP_LDIR) -L$(CURL_LDIR) -L$(SSL_LDIR) +#CUSTOMARGS += -Wl,-Bstatic -lcurl +CUSTOMARGS += -Wl,-Bdynamic -ltap -lcpp_dotenv -lcurl -lssl -lcrypto -lpthread -lz -ldl +CUSTOMARGS += $(OPT) -CUSTOMARGS=-DGITVERSION=\"$(GIT_VERSION)\" -I$(SQLITE3_DIR) -I$(IDIR) -I$(CURL_IDIR) -I$(JSON_IDIR) -I../tap -L$(TAP_LIBDIR) -L$(CURL_LDIR) -Wl,-Bstatic -lcurl -Wl,-Bdynamic -ltap -lcpp_dotenv -lpthread -std=c++11 -lz -ldl +reg_test_3504-change_user_libmariadb_helper: reg_test_3504-change_user_helper.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DDISABLE_WARNING_COUNT_LOGGING $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ -reg_test_3504-change_user_libmariadb_helper: reg_test_3504-change_user_helper.cpp $(TAP_LIBDIR)/libtap.so - $(CXX) -DDISABLE_WARNING_COUNT_LOGGING -DDEBUG reg_test_3504-change_user_helper.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -std=c++11 $(STATIC_LIBS) -o reg_test_3504-change_user_libmariadb_helper -DGITVERSION=\"$(GIT_VERSION)\" +reg_test_3504-change_user_libmysql_helper: reg_test_3504-change_user_helper.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING $< -I$(TEST_MYSQL_IDIR) -I$(TEST_MYSQL_EDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ -reg_test_3504-change_user_libmysql_helper: reg_test_3504-change_user_helper.cpp - $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING reg_test_3504-change_user_helper.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o reg_test_3504-change_user_libmysql_helper +test_clickhouse_server_libmysql-t: test_clickhouse_server-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING $< -I$(TEST_MYSQL_IDIR) -I$(TEST_MYSQL_EDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ -test_clickhouse_server_libmysql-t: test_clickhouse_server-t.cpp - $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING -DDEBUG test_clickhouse_server-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o test_clickhouse_server_libmysql-t +reg_test_stmt_resultset_err_no_rows_libmysql-t: reg_test_stmt_resultset_err_no_rows-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING $< -I$(TEST_MYSQL_IDIR) -I$(TEST_MYSQL_EDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ -reg_test_stmt_resultset_err_no_rows_libmysql-t: reg_test_stmt_resultset_err_no_rows-t.cpp - $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING reg_test_stmt_resultset_err_no_rows-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o reg_test_stmt_resultset_err_no_rows_libmysql-t +reg_test_mariadb_stmt_store_result_libmysql-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING $< -I$(TEST_MYSQL_IDIR) -I$(TEST_MYSQL_EDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ -reg_test_mariadb_stmt_store_result_libmysql-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING reg_test_mariadb_stmt_store_result-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o reg_test_mariadb_stmt_store_result_libmysql-t +reg_test_mariadb_stmt_store_result_async-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DASYNC_API $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ -reg_test_mariadb_stmt_store_result_async-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) -DASYNC_API reg_test_mariadb_stmt_store_result-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl -std=c++11 -ltap $(STATIC_LIBS) -o reg_test_mariadb_stmt_store_result_async-t +prepare_statement_err3024_libmysql-t: prepare_statement_err3024-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING $< -I$(TEST_MYSQL_IDIR) -I$(TEST_MYSQL_EDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ -prepare_statement_err3024_libmysql-t: prepare_statement_err3024-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) -DLIBMYSQL_HELPER -DDISABLE_WARNING_COUNT_LOGGING prepare_statement_err3024-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o prepare_statement_err3024_libmysql-t +prepare_statement_err3024_async-t: prepare_statement_err3024-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) -DASYNC_API $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ -prepare_statement_err3024_async-t: prepare_statement_err3024-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) -DASYNC_API prepare_statement_err3024-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl -std=c++11 -ltap $(STATIC_LIBS) -o prepare_statement_err3024_async-t -DGITVERSION=\"$(GIT_VERSION)\" +test_wexecvp_syscall_failures-t: test_wexecvp_syscall_failures-t.cpp $(TAP_LDIR)/libtap.so + $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) -Wl,--wrap=pipe,--wrap=fcntl,--wrap=read,--wrap=poll $(STATIC_LIBS) -o $@ -test_wexecvp_syscall_failures-t: test_wexecvp_syscall_failures-t.cpp $(TAP_LIBDIR)/libtap.a - $(CXX) test_wexecvp_syscall_failures-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -std=c++11 -Wl,--wrap=pipe,--wrap=fcntl,--wrap=read,--wrap=poll -lpthread -ldl -ltap $(STATIC_LIBS) -o $@ + +### clean targets + +.SILENT: clean +.PHONY: clean +clean: + rm -f *-t || true + rm -f galera_1_timeout_count galera_2_timeout_no_count aurora || true + rm -f generate_set_session_csv set_testing-240.csv || true + rm -f setparser_test setparser_test2 setparser_test3 || true + rm -f reg_test_3504-change_user_libmariadb_helper reg_test_3504-change_user_libmysql_helper || true + rm -f *.gcda *.gcno || true diff --git a/test/tap/tests/admin-listen_on_unix-t.cpp b/test/tap/tests/admin-listen_on_unix-t.cpp index b5917a5d7c..94c6d0f2dd 100644 --- a/test/tap/tests/admin-listen_on_unix-t.cpp +++ b/test/tap/tests/admin-listen_on_unix-t.cpp @@ -4,8 +4,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "proxysql_utils.h" #include "tap.h" diff --git a/test/tap/tests/admin_show_create_table-t.cpp b/test/tap/tests/admin_show_create_table-t.cpp index 7647e59891..5a995b1a6b 100644 --- a/test/tap/tests/admin_show_create_table-t.cpp +++ b/test/tap/tests/admin_show_create_table-t.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/admin_show_fields_from-t.cpp b/test/tap/tests/admin_show_fields_from-t.cpp index 6ace382f26..8252bafd46 100644 --- a/test/tap/tests/admin_show_fields_from-t.cpp +++ b/test/tap/tests/admin_show_fields_from-t.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/admin_show_table_status-t.cpp b/test/tap/tests/admin_show_table_status-t.cpp index 42c02b7d07..1e48e78471 100644 --- a/test/tap/tests/admin_show_table_status-t.cpp +++ b/test/tap/tests/admin_show_table_status-t.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/admin_various_commands-t.cpp b/test/tap/tests/admin_various_commands-t.cpp index db683ba859..cbc2ea3c9b 100644 --- a/test/tap/tests/admin_various_commands-t.cpp +++ b/test/tap/tests/admin_various_commands-t.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/admin_various_commands2-t.cpp b/test/tap/tests/admin_various_commands2-t.cpp index d38c2cc409..94081b1e67 100644 --- a/test/tap/tests/admin_various_commands2-t.cpp +++ b/test/tap/tests/admin_various_commands2-t.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/admin_various_commands3-t.cpp b/test/tap/tests/admin_various_commands3-t.cpp index 4a80f16b08..db86720d81 100644 --- a/test/tap/tests/admin_various_commands3-t.cpp +++ b/test/tap/tests/admin_various_commands3-t.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/charset_unsigned_int-t.cpp b/test/tap/tests/charset_unsigned_int-t.cpp index 62fd4cdac6..fafc557d48 100644 --- a/test/tap/tests/charset_unsigned_int-t.cpp +++ b/test/tap/tests/charset_unsigned_int-t.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/firewall_commands1-t.cpp b/test/tap/tests/firewall_commands1-t.cpp index f3bfd1a631..6aa56cf61d 100644 --- a/test/tap/tests/firewall_commands1-t.cpp +++ b/test/tap/tests/firewall_commands1-t.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/generate_set_session_csv.cpp b/test/tap/tests/generate_set_session_csv.cpp index 900a85e525..95eed9e68f 100644 --- a/test/tap/tests/generate_set_session_csv.cpp +++ b/test/tap/tests/generate_set_session_csv.cpp @@ -5,6 +5,7 @@ #include #include #include +#include std::vector bool_values = { "0", "1", @@ -64,7 +65,7 @@ class variable { }; -std::unordered_map vars; +std::unordered_map> vars; void add_value_j(std::string& j, const std::string& s, variable *v) { @@ -125,44 +126,44 @@ void add_values_and_quotes(const std::string& name, const std::vector("sql_log_bin", false, false, true); vars["sql_log_bin"]->add(bool_values); - vars["sql_safe_updates"] = new variable("sql_safe_updates", true, false, true); + vars["sql_safe_updates"] = std::make_unique("sql_safe_updates", true, false, true); vars["sql_safe_updates"]->add(bool_values); - vars["sql_big_selects"] = new variable("sql_big_selects", true, false, true); + vars["sql_big_selects"] = std::make_unique("sql_big_selects", true, false, true); vars["sql_big_selects"]->add(bool_values); -// vars["wsrep_sync_wait"] = new variable("wsrep_sync_wait", true, false); +// vars["wsrep_sync_wait"] = std::make_unique("wsrep_sync_wait", true, false); // vars["wsrep_sync_wait"]->add(bool_values); - vars["sql_auto_is_null"] = new variable("sql_auto_is_null", true, false, true); + vars["sql_auto_is_null"] = std::make_unique("sql_auto_is_null", true, false, true); vars["sql_auto_is_null"]->add(bool_values); - vars["foreign_key_checks"] = new variable("foreign_key_checks", true, false, true); + vars["foreign_key_checks"] = std::make_unique("foreign_key_checks", true, false, true); vars["foreign_key_checks"]->add(bool_values); - vars["unique_checks"] = new variable("unique_checks", true, false, true); + vars["unique_checks"] = std::make_unique("unique_checks", true, false, true); vars["unique_checks"]->add(bool_values); - vars["innodb_lock_wait_timeout"] = new variable("innodb_lock_wait_timeout", true, true, false); + vars["innodb_lock_wait_timeout"] = std::make_unique("innodb_lock_wait_timeout", true, true, false); vars["innodb_lock_wait_timeout"]->add(int_values_small, 34); vars["innodb_lock_wait_timeout"]->add(int_values, 117); - vars["innodb_strict_mode"] = new variable("innodb_strict_mode", true, false, true); + vars["innodb_strict_mode"] = std::make_unique("innodb_strict_mode", true, false, true); vars["innodb_strict_mode"]->add(bool_values); - vars["innodb_table_locks"] = new variable("innodb_table_locks", true, false, true); + vars["innodb_table_locks"] = std::make_unique("innodb_table_locks", true, false, true); vars["innodb_table_locks"]->add(bool_values); - vars["aurora_read_replica_read_committed"] = new variable("aurora_read_replica_read_committed", true, false, true); + vars["aurora_read_replica_read_committed"] = std::make_unique("aurora_read_replica_read_committed", true, false, true); vars["aurora_read_replica_read_committed"]->add(bool_values); - //vars[""] = new variable(""); + //vars[""] = std::make_unique(""); //vars[""]->add(bool_values); - vars["auto_increment_increment"] = new variable("auto_increment_increment", true, true, false); + vars["auto_increment_increment"] = std::make_unique("auto_increment_increment", true, true, false); vars["auto_increment_increment"]->add(int_values_small, 10); - vars["auto_increment_offset"] = new variable("auto_increment_offset", true, true, false); + vars["auto_increment_offset"] = std::make_unique("auto_increment_offset", true, true, false); vars["auto_increment_offset"]->add(int_values_small, 20); - vars["sql_select_limit"] = new variable("sql_select_limit", true, true, false); + vars["sql_select_limit"] = std::make_unique("sql_select_limit", true, true, false); vars["sql_select_limit"]->add(int_values_small, 80); vars["sql_select_limit"]->add(int_values, 80); - vars["group_concat_max_len"] = new variable("group_concat_max_len", true, true, false); + vars["group_concat_max_len"] = std::make_unique("group_concat_max_len", true, true, false); vars["group_concat_max_len"]->add(int_values_small, 123); vars["group_concat_max_len"]->add(int_values, 123); - vars["join_buffer_size"] = new variable("join_buffer_size", true, true, false); + vars["join_buffer_size"] = std::make_unique("join_buffer_size", true, true, false); vars["join_buffer_size"]->add(int_values, 1028); { // join_buffer_size uses blocks of 128 , so we need to round it @@ -175,21 +176,21 @@ int main() { } } - vars["query_cache_type"] = new variable("query_cache_type", true, true, false); + vars["query_cache_type"] = std::make_unique("query_cache_type", true, true, false); vars["query_cache_type"]->add(bool_values); vars["query_cache_type"]->add("2"); add_values_and_quotes("query_cache_type", {"DeMaNd"}); - vars["lock_wait_timeout"] = new variable("lock_wait_timeout", true, true, false); + vars["lock_wait_timeout"] = std::make_unique("lock_wait_timeout", true, true, false); vars["lock_wait_timeout"]->add(int_values_small, 321); - vars["max_join_size"] = new variable("max_join_size", true, true, false); + vars["max_join_size"] = std::make_unique("max_join_size", true, true, false); vars["max_join_size"]->add(int_values, 1000); vars["max_join_size"]->add("18446744073709551615"); vars["max_join_size"]->add("DEFAULT"); - vars["tmp_table_size"] = new variable("tmp_table_size", true, true, false); + vars["tmp_table_size"] = std::make_unique("tmp_table_size", true, true, false); vars["tmp_table_size"]->add(int_values, 10050); vars["tmp_table_size"]->add("18446744000000051615"); - vars["max_heap_table_size"] = new variable("max_heap_table_size", true, true, false); + vars["max_heap_table_size"] = std::make_unique("max_heap_table_size", true, true, false); vars["max_heap_table_size"]->add(int_values, 20031); vars["max_heap_table_size"]->add("8446744073709547520"); { @@ -202,67 +203,67 @@ int main() { *it = std::to_string(a); } } - vars["sort_buffer_size"] = new variable("sort_buffer_size", true, true, false); + vars["sort_buffer_size"] = std::make_unique("sort_buffer_size", true, true, false); vars["sort_buffer_size"]->add(int_values, 40123); vars["sort_buffer_size"]->add("18446744073709551615"); - vars["max_statement_time"] = new variable("max_statement_time", true, true, false); + vars["max_statement_time"] = std::make_unique("max_statement_time", true, true, false); vars["max_statement_time"]->add(int_values, 12012); vars["max_statement_time"]->add("0"); - vars["max_execution_time"] = new variable("max_execution_time", true, true, false); + vars["max_execution_time"] = std::make_unique("max_execution_time", true, true, false); vars["max_execution_time"]->add(int_values, 12930); vars["max_execution_time"]->add("0"); - vars["long_query_time"] = new variable("long_query_time", true, true, false); + vars["long_query_time"] = std::make_unique("long_query_time", true, true, false); vars["long_query_time"]->add(int_values, 2951); vars["long_query_time"]->add(int_values_small, 498); vars["long_query_time"]->add("0"); - vars["max_sort_length"] = new variable("max_sort_length", true, true, false); + vars["max_sort_length"] = std::make_unique("max_sort_length", true, true, false); vars["max_sort_length"]->add(int_values, 1123); - vars["optimizer_prune_level"] = new variable("optimizer_prune_level", true, true, false); + vars["optimizer_prune_level"] = std::make_unique("optimizer_prune_level", true, true, false); vars["optimizer_prune_level"]->add({0, 1}, 0); - vars["optimizer_search_depth"] = new variable("optimizer_search_depth", true, true, false); + vars["optimizer_search_depth"] = std::make_unique("optimizer_search_depth", true, true, false); vars["optimizer_search_depth"]->add({0, 1, 12, 30, 62}, 0); - vars["timestamp"] = new variable("timestamp", true, true, false); + vars["timestamp"] = std::make_unique("timestamp", true, true, false); vars["timestamp"]->add("1640011196"); for (unsigned long long i = 0 ; i < 10 ; i++) { unsigned long long ts = 1640011196 + i*3600*24; vars["timestamp"]->add(std::to_string(ts)); } - vars["session_track_gtids"] = new variable("session_track_gtids", true, true, false); + vars["session_track_gtids"] = std::make_unique("session_track_gtids", true, true, false); vars["session_track_gtids"]->add("OWN_GTID"); // vars["session_track_gtids"]->add("OFF"); // vars["session_track_gtids"]->add("ALL_GTID"); - vars["optimizer_switch"] = new variable("optimizer_switch", true, false, false); + vars["optimizer_switch"] = std::make_unique("optimizer_switch", true, false, false); vars["optimizer_switch"]->add(std::vector {"'materialization=off'", "`materialization=on`", "\"materialization=off\""}); vars["optimizer_switch"]->add(std::vector {"'index_merge_union=off'", "`index_merge_union=on`", "\"index_merge_union=off\""}); vars["optimizer_switch"]->add(std::vector {"'semijoin=off'", "`semijoin=on`", "\"semijoin=off\""}); - vars["optimizer_use_condition_selectivity"] = new variable("optimizer_use_condition_selectivity", true, true, false); + vars["optimizer_use_condition_selectivity"] = std::make_unique("optimizer_use_condition_selectivity", true, true, false); vars["optimizer_use_condition_selectivity"]->add({1, 2, 3, 4, 5}, 0); - vars["lc_time_names"] = new variable("lc_time_names", true, false, false); + vars["lc_time_names"] = std::make_unique("lc_time_names", true, false, false); vars["lc_time_names"]->add(std::vector {"en_US", "'en_US'", "`en_US`", "\"en_US\""}); vars["lc_time_names"]->add(std::vector {"en_GB", "'en_GB'", "`en_GB`", "\"en_GB\""}); //vars["lc_time_names"]->add(std::vector {"ja_JP", "'ja_JP'", "`ja_JP`", "\"ja_JP\""}); vars["lc_time_names"]->add(std::vector {"pt_BR", "'pt_BR'", "`pt_BR`", "\"pt_BR\""}); - vars["lc_messages"] = new variable("lc_messages", true, false, false); + vars["lc_messages"] = std::make_unique("lc_messages", true, false, false); vars["lc_messages"]->add(std::vector {"it_IT", "'it_IT'", "`it_IT`", "\"it_IT\""}); vars["lc_messages"]->add(std::vector {"es_ES", "'es_ES'", "`es_ES`", "\"es_ES\""}); vars["lc_messages"]->add(std::vector {"fr_FR", "'fr_FR'", "`fr_FR`", "\"fr_FR\""}); - vars["log_slow_filter"] = new variable("log_slow_filter", true, false, false); + vars["log_slow_filter"] = std::make_unique("log_slow_filter", true, false, false); vars["log_slow_filter"]->add(std::vector {"'not_using_index'", "`not_using_index`", "\"not_using_index\""}); vars["log_slow_filter"]->add(std::vector {"'admin,filesort,filesort_on_disk,full_join'", "`admin,filesort,filesort_on_disk,full_join`", "\"admin,filesort,filesort_on_disk,full_join\""}); - vars["time_zone"] = new variable("time_zone", true, false, false); + vars["time_zone"] = std::make_unique("time_zone", true, false, false); vars["time_zone"]->add(std::vector {"'+01:00'", "`+02:15`", "\"+03:30\""}); vars["time_zone"]->add(std::vector {"'+04:45'", "`+05:00`", "\"+06:10\""}); vars["time_zone"]->add(std::vector {"'-1:10'", "`-03:33`", "\"-04:56\""}); vars["time_zone"]->add(std::vector {"'+02:45'", "`+7:00`", "\"+06:10\""}); vars["time_zone"]->add(std::vector {"'-11:10'", "`-11:33`", "\"-04:56\""}); - vars["sql_mode"] = new variable("sql_mode", true, false, false); + vars["sql_mode"] = std::make_unique("sql_mode", true, false, false); vars["sql_mode"]->add(std::vector {"'traditional'", "TRADITIONAL", "''"}); vars["sql_mode"]->add(std::vector {"'NO_BACKSLASH_ESCAPES'", "NO_BACKSLASH_ESCAPES"}); vars["sql_mode"]->add(std::vector {"'TRADITIONAL,NO_BACKSLASH_ESCAPES'", "\"NO_BACKSLASH_ESCAPES,TRADITIONAL\""}); @@ -274,24 +275,24 @@ int main() { vars["sql_mode"]->add(std::vector {"''", "\"\"", "' '", "\" \"", "' '", "\" \"",}); - vars["default_storage_engine"] = new variable("default_storage_engine", true, false, false); + vars["default_storage_engine"] = std::make_unique("default_storage_engine", true, false, false); add_values_and_quotes("default_storage_engine", {"InnoDB", "MEMORY", "MyISAM", "BLACKHOLE"}); - vars["default_tmp_storage_engine"] = new variable("default_tmp_storage_engine", true, false, false); + vars["default_tmp_storage_engine"] = std::make_unique("default_tmp_storage_engine", true, false, false); vars["default_tmp_storage_engine"]->add(vars["default_storage_engine"]->values); - vars["group_replication_consistency"] = new variable("group_replication_consistency", true, false, false); + vars["group_replication_consistency"] = std::make_unique("group_replication_consistency", true, false, false); add_values_and_quotes("group_replication_consistency", {"EVENTUAL", "BEFORE_ON_PRIMARY_FAILOVER", "BEFORE", "AFTER", "BEFORE_AND_AFTER"}); - vars["wsrep_osu_method"] = new variable("wsrep_osu_method", true, false, false); + vars["wsrep_osu_method"] = std::make_unique("wsrep_osu_method", true, false, false); add_values_and_quotes("wsrep_osu_method", {"TOI","RSU"}); - vars["sql_quote_show_create"] = new variable("sql_quote_show_create", true, false, true); + vars["sql_quote_show_create"] = std::make_unique("sql_quote_show_create", true, false, true); vars["sql_quote_show_create"]->add(bool_values); - vars["sql_require_primary_key"] = new variable("sql_require_primary_key", true, false, true); + vars["sql_require_primary_key"] = std::make_unique("sql_require_primary_key", true, false, true); vars["sql_require_primary_key"]->add(bool_values); - vars["sql_generate_invisible_primary_key"] = new variable("sql_generate_invisible_primary_key", true, false, true); + vars["sql_generate_invisible_primary_key"] = std::make_unique("sql_generate_invisible_primary_key", true, false, true); vars["sql_generate_invisible_primary_key"]->add(bool_values); /* example: @@ -301,8 +302,8 @@ int main() { variable * vararray[vars.size()]; { unsigned int i = 0; - for (std::unordered_map::iterator it = vars.begin() ; it != vars.end() ; it++) { - vararray[i] = it->second; + for (std::unordered_map>::iterator it = vars.begin() ; it != vars.end() ; it++) { + vararray[i] = it->second.get(); i++; } } @@ -360,9 +361,9 @@ int main() { j += "sql_big_selects"; j += "\":\""; if (strcasecmp(s2.c_str(),(char *)"default")==0 || s2 == "18446744073709551615") { - add_value_j(j,"ON",vars["sql_big_selects"]); + add_value_j(j,"ON",vars["sql_big_selects"].get()); } else { - add_value_j(j,"OFF",vars["sql_big_selects"]); + add_value_j(j,"OFF",vars["sql_big_selects"].get()); } } if (ine != ne -1) { diff --git a/test/tap/tests/kill_connection-t.cpp b/test/tap/tests/kill_connection-t.cpp index ade613df06..5f964a959d 100644 --- a/test/tap/tests/kill_connection-t.cpp +++ b/test/tap/tests/kill_connection-t.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/kill_connection2-t.cpp b/test/tap/tests/kill_connection2-t.cpp index 3b89032e98..947c9d9cf5 100644 --- a/test/tap/tests/kill_connection2-t.cpp +++ b/test/tap/tests/kill_connection2-t.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/kill_connection3-t.cpp b/test/tap/tests/kill_connection3-t.cpp index 3fd31bf98a..ef28ac6cb6 100644 --- a/test/tap/tests/kill_connection3-t.cpp +++ b/test/tap/tests/kill_connection3-t.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/max_connections_ff-t.cpp b/test/tap/tests/max_connections_ff-t.cpp index 22f1285abb..f85a66f330 100644 --- a/test/tap/tests/max_connections_ff-t.cpp +++ b/test/tap/tests/max_connections_ff-t.cpp @@ -24,8 +24,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "json.hpp" diff --git a/test/tap/tests/multiple_prepared_statements-t.cpp b/test/tap/tests/multiple_prepared_statements-t.cpp index 8a4560437c..ea3bed6035 100644 --- a/test/tap/tests/multiple_prepared_statements-t.cpp +++ b/test/tap/tests/multiple_prepared_statements-t.cpp @@ -21,8 +21,8 @@ It stresses how proxysql managers prepared statements, specifically: #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "command_line.h" #include "proxysql_utils.h" diff --git a/test/tap/tests/mysql-fast_forward-t.cpp b/test/tap/tests/mysql-fast_forward-t.cpp index 7b43a29276..6fa29c4eb0 100644 --- a/test/tap/tests/mysql-fast_forward-t.cpp +++ b/test/tap/tests/mysql-fast_forward-t.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/mysql-init_connect-1-t.cpp b/test/tap/tests/mysql-init_connect-1-t.cpp index b0643b14a4..65dc2202b4 100644 --- a/test/tap/tests/mysql-init_connect-1-t.cpp +++ b/test/tap/tests/mysql-init_connect-1-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/mysql-init_connect-2-t.cpp b/test/tap/tests/mysql-init_connect-2-t.cpp index cc9aeea1ed..705869c70c 100644 --- a/test/tap/tests/mysql-init_connect-2-t.cpp +++ b/test/tap/tests/mysql-init_connect-2-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/mysql-last_insert_id-t.cpp b/test/tap/tests/mysql-last_insert_id-t.cpp index 4d8acd3acc..1e8e9d18b1 100644 --- a/test/tap/tests/mysql-last_insert_id-t.cpp +++ b/test/tap/tests/mysql-last_insert_id-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/mysql-mirror1-t.cpp b/test/tap/tests/mysql-mirror1-t.cpp index 42e00c8726..54e63488f7 100644 --- a/test/tap/tests/mysql-mirror1-t.cpp +++ b/test/tap/tests/mysql-mirror1-t.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/mysql-set_transaction-t.cpp b/test/tap/tests/mysql-set_transaction-t.cpp index 5472e97dd2..1948bafb40 100644 --- a/test/tap/tests/mysql-set_transaction-t.cpp +++ b/test/tap/tests/mysql-set_transaction-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/mysql-sql_log_bin-error-t.cpp b/test/tap/tests/mysql-sql_log_bin-error-t.cpp index 9e1e4ad792..8311372a6b 100644 --- a/test/tap/tests/mysql-sql_log_bin-error-t.cpp +++ b/test/tap/tests/mysql-sql_log_bin-error-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/mysql-test_ssl_CA-t.cpp b/test/tap/tests/mysql-test_ssl_CA-t.cpp index 7ded1443e9..b09d659e03 100644 --- a/test/tap/tests/mysql-test_ssl_CA-t.cpp +++ b/test/tap/tests/mysql-test_ssl_CA-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include #include "tap.h" diff --git a/test/tap/tests/mysql_hostgroup_attributes-servers_defaults-t.cpp b/test/tap/tests/mysql_hostgroup_attributes-servers_defaults-t.cpp index 06a1907214..51d5300f96 100644 --- a/test/tap/tests/mysql_hostgroup_attributes-servers_defaults-t.cpp +++ b/test/tap/tests/mysql_hostgroup_attributes-servers_defaults-t.cpp @@ -15,8 +15,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "json.hpp" diff --git a/test/tap/tests/mysql_stmt_send_long_data-t.cpp b/test/tap/tests/mysql_stmt_send_long_data-t.cpp index d14a7e102e..92722c5bf8 100644 --- a/test/tap/tests/mysql_stmt_send_long_data-t.cpp +++ b/test/tap/tests/mysql_stmt_send_long_data-t.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/mysql_stmt_send_long_data_large-t.cpp b/test/tap/tests/mysql_stmt_send_long_data_large-t.cpp index 15486cfa64..e0e504e5bf 100644 --- a/test/tap/tests/mysql_stmt_send_long_data_large-t.cpp +++ b/test/tap/tests/mysql_stmt_send_long_data_large-t.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/prepare_statement_err3024-t.cpp b/test/tap/tests/prepare_statement_err3024-t.cpp index 51eea03e22..3938d4cf1e 100644 --- a/test/tap/tests/prepare_statement_err3024-t.cpp +++ b/test/tap/tests/prepare_statement_err3024-t.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_1493-mixed_compression-t.cpp b/test/tap/tests/reg_test_1493-mixed_compression-t.cpp index 75edafffba..473d3288cf 100644 --- a/test/tap/tests/reg_test_1493-mixed_compression-t.cpp +++ b/test/tap/tests/reg_test_1493-mixed_compression-t.cpp @@ -8,8 +8,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_1574-mariadb_read_stmt_execute_response-t.cpp b/test/tap/tests/reg_test_1574-mariadb_read_stmt_execute_response-t.cpp index a803d0d2d6..0a78523c7c 100644 --- a/test/tap/tests/reg_test_1574-mariadb_read_stmt_execute_response-t.cpp +++ b/test/tap/tests/reg_test_1574-mariadb_read_stmt_execute_response-t.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_1574-stmt_metadata-t.cpp b/test/tap/tests/reg_test_1574-stmt_metadata-t.cpp index 742ee3aed7..fb61d6a474 100644 --- a/test/tap/tests/reg_test_1574-stmt_metadata-t.cpp +++ b/test/tap/tests/reg_test_1574-stmt_metadata-t.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_2793-compression-t.cpp b/test/tap/tests/reg_test_2793-compression-t.cpp index 5f493f0b7d..7256094746 100644 --- a/test/tap/tests/reg_test_2793-compression-t.cpp +++ b/test/tap/tests/reg_test_2793-compression-t.cpp @@ -7,8 +7,8 @@ #include #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3184-set_wait_timeout-t.cpp b/test/tap/tests/reg_test_3184-set_wait_timeout-t.cpp index ff5b5cdcc5..d3eddc8d40 100644 --- a/test/tap/tests/reg_test_3184-set_wait_timeout-t.cpp +++ b/test/tap/tests/reg_test_3184-set_wait_timeout-t.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3223-restapi_return_codes-t.cpp b/test/tap/tests/reg_test_3223-restapi_return_codes-t.cpp index 440e5c64f9..6eac9c9d73 100644 --- a/test/tap/tests/reg_test_3223-restapi_return_codes-t.cpp +++ b/test/tap/tests/reg_test_3223-restapi_return_codes-t.cpp @@ -18,7 +18,7 @@ #include "curl/curl.h" #include "json.hpp" #include "mysql.h" -#include "mysql/mysqld_error.h" +#include "mysqld_error.h" #include "command_line.h" #include "proxysql_utils.h" diff --git a/test/tap/tests/reg_test_3247-mycli_support-t.cpp b/test/tap/tests/reg_test_3247-mycli_support-t.cpp index 0cb9505c73..4116bd621d 100644 --- a/test/tap/tests/reg_test_3247-mycli_support-t.cpp +++ b/test/tap/tests/reg_test_3247-mycli_support-t.cpp @@ -8,8 +8,8 @@ #include #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3273_ssl_con-t.cpp b/test/tap/tests/reg_test_3273_ssl_con-t.cpp index 32d187e15c..1b0c8b55cb 100644 --- a/test/tap/tests/reg_test_3273_ssl_con-t.cpp +++ b/test/tap/tests/reg_test_3273_ssl_con-t.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include "mysql.h" #include #include "tap.h" diff --git a/test/tap/tests/reg_test_3317-lock_hostgroup_special_queries-t.cpp b/test/tap/tests/reg_test_3317-lock_hostgroup_special_queries-t.cpp index 46264349c1..5eadc264fb 100644 --- a/test/tap/tests/reg_test_3317-lock_hostgroup_special_queries-t.cpp +++ b/test/tap/tests/reg_test_3317-lock_hostgroup_special_queries-t.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3327-process_query_set_status_flags-t.cpp b/test/tap/tests/reg_test_3327-process_query_set_status_flags-t.cpp index 8f6c0506ed..98a0983dbc 100644 --- a/test/tap/tests/reg_test_3327-process_query_set_status_flags-t.cpp +++ b/test/tap/tests/reg_test_3327-process_query_set_status_flags-t.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3427-stmt_first_comment1-t.cpp b/test/tap/tests/reg_test_3427-stmt_first_comment1-t.cpp index c4b6f9e077..a4eec522b3 100644 --- a/test/tap/tests/reg_test_3427-stmt_first_comment1-t.cpp +++ b/test/tap/tests/reg_test_3427-stmt_first_comment1-t.cpp @@ -29,8 +29,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "proxysql_utils.h" #include "tap.h" diff --git a/test/tap/tests/reg_test_3434-text_stmt_mix-t.cpp b/test/tap/tests/reg_test_3434-text_stmt_mix-t.cpp index b232ab5c27..6fc4bdac3d 100644 --- a/test/tap/tests/reg_test_3434-text_stmt_mix-t.cpp +++ b/test/tap/tests/reg_test_3434-text_stmt_mix-t.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include "mysql.h" #include "proxysql_utils.h" #include "tap.h" diff --git a/test/tap/tests/reg_test_3493-USE_with_comment-t.cpp b/test/tap/tests/reg_test_3493-USE_with_comment-t.cpp index 16600783e2..66f509296c 100644 --- a/test/tap/tests/reg_test_3493-USE_with_comment-t.cpp +++ b/test/tap/tests/reg_test_3493-USE_with_comment-t.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3504-change_user-t.cpp b/test/tap/tests/reg_test_3504-change_user-t.cpp index fa9f09b902..3e839ee804 100644 --- a/test/tap/tests/reg_test_3504-change_user-t.cpp +++ b/test/tap/tests/reg_test_3504-change_user-t.cpp @@ -21,8 +21,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "command_line.h" #include "proxysql_utils.h" diff --git a/test/tap/tests/reg_test_3504-change_user_helper.cpp b/test/tap/tests/reg_test_3504-change_user_helper.cpp index 1efb7a0c3f..ee6ba80dbb 100644 --- a/test/tap/tests/reg_test_3504-change_user_helper.cpp +++ b/test/tap/tests/reg_test_3504-change_user_helper.cpp @@ -31,8 +31,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "proxysql_utils.h" #include "json.hpp" diff --git a/test/tap/tests/reg_test_3546-stmt_empty_params-t.cpp b/test/tap/tests/reg_test_3546-stmt_empty_params-t.cpp index 82c0e3323f..86a148cd4f 100644 --- a/test/tap/tests/reg_test_3546-stmt_empty_params-t.cpp +++ b/test/tap/tests/reg_test_3546-stmt_empty_params-t.cpp @@ -20,8 +20,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "proxysql_utils.h" #include "tap.h" diff --git a/test/tap/tests/reg_test_3549-autocommit_tracking-t.cpp b/test/tap/tests/reg_test_3549-autocommit_tracking-t.cpp index 65656a4b7f..42980c22b5 100644 --- a/test/tap/tests/reg_test_3549-autocommit_tracking-t.cpp +++ b/test/tap/tests/reg_test_3549-autocommit_tracking-t.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include "mysql.h" #include "proxysql_utils.h" #include "tap.h" diff --git a/test/tap/tests/reg_test_3585-stmt_metadata-t.cpp b/test/tap/tests/reg_test_3585-stmt_metadata-t.cpp index c6a19cb872..f40e959a39 100644 --- a/test/tap/tests/reg_test_3585-stmt_metadata-t.cpp +++ b/test/tap/tests/reg_test_3585-stmt_metadata-t.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3591-restapi_num_fds-t.cpp b/test/tap/tests/reg_test_3591-restapi_num_fds-t.cpp index f859517183..13bb29142e 100644 --- a/test/tap/tests/reg_test_3591-restapi_num_fds-t.cpp +++ b/test/tap/tests/reg_test_3591-restapi_num_fds-t.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3603-stmt_metadata-t.cpp b/test/tap/tests/reg_test_3603-stmt_metadata-t.cpp index 1f4eb5b693..8afc9a8614 100644 --- a/test/tap/tests/reg_test_3603-stmt_metadata-t.cpp +++ b/test/tap/tests/reg_test_3603-stmt_metadata-t.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3606-mysql_warnings-t.cpp b/test/tap/tests/reg_test_3606-mysql_warnings-t.cpp index 412bc68b61..b5a1fc3166 100644 --- a/test/tap/tests/reg_test_3606-mysql_warnings-t.cpp +++ b/test/tap/tests/reg_test_3606-mysql_warnings-t.cpp @@ -18,15 +18,14 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" -#include +#include "proxysql_utils.h" #include "tap.h" #include "command_line.h" #include "utils.h" -#include "utils.h" using std::vector; using std::tuple; diff --git a/test/tap/tests/reg_test_3625-sqlite3_session_client_error_limit-t.cpp b/test/tap/tests/reg_test_3625-sqlite3_session_client_error_limit-t.cpp index 9d4624aeb5..05a2e08e47 100644 --- a/test/tap/tests/reg_test_3625-sqlite3_session_client_error_limit-t.cpp +++ b/test/tap/tests/reg_test_3625-sqlite3_session_client_error_limit-t.cpp @@ -15,8 +15,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3690-admin_large_pkts-t.cpp b/test/tap/tests/reg_test_3690-admin_large_pkts-t.cpp index 486c46bd54..83687245fc 100644 --- a/test/tap/tests/reg_test_3690-admin_large_pkts-t.cpp +++ b/test/tap/tests/reg_test_3690-admin_large_pkts-t.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include "mysql.h" #include "json.hpp" #include "tap.h" diff --git a/test/tap/tests/reg_test_3765_ssl_pollout-t.cpp b/test/tap/tests/reg_test_3765_ssl_pollout-t.cpp index 7570c4642e..e559c758f8 100644 --- a/test/tap/tests/reg_test_3765_ssl_pollout-t.cpp +++ b/test/tap/tests/reg_test_3765_ssl_pollout-t.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include "mysql.h" #include #include "tap.h" diff --git a/test/tap/tests/reg_test_3838-restapi_eintr-t.cpp b/test/tap/tests/reg_test_3838-restapi_eintr-t.cpp index cd081cd0b1..b890a43d8c 100644 --- a/test/tap/tests/reg_test_3838-restapi_eintr-t.cpp +++ b/test/tap/tests/reg_test_3838-restapi_eintr-t.cpp @@ -22,8 +22,8 @@ #include "curl/curl.h" -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "json.hpp" #include "tap.h" diff --git a/test/tap/tests/reg_test_3847_admin_lock-t.cpp b/test/tap/tests/reg_test_3847_admin_lock-t.cpp index 8fad233ef9..e110a7874b 100644 --- a/test/tap/tests/reg_test_3847_admin_lock-t.cpp +++ b/test/tap/tests/reg_test_3847_admin_lock-t.cpp @@ -10,8 +10,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "proxysql_utils.h" #include "tap.h" diff --git a/test/tap/tests/reg_test_3992_fast_forward_malformed_packet-mysqlsh-t.cpp b/test/tap/tests/reg_test_3992_fast_forward_malformed_packet-mysqlsh-t.cpp index 51fd91de47..b19e38edc2 100644 --- a/test/tap/tests/reg_test_3992_fast_forward_malformed_packet-mysqlsh-t.cpp +++ b/test/tap/tests/reg_test_3992_fast_forward_malformed_packet-mysqlsh-t.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_3992_fast_forward_malformed_packet-t.cpp b/test/tap/tests/reg_test_3992_fast_forward_malformed_packet-t.cpp index 7335ed7b67..128fdec549 100644 --- a/test/tap/tests/reg_test_3992_fast_forward_malformed_packet-t.cpp +++ b/test/tap/tests/reg_test_3992_fast_forward_malformed_packet-t.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_4001-restapi_scripts_num_fds-t.cpp b/test/tap/tests/reg_test_4001-restapi_scripts_num_fds-t.cpp index e8c162c88e..b035d8c40d 100644 --- a/test/tap/tests/reg_test_4001-restapi_scripts_num_fds-t.cpp +++ b/test/tap/tests/reg_test_4001-restapi_scripts_num_fds-t.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include "mysql.h" #include "command_line.h" #include "proxysql_utils.h" diff --git a/test/tap/tests/reg_test_4072-show-warnings-t.cpp b/test/tap/tests/reg_test_4072-show-warnings-t.cpp index d0bcf6dbb4..3e22e70e19 100644 --- a/test/tap/tests/reg_test_4072-show-warnings-t.cpp +++ b/test/tap/tests/reg_test_4072-show-warnings-t.cpp @@ -7,8 +7,8 @@ #include #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" #include "utils.h" diff --git a/test/tap/tests/reg_test_4264-commit_rollback-t.cpp b/test/tap/tests/reg_test_4264-commit_rollback-t.cpp index 15369d8895..1c5c6585ab 100644 --- a/test/tap/tests/reg_test_4264-commit_rollback-t.cpp +++ b/test/tap/tests/reg_test_4264-commit_rollback-t.cpp @@ -41,8 +41,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "utils.h" diff --git a/test/tap/tests/reg_test_4300-dollar_quote_check-t.cpp b/test/tap/tests/reg_test_4300-dollar_quote_check-t.cpp index 72ecc5b70c..9e6828e621 100644 --- a/test/tap/tests/reg_test_4300-dollar_quote_check-t.cpp +++ b/test/tap/tests/reg_test_4300-dollar_quote_check-t.cpp @@ -15,8 +15,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "utils.h" diff --git a/test/tap/tests/reg_test_fast_forward_split_packet-t.cpp b/test/tap/tests/reg_test_fast_forward_split_packet-t.cpp index a302543202..626545055b 100644 --- a/test/tap/tests/reg_test_fast_forward_split_packet-t.cpp +++ b/test/tap/tests/reg_test_fast_forward_split_packet-t.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_mariadb_stmt_store_result-t.cpp b/test/tap/tests/reg_test_mariadb_stmt_store_result-t.cpp index aa21489f1f..292f98f137 100644 --- a/test/tap/tests/reg_test_mariadb_stmt_store_result-t.cpp +++ b/test/tap/tests/reg_test_mariadb_stmt_store_result-t.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/reg_test_sql_calc_found_rows-t.cpp b/test/tap/tests/reg_test_sql_calc_found_rows-t.cpp index 10aef61c33..674a1f9b74 100644 --- a/test/tap/tests/reg_test_sql_calc_found_rows-t.cpp +++ b/test/tap/tests/reg_test_sql_calc_found_rows-t.cpp @@ -12,8 +12,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "json.hpp" diff --git a/test/tap/tests/reg_test_stmt_resultset_err_no_rows-t.cpp b/test/tap/tests/reg_test_stmt_resultset_err_no_rows-t.cpp index 514b5d627e..f02fc7fd95 100644 --- a/test/tap/tests/reg_test_stmt_resultset_err_no_rows-t.cpp +++ b/test/tap/tests/reg_test_stmt_resultset_err_no_rows-t.cpp @@ -16,8 +16,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "proxysql_utils.h" #include "tap.h" @@ -140,9 +140,9 @@ int main(int argc, char** argv) { bind.buffer_type = MYSQL_TYPE_STRING; bind.buffer = (char *)&data_c2; bind.buffer_length = STRING_SIZE; - bind.is_null = &is_null[0]; + bind.is_null = (my_bool *)&is_null[0]; bind.length = &length[0]; - bind.error = &error[0]; + bind.error = (my_bool *)&error[0]; if (mysql_stmt_bind_result(stmt, &bind)) { diag("mysql_stmt_bind_result at line %d failed: %s", __LINE__, mysql_stmt_error(stmt)); diff --git a/test/tap/tests/reg_test_stmt_resultset_err_no_rows_php-t.cpp b/test/tap/tests/reg_test_stmt_resultset_err_no_rows_php-t.cpp index 03a1f0143e..bd7a0cf19d 100644 --- a/test/tap/tests/reg_test_stmt_resultset_err_no_rows_php-t.cpp +++ b/test/tap/tests/reg_test_stmt_resultset_err_no_rows_php-t.cpp @@ -8,8 +8,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "proxysql_utils.h" #include "tap.h" diff --git a/test/tap/tests/repro_3404-mysql_close_fd_leak.cpp b/test/tap/tests/repro_3404-mysql_close_fd_leak.cpp index 83b1e28770..5e0ec91332 100644 --- a/test/tap/tests/repro_3404-mysql_close_fd_leak.cpp +++ b/test/tap/tests/repro_3404-mysql_close_fd_leak.cpp @@ -56,7 +56,7 @@ #include #include -#include +#include "mysql.h" #include #include "tap.h" diff --git a/test/tap/tests/repro_test_leak_3350.cpp b/test/tap/tests/repro_test_leak_3350.cpp index 6d51b66367..bc0644f6e2 100644 --- a/test/tap/tests/repro_test_leak_3350.cpp +++ b/test/tap/tests/repro_test_leak_3350.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/repro_test_leak_3525.cpp b/test/tap/tests/repro_test_leak_3525.cpp index 5ac66cbe4a..c4b50932cd 100644 --- a/test/tap/tests/repro_test_leak_3525.cpp +++ b/test/tap/tests/repro_test_leak_3525.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/savepoint-3749-t.cpp b/test/tap/tests/savepoint-3749-t.cpp index 9606863af3..e8202d900d 100644 --- a/test/tap/tests/savepoint-3749-t.cpp +++ b/test/tap/tests/savepoint-3749-t.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include "mysql.h" #include #include #include diff --git a/test/tap/tests/savepoint-948-t.cpp b/test/tap/tests/savepoint-948-t.cpp index 3ec1a2168c..a174ed2fc2 100644 --- a/test/tap/tests/savepoint-948-t.cpp +++ b/test/tap/tests/savepoint-948-t.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include "mysql.h" #include #include #include diff --git a/test/tap/tests/set_character_set-t.cpp b/test/tap/tests/set_character_set-t.cpp index b0fdce464b..f208e532f9 100644 --- a/test/tap/tests/set_character_set-t.cpp +++ b/test/tap/tests/set_character_set-t.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/set_testing-240-t.cpp b/test/tap/tests/set_testing-240-t.cpp index bf9056dd0e..e08bf5753d 100644 --- a/test/tap/tests/set_testing-240-t.cpp +++ b/test/tap/tests/set_testing-240-t.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include "mysql.h" #include #include #include diff --git a/test/tap/tests/set_testing-multi-t.cpp b/test/tap/tests/set_testing-multi-t.cpp index 02d87f9f26..1f85d6a95b 100644 --- a/test/tap/tests/set_testing-multi-t.cpp +++ b/test/tap/tests/set_testing-multi-t.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include "mysql.h" #include #include #include diff --git a/test/tap/tests/set_testing-t.cpp b/test/tap/tests/set_testing-t.cpp index 18f336bd56..0604669075 100644 --- a/test/tap/tests/set_testing-t.cpp +++ b/test/tap/tests/set_testing-t.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include "mysql.h" #include #include #include diff --git a/test/tap/tests/sqlite3-t.cpp b/test/tap/tests/sqlite3-t.cpp index e41f0068e3..c9c1a421c7 100644 --- a/test/tap/tests/sqlite3-t.cpp +++ b/test/tap/tests/sqlite3-t.cpp @@ -5,7 +5,8 @@ #include #include #include -#include + +#include "openssl/ssl.h" #include "mysql.h" #include "proxysql_structs.h" diff --git a/test/tap/tests/sqlite_autocommit-t.cpp b/test/tap/tests/sqlite_autocommit-t.cpp index 0fb858d56e..e5a15e0726 100644 --- a/test/tap/tests/sqlite_autocommit-t.cpp +++ b/test/tap/tests/sqlite_autocommit-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_admin_prometheus_metrics_dump-t_disabled_gh3571.cpp b/test/tap/tests/test_admin_prometheus_metrics_dump-t_disabled_gh3571.cpp index 4b3ba54325..f979b772e0 100644 --- a/test/tap/tests/test_admin_prometheus_metrics_dump-t_disabled_gh3571.cpp +++ b/test/tap/tests/test_admin_prometheus_metrics_dump-t_disabled_gh3571.cpp @@ -10,8 +10,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_admin_stats-t.cpp b/test/tap/tests/test_admin_stats-t.cpp index 7128767250..29ac4d0e40 100644 --- a/test/tap/tests/test_admin_stats-t.cpp +++ b/test/tap/tests/test_admin_stats-t.cpp @@ -27,8 +27,8 @@ DELETE FROM history_mysql_status_variables; #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_auto_increment_delay_multiplex-t.cpp b/test/tap/tests/test_auto_increment_delay_multiplex-t.cpp index ad6f04a258..ee50da7211 100644 --- a/test/tap/tests/test_auto_increment_delay_multiplex-t.cpp +++ b/test/tap/tests/test_auto_increment_delay_multiplex-t.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "json.hpp" diff --git a/test/tap/tests/test_binlog_fast_forward-t.cpp b/test/tap/tests/test_binlog_fast_forward-t.cpp index a80247fb7a..281ac0e056 100644 --- a/test/tap/tests/test_binlog_fast_forward-t.cpp +++ b/test/tap/tests/test_binlog_fast_forward-t.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_binlog_reader-t.cpp b/test/tap/tests/test_binlog_reader-t.cpp index 432d1244ef..82eaf7f619 100644 --- a/test/tap/tests/test_binlog_reader-t.cpp +++ b/test/tap/tests/test_binlog_reader-t.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include #include "tap.h" diff --git a/test/tap/tests/test_binlog_reader_uses_previous_hostgroup-t.cpp b/test/tap/tests/test_binlog_reader_uses_previous_hostgroup-t.cpp index 45e214f296..2015e47163 100644 --- a/test/tap/tests/test_binlog_reader_uses_previous_hostgroup-t.cpp +++ b/test/tap/tests/test_binlog_reader_uses_previous_hostgroup-t.cpp @@ -10,7 +10,7 @@ */ #include -#include +#include "mysql.h" #include #include diff --git a/test/tap/tests/test_clickhouse_server-t.cpp b/test/tap/tests/test_clickhouse_server-t.cpp index 1fe6a08665..d943442e97 100644 --- a/test/tap/tests/test_clickhouse_server-t.cpp +++ b/test/tap/tests/test_clickhouse_server-t.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_client_limit_error-t.cpp b/test/tap/tests/test_client_limit_error-t.cpp index 8ae4618d2e..6d84f245a7 100644 --- a/test/tap/tests/test_client_limit_error-t.cpp +++ b/test/tap/tests/test_client_limit_error-t.cpp @@ -48,8 +48,8 @@ #include #include -#include -#include +#include "proxysql_utils.h" +#include "mysql.h" #include "json.hpp" #include "tap.h" diff --git a/test/tap/tests/test_cluster1-t.cpp b/test/tap/tests/test_cluster1-t.cpp index b3a4526cef..089c4bd82a 100644 --- a/test/tap/tests/test_cluster1-t.cpp +++ b/test/tap/tests/test_cluster1-t.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_cluster_sync-t.cpp b/test/tap/tests/test_cluster_sync-t.cpp index 3d7128ca54..94a840bdc9 100644 --- a/test/tap/tests/test_cluster_sync-t.cpp +++ b/test/tap/tests/test_cluster_sync-t.cpp @@ -77,9 +77,9 @@ #include -#include +#include "proxysql_utils.h" -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_com_reset_connection_com_change_user-t.cpp b/test/tap/tests/test_com_reset_connection_com_change_user-t.cpp index e02981b2c3..ed81bd5abb 100644 --- a/test/tap/tests/test_com_reset_connection_com_change_user-t.cpp +++ b/test/tap/tests/test_com_reset_connection_com_change_user-t.cpp @@ -19,8 +19,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "command_line.h" #include "proxysql_utils.h" diff --git a/test/tap/tests/test_connection_annotation-t.cpp b/test/tap/tests/test_connection_annotation-t.cpp index 93b09f28fe..915e20c122 100644 --- a/test/tap/tests/test_connection_annotation-t.cpp +++ b/test/tap/tests/test_connection_annotation-t.cpp @@ -10,8 +10,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_csharp_connector_support-t.cpp b/test/tap/tests/test_csharp_connector_support-t.cpp index 6c4856f079..a6a1168fe7 100644 --- a/test/tap/tests/test_csharp_connector_support-t.cpp +++ b/test/tap/tests/test_csharp_connector_support-t.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_debug_filters-t.cpp b/test/tap/tests/test_debug_filters-t.cpp index c3b17bc2df..559f73b653 100644 --- a/test/tap/tests/test_debug_filters-t.cpp +++ b/test/tap/tests/test_debug_filters-t.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_default_conn_collation-t.cpp b/test/tap/tests/test_default_conn_collation-t.cpp index fa8a29ef8d..a130ac1307 100644 --- a/test/tap/tests/test_default_conn_collation-t.cpp +++ b/test/tap/tests/test_default_conn_collation-t.cpp @@ -10,7 +10,7 @@ #include #include "mysql.h" -#include "mysql/mysqld_error.h" +#include "mysqld_error.h" #include "tap.h" #include "utils.h" diff --git a/test/tap/tests/test_default_value_transaction_isolation-t.cpp b/test/tap/tests/test_default_value_transaction_isolation-t.cpp index cca5d20806..972b9a3ac0 100644 --- a/test/tap/tests/test_default_value_transaction_isolation-t.cpp +++ b/test/tap/tests/test_default_value_transaction_isolation-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_default_value_transaction_isolation_attr-t.cpp b/test/tap/tests/test_default_value_transaction_isolation_attr-t.cpp index e709c24635..c90541e200 100644 --- a/test/tap/tests/test_default_value_transaction_isolation_attr-t.cpp +++ b/test/tap/tests/test_default_value_transaction_isolation_attr-t.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_digest_umap_aux-t.cpp b/test/tap/tests/test_digest_umap_aux-t.cpp index f68be97350..227f5af08d 100644 --- a/test/tap/tests/test_digest_umap_aux-t.cpp +++ b/test/tap/tests/test_digest_umap_aux-t.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "mysql.h" #include #include #include diff --git a/test/tap/tests/test_dns_cache-t.cpp b/test/tap/tests/test_dns_cache-t.cpp index c1b5f14c75..652efa2425 100644 --- a/test/tap/tests/test_dns_cache-t.cpp +++ b/test/tap/tests/test_dns_cache-t.cpp @@ -14,8 +14,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_enforce_autocommit_on_reads-t.cpp b/test/tap/tests/test_enforce_autocommit_on_reads-t.cpp index 1dbc62af7c..0d7550c4a9 100644 --- a/test/tap/tests/test_enforce_autocommit_on_reads-t.cpp +++ b/test/tap/tests/test_enforce_autocommit_on_reads-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_filtered_set_statements-t.cpp b/test/tap/tests/test_filtered_set_statements-t.cpp index 726050ac62..5e27cb55fc 100644 --- a/test/tap/tests/test_filtered_set_statements-t.cpp +++ b/test/tap/tests/test_filtered_set_statements-t.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include "mysql.h" #include "proxysql_utils.h" #include "tap.h" diff --git a/test/tap/tests/test_firewall-t.cpp b/test/tap/tests/test_firewall-t.cpp index 39ccf4bd6d..a9b8cc6bab 100644 --- a/test/tap/tests/test_firewall-t.cpp +++ b/test/tap/tests/test_firewall-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_flagOUT_weight-t.cpp b/test/tap/tests/test_flagOUT_weight-t.cpp index df6aa718c5..f07da9f2cc 100644 --- a/test/tap/tests/test_flagOUT_weight-t.cpp +++ b/test/tap/tests/test_flagOUT_weight-t.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_gtid_forwarding-t.cpp b/test/tap/tests/test_gtid_forwarding-t.cpp index 4be02a5c72..dddc65206a 100644 --- a/test/tap/tests/test_gtid_forwarding-t.cpp +++ b/test/tap/tests/test_gtid_forwarding-t.cpp @@ -14,8 +14,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_keep_multiplexing_variables-t.cpp b/test/tap/tests/test_keep_multiplexing_variables-t.cpp index ef4995bc91..56e283c93b 100644 --- a/test/tap/tests/test_keep_multiplexing_variables-t.cpp +++ b/test/tap/tests/test_keep_multiplexing_variables-t.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_log_last_insert_id-t.cpp b/test/tap/tests/test_log_last_insert_id-t.cpp index 8fa074c153..2443a85d1d 100644 --- a/test/tap/tests/test_log_last_insert_id-t.cpp +++ b/test/tap/tests/test_log_last_insert_id-t.cpp @@ -7,8 +7,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_mysql_connect_retries_delay-t.cpp b/test/tap/tests/test_mysql_connect_retries_delay-t.cpp index e08596bb9a..014c2eff6b 100644 --- a/test/tap/tests/test_mysql_connect_retries_delay-t.cpp +++ b/test/tap/tests/test_mysql_connect_retries_delay-t.cpp @@ -18,8 +18,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_mysql_hostgroup_attributes-1-t.cpp b/test/tap/tests/test_mysql_hostgroup_attributes-1-t.cpp index 31adbb1f4d..8825126eb8 100644 --- a/test/tap/tests/test_mysql_hostgroup_attributes-1-t.cpp +++ b/test/tap/tests/test_mysql_hostgroup_attributes-1-t.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_mysql_query_rules_fast_routing-t.cpp b/test/tap/tests/test_mysql_query_rules_fast_routing-t.cpp index 765366165c..cecfd8dfcc 100644 --- a/test/tap/tests/test_mysql_query_rules_fast_routing-t.cpp +++ b/test/tap/tests/test_mysql_query_rules_fast_routing-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_mysqlsh-t.cpp b/test/tap/tests/test_mysqlsh-t.cpp index bb1324398f..a809b172b5 100644 --- a/test/tap/tests/test_mysqlsh-t.cpp +++ b/test/tap/tests/test_mysqlsh-t.cpp @@ -8,8 +8,8 @@ #include #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_prometheus_metrics-t.cpp b/test/tap/tests/test_prometheus_metrics-t.cpp index 1b52e23934..a9bc27df6a 100644 --- a/test/tap/tests/test_prometheus_metrics-t.cpp +++ b/test/tap/tests/test_prometheus_metrics-t.cpp @@ -16,8 +16,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "json.hpp" #include "tap.h" diff --git a/test/tap/tests/test_ps_async-t.cpp b/test/tap/tests/test_ps_async-t.cpp index 5674b532c1..707d880eaf 100644 --- a/test/tap/tests/test_ps_async-t.cpp +++ b/test/tap/tests/test_ps_async-t.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_ps_hg_routing-t.cpp b/test/tap/tests/test_ps_hg_routing-t.cpp index ad4da4000c..02a514f111 100644 --- a/test/tap/tests/test_ps_hg_routing-t.cpp +++ b/test/tap/tests/test_ps_hg_routing-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_ps_large_result-t.cpp b/test/tap/tests/test_ps_large_result-t.cpp index 5f2b47c70d..52e6caaba9 100644 --- a/test/tap/tests/test_ps_large_result-t.cpp +++ b/test/tap/tests/test_ps_large_result-t.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_ps_no_store-t.cpp b/test/tap/tests/test_ps_no_store-t.cpp index f2aad57199..a64b507bf9 100644 --- a/test/tap/tests/test_ps_no_store-t.cpp +++ b/test/tap/tests/test_ps_no_store-t.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_query_cache_soft_ttl_pct-t.cpp b/test/tap/tests/test_query_cache_soft_ttl_pct-t.cpp index 4594477c4f..68bce7954f 100644 --- a/test/tap/tests/test_query_cache_soft_ttl_pct-t.cpp +++ b/test/tap/tests/test_query_cache_soft_ttl_pct-t.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include "mysql.h" #include #include #include diff --git a/test/tap/tests/test_query_rules_fast_routing_algorithm-t.cpp b/test/tap/tests/test_query_rules_fast_routing_algorithm-t.cpp index b0171f9c37..81b8c39ee4 100644 --- a/test/tap/tests/test_query_rules_fast_routing_algorithm-t.cpp +++ b/test/tap/tests/test_query_rules_fast_routing_algorithm-t.cpp @@ -13,8 +13,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "utils.h" diff --git a/test/tap/tests/test_query_rules_routing-t.cpp b/test/tap/tests/test_query_rules_routing-t.cpp index 165e08543e..792ef90ae9 100644 --- a/test/tap/tests/test_query_rules_routing-t.cpp +++ b/test/tap/tests/test_query_rules_routing-t.cpp @@ -19,8 +19,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "command_line.h" #include "proxysql_utils.h" diff --git a/test/tap/tests/test_query_timeout-t.cpp b/test/tap/tests/test_query_timeout-t.cpp index 32ae524c4c..9f4af5f6b5 100644 --- a/test/tap/tests/test_query_timeout-t.cpp +++ b/test/tap/tests/test_query_timeout-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp b/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp index 3ee3e9a42e..90380e20f9 100644 --- a/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp +++ b/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" #include "utils.h" diff --git a/test/tap/tests/test_rw_binary_data-t.cpp b/test/tap/tests/test_rw_binary_data-t.cpp index a61f9834b6..748d62aedd 100644 --- a/test/tap/tests/test_rw_binary_data-t.cpp +++ b/test/tap/tests/test_rw_binary_data-t.cpp @@ -24,8 +24,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "command_line.h" #include "proxysql_utils.h" diff --git a/test/tap/tests/test_set_character_results-t.cpp b/test/tap/tests/test_set_character_results-t.cpp index 5bd927353f..a4499ac04c 100644 --- a/test/tap/tests/test_set_character_results-t.cpp +++ b/test/tap/tests/test_set_character_results-t.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_set_collation-t.cpp b/test/tap/tests/test_set_collation-t.cpp index 563f6af61c..cc3a6df4b9 100644 --- a/test/tap/tests/test_set_collation-t.cpp +++ b/test/tap/tests/test_set_collation-t.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include "mysql.h" #include #include "tap.h" diff --git a/test/tap/tests/test_simple_embedded_HTTP_server-t.cpp b/test/tap/tests/test_simple_embedded_HTTP_server-t.cpp index 86d9328bb1..4f2860a729 100644 --- a/test/tap/tests/test_simple_embedded_HTTP_server-t.cpp +++ b/test/tap/tests/test_simple_embedded_HTTP_server-t.cpp @@ -8,8 +8,8 @@ #include "curl/curl.h" -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_sqlite3_server-t.cpp b/test/tap/tests/test_sqlite3_server-t.cpp index 36d6982ef8..a9e2b06f93 100644 --- a/test/tap/tests/test_sqlite3_server-t.cpp +++ b/test/tap/tests/test_sqlite3_server-t.cpp @@ -35,8 +35,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_sqlite3_server_and_fast_routing-t.cpp b/test/tap/tests/test_sqlite3_server_and_fast_routing-t.cpp index 84f74042e6..c53732373d 100644 --- a/test/tap/tests/test_sqlite3_server_and_fast_routing-t.cpp +++ b/test/tap/tests/test_sqlite3_server_and_fast_routing-t.cpp @@ -7,8 +7,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_ssl_connect-t.cpp b/test/tap/tests/test_ssl_connect-t.cpp index f517c5a82d..daa9d02f66 100644 --- a/test/tap/tests/test_ssl_connect-t.cpp +++ b/test/tap/tests/test_ssl_connect-t.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_ssl_fast_forward-1-t.cpp b/test/tap/tests/test_ssl_fast_forward-1-t.cpp index b075ef632f..f8c5022c8d 100644 --- a/test/tap/tests/test_ssl_fast_forward-1-t.cpp +++ b/test/tap/tests/test_ssl_fast_forward-1-t.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_ssl_fast_forward-2-t.cpp b/test/tap/tests/test_ssl_fast_forward-2-t.cpp index dd5b0b9a3b..e90f4b8d94 100644 --- a/test/tap/tests/test_ssl_fast_forward-2-t.cpp +++ b/test/tap/tests/test_ssl_fast_forward-2-t.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_ssl_fast_forward-3-t.cpp b/test/tap/tests/test_ssl_fast_forward-3-t.cpp index af48b854d4..24d36e3842 100644 --- a/test/tap/tests/test_ssl_fast_forward-3-t.cpp +++ b/test/tap/tests/test_ssl_fast_forward-3-t.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_ssl_large_query-1-t.cpp b/test/tap/tests/test_ssl_large_query-1-t.cpp index fd9ef63a9e..896a2d955d 100644 --- a/test/tap/tests/test_ssl_large_query-1-t.cpp +++ b/test/tap/tests/test_ssl_large_query-1-t.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_ssl_large_query-2-t.cpp b/test/tap/tests/test_ssl_large_query-2-t.cpp index eb780cf2b4..eaaaada5db 100644 --- a/test/tap/tests/test_ssl_large_query-2-t.cpp +++ b/test/tap/tests/test_ssl_large_query-2-t.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_stats_proxysql_message_metrics-t.cpp b/test/tap/tests/test_stats_proxysql_message_metrics-t.cpp index 173dff40b4..8970596977 100644 --- a/test/tap/tests/test_stats_proxysql_message_metrics-t.cpp +++ b/test/tap/tests/test_stats_proxysql_message_metrics-t.cpp @@ -8,8 +8,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "tap.h" #include "utils.h" diff --git a/test/tap/tests/test_throttle_max_bytes_per_second_to_client-t.cpp b/test/tap/tests/test_throttle_max_bytes_per_second_to_client-t.cpp index 3382d1fa21..d031f3c561 100644 --- a/test/tap/tests/test_throttle_max_bytes_per_second_to_client-t.cpp +++ b/test/tap/tests/test_throttle_max_bytes_per_second_to_client-t.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "mysql.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests/test_unshun_algorithm-t.cpp b/test/tap/tests/test_unshun_algorithm-t.cpp index 6e57c5f8a0..4a5714eaaf 100644 --- a/test/tap/tests/test_unshun_algorithm-t.cpp +++ b/test/tap/tests/test_unshun_algorithm-t.cpp @@ -63,8 +63,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "proxysql_utils.h" #include "tap.h" diff --git a/test/tap/tests/test_unsupported_queries-t.cpp b/test/tap/tests/test_unsupported_queries-t.cpp index 35acce78ab..07afbb7884 100644 --- a/test/tap/tests/test_unsupported_queries-t.cpp +++ b/test/tap/tests/test_unsupported_queries-t.cpp @@ -12,8 +12,8 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" #include "command_line.h" #include "json.hpp" diff --git a/test/tap/tests_with_deps/Makefile b/test/tap/tests_with_deps/Makefile index 8c99712ab9..7e9665fea3 100644 --- a/test/tap/tests_with_deps/Makefile +++ b/test/tap/tests_with_deps/Makefile @@ -1,13 +1,20 @@ +#!/bin/make -f + + +.DEFAULT: all .PHONY: all all: deprecate_eof_support -.PHONY: clean -clean: - cd deprecate_eof_support && ${MAKE} clean - .PHONY: debug debug: deprecate_eof_support + .PHONY: deprecate_eof_support deprecate_eof_support: cd deprecate_eof_support && CC=${CC} CXX=${CXX} ${MAKE} $(MAKECMDGOALS) + + +.PHONY: clean +.SILENT: clean +clean: + cd deprecate_eof_support && ${MAKE} clean diff --git a/test/tap/tests_with_deps/deprecate_eof_support/Makefile b/test/tap/tests_with_deps/deprecate_eof_support/Makefile index 4db69b67f1..bfbccf3815 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/Makefile +++ b/test/tap/tests_with_deps/deprecate_eof_support/Makefile @@ -1,106 +1,194 @@ -include ../common_defs.Makefile +#!/bin/make -f -MARIADB_BASE_FOLDER=$(TEST_DEPS)/mariadb-client-library-3.1.9/ -MARIADB_TEST_DEP=$(TEST_DEPS)/mariadb-client-library-3.1.9/mariadb-connector-c -BASE_DIR_EXIST := $(shell if [ -d $(MARIADB_BASE_FOLDER) ]; then echo 1; else echo 0; fi) -DEP_FOLDER_EMPTY := $(shell if [ -f $(MARIADB_TEST_DEP)/CMakeLists.txt ]; then echo 1; else echo 0; fi) +GIT_VERSION ?= $(shell git describe --long --abbrev=7) +ifndef GIT_VERSION + $(error GIT_VERSION is not set) +endif -ifeq ($(BASE_DIR_EXIST), 1) -ifeq ($(DEP_FOLDER_EMPTY), 0) - $(error "Dependency folder '$(MARIADB_TEST_DEP)' is empty. Make sure folder is initialized") -endif +PROXYSQL_PATH := $(shell while [ ! -f ./src/proxysql_global.cpp ]; do cd ..; done; pwd) +PROXYSQL_IDIR := $(PROXYSQL_PATH)/include +PROXYSQL_LDIR := $(PROXYSQL_PATH)/lib -.PHONY: all -all: build_deps tests +DEPS_PATH := $(PROXYSQL_PATH)/deps -OPT=-O2 $(WGCOV) -Wl,--no-as-needed +MARIADB_PATH := $(DEPS_PATH)/mariadb-client-library/mariadb_client +MARIADB_IDIR := $(MARIADB_PATH)/include +MARIADB_LDIR := $(MARIADB_PATH)/libmariadb -.PHONY: debug -debug: OPT=-O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WGCOV) $(WASAN) -debug: build_deps tests +JEMALLOC_PATH := $(DEPS_PATH)/jemalloc/jemalloc +JEMALLOC_IDIR := $(JEMALLOC_PATH)/include/jemalloc +JEMALLOC_LDIR := $(JEMALLOC_PATH)/lib -LLP=$(shell pwd)/../../tap -$(MARIADB_TEST_DEP)/libmariadb/libmariadbclient.a: - cd $(MARIADB_BASE_FOLDER) && CC=${CC} CXX=${CXX} ${MAKE} mariadb_client +JSON_IDIR := $(DEPS_PATH)/json -.PHONY: build_deps -build_deps: $(MARIADB_TEST_DEP)/libmariadb/libmariadbclient.a +RE2_PATH := $(DEPS_PATH)/re2/re2 +RE2_IDIR := $(RE2_PATH) +RE2_LDIR := $(RE2_PATH)/obj -.PHONY: clean -clean: - rm -f *-t - rm -f fwd_eof_query - rm -f fwd_eof_ok_query - rm -f *.a *.o - cd $(MARIADB_BASE_FOLDER) && ${MAKE} clean - -WITHGCOVVAR := $(shell echo $(WITHGCOV)) -ifeq ($(WITHGCOVVAR),1) -WGCOV=-DWITHGCOV --coverage -lgcov -else -WGCOV= +SQLITE3_PATH := $(DEPS_PATH)/sqlite3/sqlite3 +SQLITE3_IDIR := $(SQLITE3_PATH) +SQLITE3_LDIR := $(SQLITE3_PATH) + +LIBHTTPSERVER_DIR := $(DEPS_PATH)/libhttpserver/libhttpserver +LIBHTTPSERVER_IDIR := $(LIBHTTPSERVER_DIR)/src +LIBHTTPSERVER_LDIR := $(LIBHTTPSERVER_DIR)/build/src/.libs/ + +LIBCONFIG_PATH := $(DEPS_PATH)/libconfig/libconfig +LIBCONFIG_IDIR := $(LIBCONFIG_PATH)/lib +LIBCONFIG_LDIR := $(LIBCONFIG_PATH)/lib/.libs + +CURL_DIR := $(DEPS_PATH)/curl/curl +CURL_IDIR := $(CURL_DIR)/include +CURL_LDIR := $(CURL_DIR)/lib/.libs + +PCRE_PATH := $(DEPS_PATH)/pcre/pcre +PCRE_LDIR := $(PCRE_PATH)/.libs + +MICROHTTPD_DIR := $(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src +MICROHTTPD_IDIR := $(MICROHTTPD_DIR)/include +MICROHTTPD_LDIR := $(MICROHTTPD_DIR)/microhttpd/.libs + +SSL_DIR := $(DEPS_PATH)/libssl/openssl/ +SSL_IDIR := $(SSL_DIR)/include +SSL_LDIR := $(SSL_DIR) + +EV_DIR := $(DEPS_PATH)/libev/libev/ +EV_IDIR := $(EV_DIR) +EV_LDIR := $(EV_DIR)/.libs + +PROMETHEUS_PATH := $(DEPS_PATH)/prometheus-cpp/prometheus-cpp +PROMETHEUS_IDIR := $(PROMETHEUS_PATH)/pull/include -I$(PROMETHEUS_PATH)/core/include +PROMETHEUS_LDIR := $(PROMETHEUS_PATH)/lib + +CITYHASH_DIR := $(DEPS_PATH)/cityhash/cityhash/ +CITYHASH_IDIR := $(CITYHASH_DIR) +CITYHASH_LDIR := $(CITYHASH_DIR)/src/.libs + +COREDUMPER_DIR := $(DEPS_PATH)/coredumper/coredumper +COREDUMPER_IDIR := $(COREDUMPER_DIR)/include +COREDUMPER_LDIR := $(COREDUMPER_DIR)/src + +TAP_PATH := $(PROXYSQL_PATH)/test/tap/tap +TAP_IDIR := $(TAP_PATH) +TAP_LDIR := $(TAP_PATH) + +TEST_DEPS_PATH := $(PROXYSQL_PATH)/test/deps + +TEST_MARIADB_PATH := $(TEST_DEPS_PATH)/mariadb-connector-c/mariadb-connector-c +TEST_MARIADB_IDIR := $(TEST_MARIADB_PATH)/include +TEST_MARIADB_LDIR := $(TEST_MARIADB_PATH)/libmariadb + +TEST_MYSQL_PATH := $(TEST_DEPS_PATH)/mysql-connector-c/mysql-connector-c +TEST_MYSQL_IDIR := $(TEST_MYSQL_PATH)/include +TEST_MYSQL_EDIR := $(TEST_MYSQL_PATH)/libbinlogevents/export +TEST_MYSQL_LDIR := $(TEST_MYSQL_PATH)/libmysql + +### detect compiler support for c++11/17 +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201703L) + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +ifneq ($(CPLUSPLUS),201103L) + $(error Compiler must support at least c++11) +endif +endif +STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4) + +WGCOV := +ifeq ($(WITHGCOV),1) + WGCOV := -DWITHGCOV --coverage -lgcov endif -WITHASANVAR := $(shell echo $(WITHASAN)) -ifeq ($(WITHASANVAR),1) -WASAN=-fsanitize=address -else -WASAN= +WASAN := +ifeq ($(WITHASAN),1) + WASAN := -fsanitize=address endif -TESTS_DEPS=$(TAP_LIBDIR)/libtap.a $(MARIADB_TEST_DEP)/libmariadb/libmariadbclient.a +OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed -Wl,-rpath,$(TAP_LDIR) $(WGCOV) $(WASAN) + +IDIRS := -I$(TAP_IDIR) -I$(RE2_IDIR) -I$(PROXYSQL_IDIR) -I$(JEMALLOC_IDIR) -I$(LIBCONFIG_IDIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(CURL_IDIR) -I$(EV_IDIR) -I$(PROMETHEUS_IDIR) -I$(DOTENV_DYN_IDIR) -I$(SSL_IDIR) -I$(SQLITE3_IDIR) -I$(JSON_IDIR) +LDIRS := -L$(TAP_LDIR) -L$(RE2_LDIR) -L$(PROXYSQL_LDIR) -L$(JEMALLOC_LDIR) -L$(LIBCONFIG_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(PROMETHEUS_LDIR) -L$(DOTENV_DYN_LDIR) -L$(SSL_LDIR) -L$(SQLITE3_LDIR) -L$(PCRE_LDIR) + +### main targets + +.DEFAULT: default +.PHONY: default +default: all + +.PHONY: all +all: tests + +.PHONY: debug +debug: DEBUG := -DDEBUG +debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed -Wl,-rpath,$(TAP_LDIR) $(WGCOV) $(WASAN) +debug: tests + -tests: $(patsubst %.cpp,%,$(wildcard *-t.cpp)) fwd_eof_query fwd_eof_ok_query +### test deps targets -COMMONARGS1=$(OPT) -std=c++11 -I$(TAP_LIBDIR) -L$(TAP_LIBDIR) -ltap -lcpp_dotenv -Wl,--no-as-needed -lz -ldl -lpthread -DGITVERSION=\"$(GIT_VERSION)\" -DDEBUG -I$(JSON_IDIR) -COMMONARGS=$(COMMONARGS1) $(MYLIBS) +#.PHONY: build_test_deps +#build_test_deps: $(TAP_LDIR)/libtap.so $(TEST_MARIADB_LDIR)/libmariadbclient.a $(TEST_MYSQL_LDIR)/libmysqlclient.a -ok_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp $(TESTS_DEPS) - LD_LIBRARY_PATH=$(LLP) $(CXX) $< $(INCLUDEDIRS) $(LDIRS) $(COMMONARGS) -o $@ +$(TAP_LDIR)/libtap.so: + cd $(TAP_PATH) && CC=${CC} CXX=${CXX} ${MAKE} -eof_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp ok_packet_mixed_queries-t $(TESTS_DEPS) - LD_LIBRARY_PATH=$(LLP) $(CXX) -DNON_EOF_SUPPORT $< $(INCLUDEDIRS) -I$(MARIADB_TEST_DEP)/include/ -L$(MARIADB_TEST_DEP)/libmariadb $(COMMONARGS) -o $@ +$(TEST_MARIADB_LDIR)/libmariadbclient.a: + cd $(TEST_DEPS_PATH) && CC=${CC} CXX=${CXX} ${MAKE} mariadb_client -fwd_eof_query: fwd_eof_query.cpp $(TESTS_DEPS) - LD_LIBRARY_PATH=$(LLP) $(CXX) -DNON_EOF_SUPPORT $< $(INCLUDEDIRS) -L$(MARIADB_TEST_DEP)/libmariadb $(COMMONARGS) -o $@ +$(TEST_MYSQL_LDIR)/libmysqlclient.a: + cd $(TEST_DEPS_PATH) && CC=${CC} CXX=${CXX} ${MAKE} mysql_client -#fwd_eof_ok_query: fwd_eof_query.cpp $(TESTS_DEPS) -# $(CXX) -DDEBUG fwd_eof_query.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 -I$(TAP_LIBDIR) -L$(TAP_LIBDIR) $(MYLIBS) -L$(SSL_LDIR) -ltap -Wl,--no-as-needed -ldl -lpthread -o fwd_eof_ok_query -DGITVERSION=\"$(GIT_VERSION)\" + +### test and helper targets + +#tests: build_test_deps +tests: $(patsubst %.cpp,%,$(wildcard *-t.cpp)) ok_packet_mixed_queries-t fwd_eof_query fwd_eof_ok_query + +COMMONARGS = $(OPT) -Wl,-Bdynamic -ltap -lcpp_dotenv -lcurl -lssl -lcrypto -lz -ldl -lpthread -DGITVERSION=\"$(GIT_VERSION)\" + +ok_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp + $(CXX) $< $(IDIRS) $(LDIRS) -I$(MARIADB_IDIR) -L$(MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ + +eof_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp + $(CXX) -DNON_EOF_SUPPORT $< $(IDIRS) $(LDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ + +fwd_eof_query: fwd_eof_query.cpp + $(CXX) -DNON_EOF_SUPPORT $< $(IDIRS) $(LDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ # NOTE: Compilation with 'libmysql' instead of 'libmariadb' client to confirm packet sequence id isn't check by 'libmariadb' -fwd_eof_ok_query: fwd_eof_query.cpp $(TAP_LIBDIR)/libtap.a - LD_LIBRARY_PATH=$(LLP) $(CXX) $< -I/usr/include/mysql/ -I$(IDIR) -L/usr/lib/x86_64-linux-gnu/ -lmysqlclient $(COMMONARGS1) -o $@ +fwd_eof_ok_query: fwd_eof_query.cpp + $(CXX) $< $(IDIRS) $(LDIRS) -I$(TEST_MARIADB_IDIR) -I$(TEST_MYSQL_IDIR) -I$(TEST_MYSQL_EDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(COMMONARGS) -o $@ +# NOTE end -deprecate_eof_cache-t: deprecate_eof_cache-t.cpp $(TESTS_DEPS) - LD_LIBRARY_PATH=$(LLP) $(CXX) $^ $(INCLUDEDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -L$(PROXYLDIR) -lproxysql $(COMMONARGS) -o $@ +deprecate_eof_cache-t: deprecate_eof_cache-t.cpp + $(CXX) $< $(IDIRS) $(LDIRS) $(PROXYSQL_LDIR)/proxysql_utils.cpp -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -eof_cache_mixed_flags-t: eof_cache_mixed_flags-t.cpp $(TESTS_DEPS) - LD_LIBRARY_PATH=$(LLP) $(CXX) $^ $(INCLUDEDIRS) -L$(MARIADB_TEST_DEP)/libmariadb $(COMMONARGS) -o $@ +eof_cache_mixed_flags-t: eof_cache_mixed_flags-t.cpp + $(CXX) $< $(IDIRS) $(LDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -eof_mixed_flags_queries-t: eof_mixed_flags_queries-t.cpp $(TESTS_DEPS) - LD_LIBRARY_PATH=$(LLP) $(CXX) $^ $(INCLUDEDIRS) -L$(MARIADB_TEST_DEP)/libmariadb $(COMMONARGS) -o $@ +eof_mixed_flags_queries-t: eof_mixed_flags_queries-t.cpp + $(CXX) $< $(IDIRS) $(LDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -eof_conn_options_check-t: eof_conn_options_check-t.cpp $(TESTS_DEPS) - LD_LIBRARY_PATH=$(LLP) $(CXX) $< $(INCLUDEDIRS) $(LDIRS) $(COMMONARGS) -o $@ +eof_conn_options_check-t: eof_conn_options_check-t.cpp + $(CXX) $< $(IDIRS) $(LDIRS) -I$(MARIADB_IDIR) -L$(MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -eof_fast_forward-t: eof_fast_forward-t.cpp $(TESTS_DEPS) - LD_LIBRARY_PATH=$(LLP) $(CXX) $< $(INCLUDEDIRS) $(LDIRS) $(COMMONARGS) -o $@ +eof_fast_forward-t: eof_fast_forward-t.cpp + $(CXX) $< $(IDIRS) $(LDIRS) -I$(MARIADB_IDIR) -L$(MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -else -.PHONY: all -all: - $(warning The required deps were not found. Tests 'deprecate_eof_support' wont be build) -.PHONY: debug -debug: - $(warning The required deps were not found. Tests 'deprecate_eof_support' wont be build) +### clean targets +.SILENT: cleanall +.PHONY: cleanall +cleanall: clean + cd $(TEST_DEPS_PATH) && ${MAKE} cleanall + +.SILENT: clean .PHONY: clean clean: - rm -f *-t - rm -f fwd_eof_query - rm -f fwd_eof_ok_query - rm -f *.a *.o -endif + rm -f *-t || true + rm -f fwd_eof_query || true + rm -f fwd_eof_ok_query || true + rm -f *.a *.o || true + rm -f *.gcda *.gcno || true diff --git a/test/tap/tests_with_deps/deprecate_eof_support/deprecate_eof_cache-t.cpp b/test/tap/tests_with_deps/deprecate_eof_support/deprecate_eof_cache-t.cpp index 66c4e8b8c1..e46e2d3f94 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/deprecate_eof_cache-t.cpp +++ b/test/tap/tests_with_deps/deprecate_eof_support/deprecate_eof_cache-t.cpp @@ -3,13 +3,14 @@ #include #include #include +#include #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" -#include +#include "proxysql_utils.h" #include "tap.h" #include "command_line.h" @@ -17,6 +18,7 @@ #include "json.hpp" + using std::vector; using std::string; using std::pair; diff --git a/test/tap/tests_with_deps/deprecate_eof_support/eof_cache_mixed_flags-t.cpp b/test/tap/tests_with_deps/deprecate_eof_support/eof_cache_mixed_flags-t.cpp index 22f6ee9ffc..f7f95a694d 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/eof_cache_mixed_flags-t.cpp +++ b/test/tap/tests_with_deps/deprecate_eof_support/eof_cache_mixed_flags-t.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests_with_deps/deprecate_eof_support/eof_conn_options_check-t.cpp b/test/tap/tests_with_deps/deprecate_eof_support/eof_conn_options_check-t.cpp index bb9cbfe999..ea64d518c8 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/eof_conn_options_check-t.cpp +++ b/test/tap/tests_with_deps/deprecate_eof_support/eof_conn_options_check-t.cpp @@ -17,13 +17,14 @@ #include #include -#include +#include "mysqld_error.h" #include "json.hpp" #include "tap.h" #include "command_line.h" #include "utils.h" + using nlohmann::json; /** diff --git a/test/tap/tests_with_deps/deprecate_eof_support/eof_fast_forward-t.cpp b/test/tap/tests_with_deps/deprecate_eof_support/eof_fast_forward-t.cpp index 976c4931c5..e6260d0a7d 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/eof_fast_forward-t.cpp +++ b/test/tap/tests_with_deps/deprecate_eof_support/eof_fast_forward-t.cpp @@ -17,15 +17,16 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" -#include +#include "proxysql_utils.h" #include "tap.h" #include "command_line.h" #include "utils.h" + using std::vector; using std::string; using std::pair; diff --git a/test/tap/tests_with_deps/deprecate_eof_support/eof_mixed_flags_queries-t.cpp b/test/tap/tests_with_deps/deprecate_eof_support/eof_mixed_flags_queries-t.cpp index d860ed25c3..2222e6a19c 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/eof_mixed_flags_queries-t.cpp +++ b/test/tap/tests_with_deps/deprecate_eof_support/eof_mixed_flags_queries-t.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include "mysqld_error.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests_with_deps/deprecate_eof_support/eof_packet_mixed_queries-t.cpp b/test/tap/tests_with_deps/deprecate_eof_support/eof_packet_mixed_queries-t.cpp index 6584afb920..d55fa7f2f6 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/eof_packet_mixed_queries-t.cpp +++ b/test/tap/tests_with_deps/deprecate_eof_support/eof_packet_mixed_queries-t.cpp @@ -19,9 +19,9 @@ #include #include "mysql.h" -#include "mysql/mysqld_error.h" +#include "mysqld_error.h" -#include +#include "proxysql_utils.h" #include "tap.h" #include "command_line.h" diff --git a/test/tap/tests_with_deps/deprecate_eof_support/fwd_eof_query.cpp b/test/tap/tests_with_deps/deprecate_eof_support/fwd_eof_query.cpp index faf18c8599..5eb35f4c61 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/fwd_eof_query.cpp +++ b/test/tap/tests_with_deps/deprecate_eof_support/fwd_eof_query.cpp @@ -5,16 +5,18 @@ #include #include -#include -#include +#include "mysql.h" +#include "mysqld_error.h" -#include +#include "proxysql_utils.h" #include "tap.h" #include "command_line.h" #include "json.hpp" +#include "MySQL_Protocol.h" + using namespace nlohmann; using std::string;