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 3fdb6a0026..b50b0b38d3 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 @@ -111,25 +124,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} @@ -187,44 +224,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) @@ -292,6 +352,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: @@ -299,9 +361,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: @@ -342,7 +406,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 @@ -379,7 +443,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..7fa0cec5b7 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,57 +191,49 @@ 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 - cd mariadb-client-library/mariadb_client && patch ./plugins/auth/CMakeLists.txt < ../plugin_auth_CMakeLists.txt.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../ConnectorName.patch + cd mariadb-client-library && tar -zxf mariadb-connector-c-3.3.8-src.tar.gz + cd mariadb-client-library/mariadb_client && patch -p0 < ../plugin_auth_CMakeLists.txt.patch cd mariadb-client-library/mariadb_client && cmake . -Wno-dev -DOPENSSL_ROOT_DIR=$(shell pwd)/libssl/openssl/ -DOPENSSL_LIBRARIES=$(shell pwd)/libssl/openssl/ -DICONV_LIBRARIES=$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$(brew --prefix libiconv)/include . ifeq ($(PROXYDEBUG),1) - cd mariadb-client-library/mariadb_client && patch include/ma_context.h < ../ma_context.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_context.h.patch else ifeq ($(USEVALGRIND),1) - cd mariadb-client-library/mariadb_client && patch include/ma_context.h < ../ma_context.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_context.h.patch endif - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_stmt.c < ../mariadb_stmt.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.collation.patch # make sure this path is applied after mariadb_lib.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.ipv6_fix.patch # make sure this patch is applied after mariadb_lib.c.collation.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_stmt.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_lib.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_lib.c.collation.patch # make sure this path is applied after mariadb_lib.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_lib.c.ipv6_fix.patch # make sure this patch is applied after mariadb_lib.c.collation.patch # cd mariadb-client-library/mariadb_client && patch libmariadb/net.c < ../net.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_async.c < ../mariadb_async.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/ma_password.c < ../ma_password.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_async.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_password.c.patch # cd mariadb-client-library/mariadb_client && patch libmariadb/ma_secure.c < ../ma_secure.c.patch - cd mariadb-client-library/mariadb_client && patch include/mysql.h < ../mysql.h.patch - cd mariadb-client-library/mariadb_client && patch include/mariadb_com.h < ../mariadb_com.h.patch - cd mariadb-client-library/mariadb_client && patch include/ma_priv.h < ../ma_priv.h.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/ma_alloc.c < ../ma_alloc.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/ma_charset.c < ../ma_charset.c.patch -# cd mariadb-client-library/mariadb_client && patch libmariadb/ma_pvio.c < ../ma_pvio.c.patch - cd mariadb-client-library/mariadb_client && patch unittest/libmariadb/basic-t.c < ../unittest_basic-t.c.patch - cd mariadb-client-library/mariadb_client && patch unittest/libmariadb/charset.c < ../unittest_charset.c.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../client_deprecate_eof.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../cr_new_stmt_metadata_removal.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../ps_buffer_stmt_read_all_rows.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../empty_split_compress_packet.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_stmt_store_result_err.patch - + cd mariadb-client-library/mariadb_client && patch -p0 < ../mysql.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_priv.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_alloc.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_charset.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../unittest_basic-t.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../unittest_charset.c.patch ifeq ($(WITHASAN),1) cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_asan.patch endif - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_dyncol.c < ../mariadb_dyncol.c-multiplication-overflow.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/ma_array.c < ../ma_array.c-multiplication-overflow.patch - cd mariadb-client-library/mariadb_client && patch zlib/zutil.c < ../zutil.c-multiplication-overflow.patch - # patches for replication testing - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_rpl.c < ../mariadb_rpl.c.patch - cd mariadb-client-library/mariadb_client && patch include/mariadb_rpl.h < ../mariadb_rpl.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_dyncol.c-multiplication-overflow.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_array.c-multiplication-overflow.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../zutil.c-multiplication-overflow.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../cr_new_stmt_metadata_removal.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ps_buffer_stmt_read_all_rows.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_stmt_store_result_err.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../empty_split_compress_packet.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../sslkeylogfile.patch + #cd mariadb-client-library/mariadb_client && patch libmariadb/ma_pvio.c < ../ma_pvio.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../client_deprecate_eof.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_com.h.patch # patches for x509 cache . See https://github.com/sysown/proxysql/issues/4117 (Slow connection time with SSL and large CA file , relevant on Aurora) - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.x509cache.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/secure/openssl.c < ../openssl.c.x509cache.patch - cd mariadb-client-library/mariadb_client && patch include/mysql.h < ../mysql.h.sslkeylogfile.patch - cd mariadb-client-library/mariadb_client && patch include/ma_common.h < ../ma_common.h.sslkeylogfile.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.sslkeylogfile.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/secure/openssl.c < ../openssl.c.sslkeylogfile.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../x509cache.patch + # patches for replication testing + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_rpl.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../cmakelists.txt.patch cd mariadb-client-library/mariadb_client && CC=${CC} CXX=${CXX} ${MAKE} mariadbclient # cd mariadb-client-library/mariadb_client/include && make my_config.h @@ -321,11 +279,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 +301,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/deps/mariadb-client-library/ConnectorName.patch b/deps/mariadb-client-library/ConnectorName.patch deleted file mode 100644 index 3227bd1d7c..0000000000 --- a/deps/mariadb-client-library/ConnectorName.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git cmake/ConnectorName.cmake cmake/ConnectorName.cmake -index b7bbbad..357b8ac 100644 ---- cmake/ConnectorName.cmake -+++ cmake/ConnectorName.cmake -@@ -22,7 +22,7 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Windows") - 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/deps/mariadb-client-library/client_deprecate_eof.patch b/deps/mariadb-client-library/client_deprecate_eof.patch index 2c7a611f50..bf8a89822e 100644 --- a/deps/mariadb-client-library/client_deprecate_eof.patch +++ b/deps/mariadb-client-library/client_deprecate_eof.patch @@ -1,10 +1,10 @@ diff --git include/ma_common.h include/ma_common.h -index 62cf71c..c05e9a3 100644 +index 0d3f39b3..112cd3b5 100644 --- include/ma_common.h +++ include/ma_common.h -@@ -23,6 +23,8 @@ - #include - #include +@@ -24,6 +24,8 @@ + #include + #include +#define MAX_PACKET_LENGTH (256L*256L*256L-1) + @@ -12,37 +12,36 @@ index 62cf71c..c05e9a3 100644 COM_MULTI_OFF= 0, COM_MULTI_CANCEL, diff --git include/mariadb_com.h include/mariadb_com.h -index 948d96e..225b2f5 100644 +index 67461b4f..96e6e04f 100644 --- include/mariadb_com.h +++ include/mariadb_com.h -@@ -160,6 +160,7 @@ enum enum_server_command - #define CLIENT_CONNECT_ATTRS (1UL << 20) +@@ -161,6 +161,7 @@ enum enum_server_command + #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21) #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) #define CLIENT_SESSION_TRACKING (1UL << 23) +#define CLIENT_DEPRECATE_EOF (1UL << 24) + #define CLIENT_ZSTD_COMPRESSION (1UL << 26) #define CLIENT_PROGRESS (1UL << 29) /* client supports progress indicator */ #define CLIENT_PROGRESS_OBSOLETE CLIENT_PROGRESS - #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) -@@ -204,8 +205,14 @@ enum enum_server_command +@@ -209,7 +210,13 @@ enum enum_server_command CLIENT_REMEMBER_OPTIONS |\ CLIENT_PLUGIN_AUTH |\ CLIENT_SESSION_TRACKING |\ + CLIENT_DEPRECATE_EOF |\ CLIENT_CONNECT_ATTRS) - +/* Client capabilities *does no* longer holds 'CLIENT_DEPRECATE_EOF' flag + * by default. This is part of ProxySQL feature for conditionally disabling + * 'deprecate_eof' support in both client and backend connections. For more + * context see #3280. -+ */ - #define CLIENT_CAPABILITIES (CLIENT_MYSQL | \ ++ */ + #define CLIENT_CAPABILITIES (CLIENT_MYSQL | \ CLIENT_LONG_FLAG |\ CLIENT_TRANSACTIONS |\ diff --git include/mariadb_stmt.h include/mariadb_stmt.h -index d07540e..4930573 100644 +index 531c2181..1ae9cf99 100644 --- include/mariadb_stmt.h +++ include/mariadb_stmt.h -@@ -257,7 +257,7 @@ typedef struct st_mysql_perm_bind { +@@ -209,7 +209,7 @@ typedef struct st_mysql_perm_bind { } MYSQL_PS_CONVERSION; extern MYSQL_PS_CONVERSION mysql_ps_fetch_functions[MYSQL_TYPE_GEOMETRY + 1]; @@ -52,7 +51,7 @@ index d07540e..4930573 100644 unsigned long net_field_length(unsigned char **packet); int ma_simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, diff --git libmariadb/ma_net.c libmariadb/ma_net.c -index 15be4fc..a69e637 100644 +index 0b1d0cce..83bf729a 100644 --- libmariadb/ma_net.c +++ libmariadb/ma_net.c @@ -39,8 +39,6 @@ @@ -65,10 +64,10 @@ index 15be4fc..a69e637 100644 See bug conc-57 */ diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c -index e475e25..1a04b2f 100644 +index 75e3c9a4..916024a8 100644 --- libmariadb/mariadb_lib.c +++ libmariadb/mariadb_lib.c -@@ -144,6 +144,7 @@ struct st_mariadb_methods MARIADB_DEFAULT_METHODS; +@@ -150,6 +150,7 @@ struct st_mariadb_methods MARIADB_DEFAULT_METHODS; #define IS_CONNHDLR_ACTIVE(mysql)\ ((mysql)->extension && (mysql)->extension->conn_hdlr) @@ -76,7 +75,7 @@ index e475e25..1a04b2f 100644 static void end_server(MYSQL *mysql); static void mysql_close_memory(MYSQL *mysql); void read_user_name(char *name); -@@ -190,11 +191,15 @@ void net_get_error(char *buf, size_t buf_len, +@@ -196,11 +197,15 @@ void net_get_error(char *buf, size_t buf_len, *****************************************************************************/ ulong @@ -93,45 +92,44 @@ index e475e25..1a04b2f 100644 restart: if (net->pvio != 0) len=ma_net_read(net); -@@ -251,6 +256,28 @@ restart: +@@ -263,6 +268,27 @@ restart: return(packet_error); } + else + { + if (is_data_packet) { -+ unsigned long deprecate_eof = -+ mysql->server_capabilities & CLIENT_DEPRECATE_EOF; -+ *is_data_packet = TRUE; -+ -+ // NOTE: -+ // The only possible alternative to an okay packet where the first byte is -+ // 0xfe, is a packet of int which is bigger than 0xffffff. This is -+ // the reason why a check 'len <= MAX_PACKET_LENGTH' guarantees that -+ // *by_exclusion* the current packet is an 'ok_packet'. -+ if (deprecate_eof && (net->read_pos[0] == 254 && len <= MAX_PACKET_LENGTH)) { -+ *is_data_packet = FALSE; -+ } -+ // A '< 9' check guarantees that it's an EOF packet. -+ else if (!deprecate_eof && (net->read_pos[0] == 254 && len < 9)) -+ { -+ *is_data_packet = FALSE; -+ } ++ unsigned long deprecate_eof = mysql->server_capabilities & CLIENT_DEPRECATE_EOF; ++ *is_data_packet = TRUE; ++ ++ // NOTE: ++ // The only possible alternative to an okay packet where the first byte is ++ // 0xfe, is a packet of int which is bigger than 0xffffff. This is ++ // the reason why a check 'len <= MAX_PACKET_LENGTH' guarantees that ++ // *by_exclusion* the current packet is an 'ok_packet'. ++ if (deprecate_eof && (net->read_pos[0] == 254 && len <= MAX_PACKET_LENGTH)) { ++ *is_data_packet = FALSE; ++ } ++ // A '< 9' check guarantees that it's an EOF packet. ++ else if (!deprecate_eof && (net->read_pos[0] == 254 && len < 9)) ++ { ++ *is_data_packet = FALSE; ++ } + } + } return len; } -@@ -424,7 +451,7 @@ mthd_my_send_cmd(MYSQL *mysql,enum enum_server_command command, const char *arg, +@@ -448,7 +474,7 @@ mthd_my_send_cmd(MYSQL *mysql,enum enum_server_command command, const char *arg, - if (!skipp_check) + if (!skip_check) { - result= ((mysql->packet_length=ma_net_safe_read(mysql)) == packet_error ? + result= ((mysql->packet_length=ma_net_safe_read(mysql, NULL)) == packet_error ? 1 : 0); } end: -@@ -565,12 +592,14 @@ end_server(MYSQL *mysql) +@@ -581,12 +607,14 @@ end_server(MYSQL *mysql) void mthd_my_skip_result(MYSQL *mysql) { ulong pkt_len; @@ -148,29 +146,29 @@ index e475e25..1a04b2f 100644 return; } -@@ -851,6 +880,95 @@ static size_t rset_field_offsets[]= { +@@ -1021,6 +1049,95 @@ static size_t rset_field_offsets[]= { OFFSET(MYSQL_FIELD, org_name_length) }; +/** -+ * @brief Helper function to unpack a particular field. -+ * -+ * NOTE: This function have been introduced due to the requirement -+ * of 'field unpacking' in mthd_my_read_metadata_ex. Extracting the -+ * logic from 'unpack_fields' function. -+ * -+ * @param mysql The mysql connection handler. -+ * @param alloc The mem_root allocator. -+ * @param default_value The default value to use for the field in case -+ * of not containing one. -+ * @param row The row containing the field description. -+ * @param field Output parameter holding the unpacked MYSQL_FIELD. -+ * -+ * @returns 0 on success. -+ */ ++ * @brief Helper function to unpack a particular field. ++ * ++ * NOTE: This function have been introduced due to the requirement ++ * of 'field unpacking' in mthd_my_read_metadata_ex. Extracting the ++ * logic from 'unpack_fields' function. ++ * ++ * @param mysql The mysql connection handler. ++ * @param alloc The mem_root allocator. ++ * @param default_value The default value to use for the field in case ++ * of not containing one. ++ * @param row The row containing the field description. ++ * @param field Output parameter holding the unpacked MYSQL_FIELD. ++ * ++ * @returns 0 on success. ++ */ +int +unpack_field(const MYSQL *mysql, MA_MEM_ROOT *alloc, my_bool default_value, -+ MYSQL_ROWS *row, MYSQL_FIELD *field) ++ MYSQL_ROWS *row, MYSQL_FIELD *field, ulong* field_length) +{ + unsigned int i, field_count = sizeof(rset_field_offsets) / sizeof(size_t) / 2; + char *p = NULL; @@ -181,15 +179,15 @@ index e475e25..1a04b2f 100644 + { + // Initialize in case of empty field + if (row->data[i][0] == 0) { -+ *(char **)(((char *)field) + rset_field_offsets[i*2]) = ma_strdup_root(alloc, ""); -+ *(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1]) = 0; ++ *(char **)(((char *)field) + rset_field_offsets[i*2]) = ma_strdup_root(alloc, ""); ++ *(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1]) = 0; + } + // Copy data in case of not empty + else + { -+ uint length = (uint)(row->data[i+1] - row->data[i] - 1); ++ uint length = ((field_length != NULL) ? (uint)field_length[i] : (uint)(row->data[i+1] - row->data[i] - 1)); + *(char **)(((char *)field) + rset_field_offsets[i*2]) = -+ ma_strdup_root(alloc, (char *)row->data[i]); ++ ma_strdup_root(alloc, (char *)row->data[i]); + *(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1]) = + length; + } @@ -228,9 +226,9 @@ index e475e25..1a04b2f 100644 + field->flags|= NUM_FLAG; + + i++; -+ /* This is used by deprecated function mysql_list_fields only, -+ however the reported length is not correct, so we always zero it */ -+ if (default_value && row->data[i]) ++ /*This is used by deprecated function mysql_list_fields only, ++ however the reported length is not correct, so we always zero it */ ++ if (default_value && row->data[i]) + field->def = ma_strdup_root(alloc,(char*) row->data[i]); + else + field->def = 0; @@ -244,7 +242,7 @@ index e475e25..1a04b2f 100644 MYSQL_FIELD * unpack_fields(const MYSQL *mysql, MYSQL_DATA *data, MA_MEM_ROOT *alloc, uint fields, -@@ -858,71 +976,19 @@ unpack_fields(const MYSQL *mysql, +@@ -1028,71 +1145,19 @@ unpack_fields(const MYSQL *mysql, { MYSQL_ROWS *row; MYSQL_FIELD *field,*result; @@ -264,7 +262,7 @@ index e475e25..1a04b2f 100644 - for (i=0; i < field_count; i++) - { - uint length= (uint)(row->data[i+1] - row->data[i] - 1); -- if (!row->data[i] && row->data[i][length]) +- if (!row->data[i] || row->data[i][length]) - goto error; - - *(char **)(((char *)field) + rset_field_offsets[i*2])= @@ -314,12 +312,12 @@ index e475e25..1a04b2f 100644 - field->def_length= 0; - - field->max_length= 0; -+ if (unpack_field(mysql, alloc, default_value, row, field) != 0) ++ if (unpack_field(mysql, alloc, default_value, row, field, NULL) != 0) + goto error; } if (field < result + fields) goto error; -@@ -948,8 +1014,9 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, +@@ -1118,8 +1183,9 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, MYSQL_DATA *result; MYSQL_ROWS **prev_ptr,*cur; NET *net = &mysql->net; @@ -330,7 +328,7 @@ index e475e25..1a04b2f 100644 return(0); if (!(result=(MYSQL_DATA*) calloc(1, sizeof(MYSQL_DATA)))) { -@@ -962,7 +1029,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, +@@ -1132,7 +1198,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, result->rows=0; result->fields=fields; @@ -339,7 +337,7 @@ index e475e25..1a04b2f 100644 { result->rows++; if (!(cur= (MYSQL_ROWS*) ma_alloc_root(&result->alloc, -@@ -1005,7 +1072,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, +@@ -1175,7 +1241,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, } } cur->data[field]=to; /* End of last field */ @@ -348,10 +346,10 @@ index e475e25..1a04b2f 100644 { free_rows(result); return(0); -@@ -1015,10 +1082,14 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - /* save status */ +@@ -1186,10 +1252,14 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, if (pkt_len > 1) { + unsigned int last_status= mysql->server_status; - cp++; - mysql->warning_count= uint2korr(cp); - cp+= 2; @@ -359,15 +357,15 @@ index e475e25..1a04b2f 100644 + // read the final EOF or OK packet + if (mysql->server_capabilities & CLIENT_DEPRECATE_EOF) + { -+ ma_read_ok_packet(mysql, cp + 1, pkt_len); ++ ma_read_ok_packet(mysql, cp + 1, pkt_len); + } else { -+ mysql->warning_count = uint2korr(cp + 1); -+ mysql->server_status = uint2korr(cp + 3); ++ mysql->warning_count = uint2korr(cp + 1); ++ mysql->server_status = uint2korr(cp + 3); + } + ma_status_callback(mysql, last_status) } return(result); - } -@@ -1035,15 +1106,21 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) +@@ -1207,15 +1277,21 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) uint field; ulong pkt_len,len; uchar *pos,*prev_pos, *end_pos; @@ -381,20 +379,19 @@ index e475e25..1a04b2f 100644 + // we are reading either final 'OK' or 'EOF' packet + if (mysql->net.read_pos[0] != 0 && !is_data_packet) { + unsigned int last_status= mysql->server_status; - mysql->warning_count= uint2korr(mysql->net.read_pos + 1); - mysql->server_status= uint2korr(mysql->net.read_pos + 3); -- return 1; /* End of data */ + if (mysql->server_capabilities & CLIENT_DEPRECATE_EOF) { + ma_read_ok_packet(mysql, mysql->net.read_pos + 1, pkt_len); + } else { + mysql->warning_count= uint2korr(mysql->net.read_pos + 1); + mysql->server_status= uint2korr(mysql->net.read_pos + 3); + } -+ return 1; + ma_status_callback(mysql, last_status); + return 1; /* End of data */ } - prev_pos= 0; /* allowed to write at packet[-1] */ - pos=mysql->net.read_pos; -@@ -1077,6 +1154,85 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) +@@ -1251,6 +1327,85 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) return 0; } @@ -438,27 +435,27 @@ index e475e25..1a04b2f 100644 + // read the columns info + for (f_i = 0; f_i < field_count; f_i++) + { -+ if (mthd_my_read_one_row(mysql, m_field_count, m_rows.data, m_len) == -1) -+ return NULL; -+ if (unpack_field(mysql, mem_root, 0, &m_rows, m_fields++)) -+ return NULL; ++ if (mthd_my_read_one_row(mysql, m_field_count, m_rows.data, m_len) == -1) ++ return NULL; ++ if (unpack_field(mysql, mem_root, 0, &m_rows, m_fields++, m_len)) ++ return NULL; + } + // read EOF packet in case of client not supporting 'CLIENT_DEPRECATE_EOF' + if (!(mysql->server_capabilities & CLIENT_DEPRECATE_EOF)) + { + // read the EOF packet + if (packet_error == ma_net_safe_read(mysql, NULL)) -+ return 0; ++ return 0; + -+ // verify it's actually an EOF packet -+ if (*(mysql->net.read_pos) == 254) -+ { -+ mysql->warning_count = uint2korr(mysql->net.read_pos + 1); -+ mysql->server_status = uint2korr(mysql->net.read_pos + 3); -+ } ++ // verify it's actually an EOF packet ++ if (*(mysql->net.read_pos) == 254) ++ { ++ mysql->warning_count = uint2korr(mysql->net.read_pos + 1); ++ mysql->server_status = uint2korr(mysql->net.read_pos + 3); + } ++ } + -+ return result; ++ return result; +} + +/** @@ -474,13 +471,13 @@ index e475e25..1a04b2f 100644 + */ +MYSQL_FIELD* mthd_my_read_metadata(MYSQL* mysql, ulong field_count, uint m_field_count) +{ -+ return mthd_my_read_metadata_ex(mysql, &mysql->field_alloc, field_count, m_field_count); ++ return mthd_my_read_metadata_ex(mysql, &mysql->field_alloc, field_count, m_field_count); +} + /**************************************************************************** ** Init MySQL structure or allocate one ****************************************************************************/ -@@ -1494,7 +1650,7 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, +@@ -1793,7 +1948,7 @@ restart: goto error; } */ @@ -489,7 +486,7 @@ index e475e25..1a04b2f 100644 { if (mysql->net.last_errno == CR_SERVER_LOST) my_set_error(mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN, -@@ -1596,6 +1752,16 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, +@@ -1894,6 +2049,16 @@ restart: } } @@ -506,14 +503,15 @@ index e475e25..1a04b2f 100644 /* pad 2 */ end+= 18; -@@ -2361,14 +2527,13 @@ int mthd_my_read_query_result(MYSQL *mysql) +@@ -2856,7 +3021,6 @@ int mthd_my_read_query_result(MYSQL *mysql) { uchar *pos; ulong field_count; - MYSQL_DATA *fields; ulong length; - my_bool can_local_infile= (mysql->options.extension) && (mysql->extension->auto_local_infile != WAIT_FOR_QUERY); - + const uchar *end; + uchar has_metadata; +@@ -2866,7 +3030,7 @@ int mthd_my_read_query_result(MYSQL *mysql) if (mysql->options.extension && mysql->extension->auto_local_infile == ACCEPT_FILE_REQUEST) mysql->extension->auto_local_infile= WAIT_FOR_QUERY; @@ -522,7 +520,7 @@ index e475e25..1a04b2f 100644 { return(1); } -@@ -2381,7 +2546,7 @@ get_info: +@@ -2880,7 +3044,7 @@ get_info: { int error=mysql_handle_local_infile(mysql, (char *)pos, can_local_infile); @@ -531,27 +529,34 @@ index e475e25..1a04b2f 100644 return(-1); goto get_info; /* Get info packet */ } -@@ -2389,12 +2554,13 @@ get_info: - mysql->server_status|= SERVER_STATUS_IN_TRANS; - - mysql->extra_info= net_field_length_ll(&pos); /* Maybe number of rec */ -- if (!(fields=mysql->methods->db_read_rows(mysql,(MYSQL_FIELD*) 0, -- ma_result_set_rows(mysql)))) -- return(-1); -- if (!(mysql->fields=unpack_fields(mysql, fields, &mysql->field_alloc, -- (uint) field_count, 1))) -- return(-1); -+ // read packet metadata -+ mysql->fields = -+ mthd_my_read_metadata(mysql, field_count, 7 + ma_extended_type_info_rows(mysql)); -+ if (!mysql->fields) { -+ ma_free_root(&mysql->field_alloc, MYF(0)); -+ return(1); -+ } - mysql->status=MYSQL_STATUS_GET_RESULT; - mysql->field_count=field_count; - return(0); -@@ -2775,21 +2941,17 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild) +@@ -2901,18 +3065,19 @@ get_info: + + if (has_metadata) + { +- if (!(fields= mysql->methods->db_read_rows(mysql, (MYSQL_FIELD *) 0, +- ma_result_set_rows(mysql)))) +- return (-1); +- if (!(mysql->fields= unpack_fields(mysql, fields, &mysql->field_alloc, +- (uint) field_count, 1))) +- return (-1); ++ // read packet metadata ++ mysql->fields = ++ mthd_my_read_metadata(mysql, field_count, 7 + ma_extended_type_info_rows(mysql)); ++ if (!mysql->fields) { ++ ma_free_root(&mysql->field_alloc, MYF(0)); ++ return(1); ++ } + } + else + { + unsigned int last_status= mysql->server_status; + /* Read EOF, to get the status and warning count. */ +- if ((length= ma_net_safe_read(mysql)) == packet_error) ++ if ((length= ma_net_safe_read(mysql, NULL)) == packet_error) + { + return -1; + } +@@ -3309,20 +3474,16 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild) MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql) { @@ -569,14 +574,12 @@ index e475e25..1a04b2f 100644 - return(NULL); - if (!(mysql->fields= unpack_fields(mysql, fields, &mysql->field_alloc, - field_count, 0))) -- return(NULL); + mysql->fields= mthd_my_read_metadata(mysql, field_count, 7); + if (!mysql->fields) -+ return(NULL); + return(NULL); mysql->status=MYSQL_STATUS_GET_RESULT; mysql->field_count=field_count; - return(mysql_store_result(mysql)); -@@ -4251,7 +4413,7 @@ mysql_debug(const char *debug __attribute__((unused))) +@@ -4830,7 +4991,7 @@ mysql_debug(const char *debug __attribute__((unused))) *********************************************************************/ ulong STDCALL mysql_net_read_packet(MYSQL *mysql) { @@ -586,23 +589,23 @@ index e475e25..1a04b2f 100644 ulong STDCALL mysql_net_field_length(uchar **packet) diff --git libmariadb/mariadb_rpl.c libmariadb/mariadb_rpl.c -index 6a7e0cf..492727d 100644 +index 0019f246..daa6d242 100644 --- libmariadb/mariadb_rpl.c +++ libmariadb/mariadb_rpl.c -@@ -122,7 +122,7 @@ MARIADB_RPL_EVENT * STDCALL mariadb_rpl_fetch(MARIADB_RPL *rpl, MARIADB_RPL_EVEN - return 0; +@@ -1021,7 +1021,7 @@ MARIADB_RPL_EVENT * STDCALL mariadb_rpl_fetch(MARIADB_RPL *rpl, MARIADB_RPL_EVEN - while (1) { -- unsigned long pkt_len= ma_net_safe_read(rpl->mysql); -+ unsigned long pkt_len= ma_net_safe_read(rpl->mysql, NULL); - - if (pkt_len == packet_error) + if (rpl->mysql) { +- pkt_len= ma_net_safe_read(rpl->mysql); ++ pkt_len= ma_net_safe_read(rpl->mysql, NULL); + + if (pkt_len == packet_error) + { diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c -index 0aaaf1a..229023b 100644 +index d6df0825..af442088 100644 --- libmariadb/mariadb_stmt.c +++ libmariadb/mariadb_stmt.c -@@ -78,6 +78,9 @@ typedef struct +@@ -80,6 +80,9 @@ typedef struct } MADB_STMT_EXTENSION; static my_bool net_stmt_close(MYSQL_STMT *stmt, my_bool remove); @@ -612,18 +615,19 @@ index 0aaaf1a..229023b 100644 static my_bool is_not_null= 0; static my_bool is_null= 1; -@@ -153,8 +156,9 @@ static int stmt_unbuffered_eof(MYSQL_STMT *stmt __attribute__((unused)), +@@ -171,8 +174,9 @@ static int stmt_unbuffered_eof(MYSQL_STMT *stmt __attribute__((unused)), static int stmt_unbuffered_fetch(MYSQL_STMT *stmt, uchar **row) { ulong pkt_len; -+ my_bool is_data_packet; - +- - pkt_len= ma_net_safe_read(stmt->mysql); ++ my_bool is_data_packet; ++ + pkt_len= ma_net_safe_read(stmt->mysql, &is_data_packet); if (pkt_len == packet_error) { -@@ -162,8 +166,10 @@ static int stmt_unbuffered_fetch(MYSQL_STMT *stmt, uchar **row) +@@ -180,8 +184,11 @@ static int stmt_unbuffered_fetch(MYSQL_STMT *stmt, uchar **row) return(1); } @@ -631,11 +635,12 @@ index 0aaaf1a..229023b 100644 + if (stmt->mysql->net.read_pos[0] != 0 && !is_data_packet) { + if (stmt->mysql->server_capabilities & CLIENT_DEPRECATE_EOF) -+ ma_read_ok_packet(stmt->mysql, stmt->mysql->net.read_pos + 1, pkt_len); ++ ma_read_ok_packet(stmt->mysql, stmt->mysql->net.read_pos + 1, pkt_len); ++ *row = NULL; stmt->fetch_row_func= stmt_unbuffered_eof; return(MYSQL_NO_DATA); -@@ -195,13 +201,15 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) +@@ -213,10 +220,11 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) MYSQL_ROWS *current, **pprevious; ulong packet_len; unsigned char *p; @@ -646,6 +651,11 @@ index 0aaaf1a..229023b 100644 - while ((packet_len = ma_net_safe_read(stmt->mysql)) != packet_error) + while ((packet_len = ma_net_safe_read(stmt->mysql, &is_data_packet)) != packet_error) { + // This change is required due to the new algorithm introduced in ProxySQL in #3295. + // ******************************************************************************** +@@ -237,7 +245,8 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) + // ******************************************************************************** + p= stmt->mysql->net.read_pos; - if (packet_len > 7 || p[0] != 254) + // The check is by 'ma_net_safe_read' @@ -653,15 +663,14 @@ index 0aaaf1a..229023b 100644 { /* allocate space for rows */ if (!(current= (MYSQL_ROWS *)ma_alloc_root(&result->alloc, sizeof(MYSQL_ROWS) + packet_len))) -@@ -276,10 +284,16 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) - { +@@ -324,10 +333,14 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) + unsigned int last_status= stmt->mysql->server_status; *pprevious= 0; /* sace status info */ - p++; - stmt->upsert_status.warning_count= stmt->mysql->warning_count= uint2korr(p); - p+=2; - stmt->upsert_status.server_status= stmt->mysql->server_status= uint2korr(p); -+ + if (stmt->mysql->server_capabilities & CLIENT_DEPRECATE_EOF && !is_data_packet) { + ma_read_ok_packet(stmt->mysql, p + 1, packet_len); + stmt->upsert_status.warning_count= stmt->mysql->warning_count; @@ -670,11 +679,10 @@ index 0aaaf1a..229023b 100644 + stmt->upsert_status.warning_count= stmt->mysql->warning_count= uint2korr(p + 1); + stmt->upsert_status.server_status= stmt->mysql->server_status= uint2korr(p + 3); + } -+ + ma_status_callback(stmt->mysql, last_status); stmt->result_cursor= result->data; return(0); - } -@@ -336,30 +348,52 @@ static int stmt_cursor_fetch(MYSQL_STMT *stmt, uchar **row) +@@ -388,34 +401,57 @@ static int stmt_cursor_fetch(MYSQL_STMT *stmt, uchar **row) void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt) { ulong packet_len; @@ -684,7 +692,9 @@ index 0aaaf1a..229023b 100644 - while ((packet_len = ma_net_safe_read(stmt->mysql)) != packet_error) + while ((packet_len = ma_net_safe_read(stmt->mysql, &is_data_packet)) != packet_error) { + unsigned int last_status= stmt->mysql->server_status; uchar *pos= stmt->mysql->net.read_pos; + - if (!in_resultset && *pos == 0) /* OK */ + if (stmt->mysql->server_capabilities & CLIENT_DEPRECATE_EOF) { @@ -692,22 +702,23 @@ index 0aaaf1a..229023b 100644 - net_field_length(&pos); - net_field_length(&pos); - stmt->mysql->server_status= uint2korr(pos); -- goto end; + if (!in_resultset && *pos == 0) /* OK */ + { -+ // 'ma_read_ok_packet' now updates 'server_status' -+ ma_read_ok_packet(stmt->mysql, pos + 1, packet_len); -+ goto end; ++ // 'ma_read_ok_packet' now updates 'server_status' ++ ma_read_ok_packet(stmt->mysql, pos + 1, packet_len); ++ goto end; + } + + // We got the initial ok_packet, avoid extra checks. + in_resultset = 1; + + if (*pos != 0 && !is_data_packet) { /* Final OK */ -+ // 'ma_read_ok_packet' now updates 'server_status' -+ ma_read_ok_packet(stmt->mysql, pos + 1, packet_len); -+ goto end; ++ // 'ma_read_ok_packet' now updates 'server_status' ++ ma_read_ok_packet(stmt->mysql, pos + 1, packet_len); ++ goto end; + } + ma_status_callback(stmt->mysql, last_status); + goto end; } - if (packet_len < 8 && *pos == 254) /* EOF */ + else @@ -724,6 +735,7 @@ index 0aaaf1a..229023b 100644 + if (packet_len < 8 && *pos == 254) /* EOF */ { - stmt->mysql->server_status= uint2korr(pos + 3); + ma_status_callback(stmt->mysql, last_status); - if (in_resultset) + if (mariadb_connection(stmt->mysql)) + { @@ -741,7 +753,7 @@ index 0aaaf1a..229023b 100644 } } end: -@@ -1554,7 +1588,7 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt) +@@ -1675,7 +1711,7 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt) ulong packet_length; uchar *p; @@ -750,7 +762,7 @@ index 0aaaf1a..229023b 100644 return(1); p= (uchar *)stmt->mysql->net.read_pos; -@@ -1579,28 +1613,38 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt) +@@ -1747,28 +1783,37 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt) return(0); } @@ -775,12 +787,11 @@ index 0aaaf1a..229023b 100644 - if (!(result= stmt->mysql->methods->db_read_rows(stmt->mysql, (MYSQL_FIELD *)0, - 7 + ma_extended_type_info_rows(stmt->mysql)))) + if (!(mthd_my_read_metadata_ex(stmt->mysql, &mt_alloc, stmt->param_count, -+ 7 + ma_extended_type_info_rows(stmt->mysql)))) ++ 7 + ma_extended_type_info_rows(stmt->mysql)))) return(1); - free_rows(result); + ma_free_root(&mt_alloc, MYF(0)); -+ return(0); } @@ -795,30 +806,29 @@ index 0aaaf1a..229023b 100644 - if (!(stmt->fields= unpack_fields(stmt->mysql, result, fields_ma_alloc_root, - stmt->field_count, 0))) + stmt->fields = -+ mthd_my_read_metadata_ex(stmt->mysql, fields_ma_alloc_root, stmt->field_count, -+ 7 + ma_extended_type_info_rows(stmt->mysql)); ++ mthd_my_read_metadata_ex(stmt->mysql, fields_ma_alloc_root, stmt->field_count, ++ 7 + ma_extended_type_info_rows(stmt->mysql)); + if (!(stmt->fields)) return(1); return(0); } -@@ -1871,6 +1915,12 @@ int stmt_read_execute_response(MYSQL_STMT *stmt) - if (!stmt->mysql) - return(1); - +@@ -2003,6 +2048,11 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt) + return (1); + } + } + /* + * NOTE: There is a relevant patch that should be applied in + * this section in case CURSOR support is added to ProxySQL, + * check: https://github.com/mysql/mysql-server/blob/ee4455a33b10f1b1886044322e4893f587b319ed/libmysql/libmysql.cc#L1994 + */ -+ + /* update affected rows, also if an error occurred */ stmt->upsert_status.affected_rows= stmt->mysql->affected_rows; - diff --git plugins/auth/my_auth.c plugins/auth/my_auth.c -index 0435b4f..c54c0e5 100644 +index 72773079..38e50b7a 100644 --- plugins/auth/my_auth.c +++ plugins/auth/my_auth.c -@@ -401,7 +401,7 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf) +@@ -463,7 +463,7 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf) } /* otherwise read the data */ @@ -827,7 +837,7 @@ index 0435b4f..c54c0e5 100644 return (int)packet_error; mpvio->last_read_packet_len= pkt_len; -@@ -617,7 +617,7 @@ retry: +@@ -691,7 +691,7 @@ retry: /* read the OK packet (or use the cached value in mysql->net.read_pos */ if (res == CR_OK) @@ -837,14 +847,14 @@ index 0435b4f..c54c0e5 100644 pkt_length= mpvio.last_read_packet_len; diff --git unittest/libmariadb/ps_bugs.c unittest/libmariadb/ps_bugs.c -index 25fd9f5..b1abcdd 100644 +index efe3d447..67effa26 100644 --- unittest/libmariadb/ps_bugs.c +++ unittest/libmariadb/ps_bugs.c -@@ -3931,6 +3931,10 @@ static int test_conc141(MYSQL *mysql) +@@ -3961,6 +3961,10 @@ static int test_conc141(MYSQL *mysql) rc= mysql_stmt_execute(stmt); check_stmt_rc(rc, stmt); -+ ++ + rc= mysql_stmt_free_result(stmt); + check_stmt_rc(rc, stmt); + @@ -852,20 +862,20 @@ index 25fd9f5..b1abcdd 100644 rc= mysql_stmt_next_result(stmt); FAIL_IF(rc==-1, "No more results and error expected"); diff --git unittest/libmariadb/ps_new.c unittest/libmariadb/ps_new.c -index 9b89d6f..39b93cb 100644 +index ea228f1c..38eaa0af 100644 --- unittest/libmariadb/ps_new.c +++ unittest/libmariadb/ps_new.c -@@ -105,6 +105,9 @@ static int test_multi_result(MYSQL *mysql) +@@ -108,6 +108,9 @@ static int test_multi_result(MYSQL *mysql) FAIL_IF(int_data[0] != 10 || int_data[1] != 20 || int_data[2] != 30, "expected 10 20 30"); + rc= mysql_stmt_free_result(stmt); // must call before next mysql_stmt_next_result + check_stmt_rc(rc, stmt); -+ ++ rc= mysql_stmt_next_result(stmt); check_stmt_rc(rc, stmt); rc= mysql_stmt_bind_result(stmt, rs_bind); -@@ -113,6 +116,8 @@ static int test_multi_result(MYSQL *mysql) +@@ -116,6 +119,8 @@ static int test_multi_result(MYSQL *mysql) FAIL_IF(mysql_stmt_field_count(stmt) != 3, "expected 3 fields"); FAIL_IF(int_data[0] != 100 || int_data[1] != 200 || int_data[2] != 300, "expected 100 200 300"); @@ -874,12 +884,11 @@ index 9b89d6f..39b93cb 100644 FAIL_IF(mysql_stmt_next_result(stmt) != 0, "expected more results"); rc= mysql_stmt_bind_result(stmt, rs_bind); -@@ -121,7 +126,10 @@ static int test_multi_result(MYSQL *mysql) +@@ -124,7 +129,9 @@ static int test_multi_result(MYSQL *mysql) FAIL_IF(mysql_stmt_field_count(stmt) != 2, "expected 2 fields"); FAIL_IF(int_data[0] != 200 || int_data[1] != 300, - "expected 100 200 300"); + "expected 200 300"); - -+ + rc= mysql_stmt_free_result(stmt); + check_stmt_rc(rc, stmt); + diff --git a/deps/mariadb-client-library/cmakelists.txt.patch b/deps/mariadb-client-library/cmakelists.txt.patch new file mode 100644 index 0000000000..32002b9158 --- /dev/null +++ b/deps/mariadb-client-library/cmakelists.txt.patch @@ -0,0 +1,22 @@ +diff --git CMakeLists.txt CMakeLists.txt +index d7150b4d..e8508f8f 100644 +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -286,7 +286,7 @@ ELSEIF() + ENDIF() + + IF(NOT DEFAULT_CHARSET) +- SET(DEFAULT_CHARSET "utf8mb4") ++ SET(DEFAULT_CHARSET "latin1") + ENDIF() + + +@@ -405,7 +405,7 @@ IF ((NOT WIN32) AND (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID + ELSEIF(CMAKE_C_COMPILER_ID MATCHES "MSVC") + SET(WARNING_AS_ERROR "/WX") + ENDIF() +-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_AS_ERROR}") ++#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_AS_ERROR}") + ENDIF() + + diff --git a/deps/mariadb-client-library/cr_new_stmt_metadata_removal.patch b/deps/mariadb-client-library/cr_new_stmt_metadata_removal.patch index 883ed84d2b..74f0b0bcf4 100644 --- a/deps/mariadb-client-library/cr_new_stmt_metadata_removal.patch +++ b/deps/mariadb-client-library/cr_new_stmt_metadata_removal.patch @@ -1,8 +1,8 @@ diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c -index bbc2831..2168065 100644 +index 47f0f2b6..7c6482ac 100644 --- libmariadb/mariadb_stmt.c +++ libmariadb/mariadb_stmt.c -@@ -2013,7 +2013,61 @@ int stmt_read_execute_response(MYSQL_STMT *stmt) +@@ -2098,7 +2098,61 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt) stmt->state= MYSQL_STMT_WAITING_USE_OR_STORE; /* in certain cases parameter types can change: For example see bug 4026 (SELECT ?), so we need to update field information */ @@ -19,7 +19,7 @@ index bbc2831..2168065 100644 + if (mysql->field_count != stmt->field_count) + { + MA_MEM_ROOT *fields_ma_alloc_root= -+ &((MADB_STMT_EXTENSION *)stmt->extension)->fields_ma_alloc_root; ++ &((MADB_STMT_EXTENSION *)stmt->extension)->fields_ma_alloc_root; + uint i; + + // 'ma_free_root' will free all the allocated memory for 'fields_ma_alloc_root' @@ -27,11 +27,11 @@ index bbc2831..2168065 100644 + // the required space for 'MYSQL_BIND'. + ma_free_root(fields_ma_alloc_root, MYF(0)); + if (!(stmt->bind= (MYSQL_BIND *)ma_alloc_root(fields_ma_alloc_root, -+ sizeof(MYSQL_BIND) * mysql->field_count)) || ++ sizeof(MYSQL_BIND) * mysql->field_count)) || + !(stmt->fields= (MYSQL_FIELD *)ma_alloc_root(fields_ma_alloc_root, -+ sizeof(MYSQL_FIELD) * mysql->field_count))) ++ sizeof(MYSQL_FIELD) * mysql->field_count))) + { -+ SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0); ++ stmt_set_error(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0); + return(1); + } + memset(stmt->bind, 0, sizeof(MYSQL_BIND) * mysql->field_count); @@ -65,14 +65,14 @@ index bbc2831..2168065 100644 { uint i; for (i=0; i < stmt->field_count; i++) -@@ -2025,12 +2079,8 @@ int stmt_read_execute_response(MYSQL_STMT *stmt) +@@ -2110,12 +2164,8 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt) stmt->fields[i].charsetnr= mysql->fields[i].charsetnr; stmt->fields[i].max_length= mysql->fields[i].max_length; } - } else - { - /* table was altered, see test_wl4166_2 */ -- SET_CLIENT_STMT_ERROR(stmt, CR_NEW_STMT_METADATA, SQLSTATE_UNKNOWN, 0); +- stmt_set_error(stmt, CR_NEW_STMT_METADATA, SQLSTATE_UNKNOWN, 0); - return(1); } + /*********************************************************************/ diff --git a/deps/mariadb-client-library/empty_split_compress_packet.patch b/deps/mariadb-client-library/empty_split_compress_packet.patch index 2d7aa187b6..e40d19b38d 100644 --- a/deps/mariadb-client-library/empty_split_compress_packet.patch +++ b/deps/mariadb-client-library/empty_split_compress_packet.patch @@ -1,8 +1,8 @@ diff --git libmariadb/ma_net.c libmariadb/ma_net.c -index 15be4fc..39a8138 100644 +index 2e932b17..0b1d0cce 100644 --- libmariadb/ma_net.c +++ libmariadb/ma_net.c -@@ -498,6 +498,7 @@ ulong ma_net_read(NET *net) +@@ -510,6 +510,7 @@ ulong ma_net_read(NET *net) { current+= 4; /* length + sequence_id, no more data will follow */ diff --git a/deps/mariadb-client-library/ma_alloc.c.patch b/deps/mariadb-client-library/ma_alloc.c.patch index 8464897ba9..f5fe53d07f 100644 --- a/deps/mariadb-client-library/ma_alloc.c.patch +++ b/deps/mariadb-client-library/ma_alloc.c.patch @@ -1,9 +1,13 @@ -@@ -85,7 +85,7 @@ +diff --git libmariadb/ma_alloc.c libmariadb/ma_alloc.c +index d6db279e..4526fef0 100644 +--- libmariadb/ma_alloc.c ++++ libmariadb/ma_alloc.c +@@ -86,7 +86,7 @@ void * ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size) if (! next) { /* Time to alloc new block */ get_size= MAX(Size+ALIGN_SIZE(sizeof(MA_USED_MEM)), - (mem_root->block_size & ~1) * (mem_root->block_num >> 2)); -+ (mem_root->block_size & ~1) * ( (mem_root->block_num >> 2) < 4 ? 4 : (mem_root->block_num >> 2) ) ); ++ (mem_root->block_size & ~1) * ((mem_root->block_num >> 2) < 4 ? 4 : (mem_root->block_num >> 2))); if (!(next = (MA_USED_MEM*) malloc(get_size))) { diff --git a/deps/mariadb-client-library/ma_array.c-multiplication-overflow.patch b/deps/mariadb-client-library/ma_array.c-multiplication-overflow.patch index 76bcb496ff..80e20be2bd 100644 --- a/deps/mariadb-client-library/ma_array.c-multiplication-overflow.patch +++ b/deps/mariadb-client-library/ma_array.c-multiplication-overflow.patch @@ -1,4 +1,8 @@ -@@ -46,7 +46,7 @@ +diff --git libmariadb/ma_array.c libmariadb/ma_array.c +index d067aa4a..81fc3c40 100644 +--- libmariadb/ma_array.c ++++ libmariadb/ma_array.c +@@ -46,7 +46,7 @@ my_bool ma_init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, array->max_element=init_alloc; array->alloc_increment=alloc_increment; array->size_of_element=element_size; @@ -7,7 +11,7 @@ { array->max_element=0; return(TRUE); -@@ -80,7 +80,7 @@ +@@ -80,7 +80,7 @@ unsigned char *ma_alloc_dynamic(DYNAMIC_ARRAY *array) if (array->elements == array->max_element) { char *new_ptr; @@ -16,7 +20,7 @@ array->alloc_increment)* array->size_of_element))) return 0; -@@ -111,14 +111,14 @@ +@@ -111,14 +111,14 @@ my_bool ma_set_dynamic(DYNAMIC_ARRAY *array, void * element, uint idx) char *new_ptr; size=(idx+array->alloc_increment)/array->alloc_increment; size*= array->alloc_increment; @@ -33,7 +37,7 @@ array->elements=idx+1; } memcpy(array->buffer+(idx * array->size_of_element),element, -@@ -155,7 +155,7 @@ +@@ -155,7 +155,7 @@ void ma_delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx) char *ptr=array->buffer+array->size_of_element*idx; array->elements--; memmove(ptr,ptr+array->size_of_element, @@ -42,7 +46,7 @@ } -@@ -166,7 +166,7 @@ +@@ -166,7 +166,7 @@ void ma_freeze_size(DYNAMIC_ARRAY *array) if (array->buffer && array->max_element != elements) { array->buffer=(char*) realloc(array->buffer, diff --git a/deps/mariadb-client-library/ma_charset.c.patch b/deps/mariadb-client-library/ma_charset.c.patch index 765d47da6f..9892f4cb5f 100644 --- a/deps/mariadb-client-library/ma_charset.c.patch +++ b/deps/mariadb-client-library/ma_charset.c.patch @@ -1,4 +1,17 @@ -@@ -720,7 +720,7 @@ +diff --git libmariadb/ma_charset.c libmariadb/ma_charset.c +index f6ed6f80..4a1207f1 100644 +--- libmariadb/ma_charset.c ++++ libmariadb/ma_charset.c +@@ -542,7 +542,7 @@ static unsigned int check_mb_gb18030_valid(const char * start, const char * end) + */ + + #define UTF8_MB4 "utf8mb4" +-#define UTF8_MB3 "utf8mb3" ++#define UTF8_MB3 "utf8" + + /* {{{ mysql_charsets */ + const MARIADB_CHARSET_INFO mariadb_compiled_charsets[] = +@@ -722,7 +722,7 @@ const MARIADB_CHARSET_INFO mariadb_compiled_charsets[] = { 182, 1, "utf32", "utf32_unicode_520_ci", "", 0, "UTF32", 4, 4, mysql_mbcharlen_utf32, check_mb_utf32}, { 183, 1, "utf32", "utf32_vietnamese_ci", "", 0, "UTF32", 4, 4, mysql_mbcharlen_utf32, check_mb_utf32}, @@ -7,3 +20,13 @@ { 193, 1, UTF8_MB3, UTF8_MB3"_icelandic_ci", "", 65001, "UTF-8", 1, 3, mysql_mbcharlen_utf8mb3, check_mb_utf8mb3_valid}, { 194, 1, UTF8_MB3, UTF8_MB3"_latvian_ci", "", 65001, "UTF-8", 1, 3, mysql_mbcharlen_utf8mb3, check_mb_utf8mb3_valid}, { 195, 1, UTF8_MB3, UTF8_MB3"_romanian_ci", "", 65001, "UTF-8", 1, 3, mysql_mbcharlen_utf8mb3, check_mb_utf8mb3_valid}, +@@ -1083,9 +1083,6 @@ MARIADB_CHARSET_INFO * mysql_find_charset_name(const char *name) + else + csname= (char *)name; + +- if (!strcasecmp("utf8",csname)) +- csname= "utf8mb3"; +- + do { + if (!strcasecmp(c->csname, csname)) { + return(c); diff --git a/deps/mariadb-client-library/ma_common.h.sslkeylogfile.patch b/deps/mariadb-client-library/ma_common.h.sslkeylogfile.patch deleted file mode 100644 index af13a9449c..0000000000 --- a/deps/mariadb-client-library/ma_common.h.sslkeylogfile.patch +++ /dev/null @@ -1,14 +0,0 @@ -@@ -78,12 +78,13 @@ - my_bool (*set_option)(MYSQL *mysql, const char *config_option, const char *config_value); - HASH userdata; - char *server_public_key; - char *proxy_header; - size_t proxy_header_len; - int (*io_wait)(my_socket handle, my_bool is_read, int timeout); -+ void (*ssl_keylog_callback)(const void *ssl, const char *line); - }; - - typedef struct st_connection_handler - { - struct st_ma_connection_plugin *plugin; - void *data; diff --git a/deps/mariadb-client-library/ma_context.h.patch b/deps/mariadb-client-library/ma_context.h.patch index 2aae87324f..6ac91adb2e 100644 --- a/deps/mariadb-client-library/ma_context.h.patch +++ b/deps/mariadb-client-library/ma_context.h.patch @@ -1,4 +1,8 @@ -@@ -25,6 +25,8 @@ +diff --git include/ma_context.h include/ma_context.h +index 0ad7f68b..ad26a721 100644 +--- include/ma_context.h ++++ include/ma_context.h +@@ -26,6 +26,8 @@ (This particular implementation uses Posix ucontext swapcontext().) */ diff --git a/deps/mariadb-client-library/ma_password.c.patch b/deps/mariadb-client-library/ma_password.c.patch index d6300c0bb1..a1d30811ef 100644 --- a/deps/mariadb-client-library/ma_password.c.patch +++ b/deps/mariadb-client-library/ma_password.c.patch @@ -1,56 +1,56 @@ -@@ -98,6 +98,35 @@ +diff --git libmariadb/ma_password.c libmariadb/ma_password.c +index eb6fe6a8..b327bf61 100644 +--- libmariadb/ma_password.c ++++ libmariadb/ma_password.c +@@ -98,6 +98,33 @@ void my_crypt(unsigned char *buffer, const unsigned char *s1, const unsigned cha } } +unsigned char decode_char(char x) { -+ if (x >= '0' && x <= '9') -+ return (x - 0x30); -+ else if (x >= 'A' && x <= 'F') -+ return(x - 0x37); -+ else if (x >= 'a' && x <= 'f') -+ return(x - 0x57); -+ else { -+ fprintf(stderr,"%s:%d:%s(): [ERROR in libmariadbclient]: \n", __FILE__, __LINE__, __func__); -+ return 0; -+ } ++ if (x >= '0' && x <= '9') ++ return (x - 0x30); ++ else if (x >= 'A' && x <= 'F') ++ return(x - 0x37); ++ else if (x >= 'a' && x <= 'f') ++ return(x - 0x57); ++ else { ++ fprintf(stderr,"%s:%d:%s(): [ERROR in libmariadbclient]: \n", __FILE__, __LINE__, __func__); ++ return 0; ++ } +} + +void unhex_pass(unsigned char *out, const char *in) { -+ int i=0; -+ for (i=0;iextension->mariadb_server_capabilities) & - (MARIADB_CLIENT_EXTENDED_METADATA >> 32)) != 0; diff --git a/deps/mariadb-client-library/mariadb-connector-c-3.1.9-src.tar.gz b/deps/mariadb-client-library/mariadb-connector-c-3.1.9-src.tar.gz deleted file mode 100644 index 0d0e3e6e29..0000000000 Binary files a/deps/mariadb-client-library/mariadb-connector-c-3.1.9-src.tar.gz and /dev/null differ diff --git a/deps/mariadb-client-library/mariadb-connector-c-3.3.8-src.tar.gz b/deps/mariadb-client-library/mariadb-connector-c-3.3.8-src.tar.gz new file mode 100644 index 0000000000..9389ee0624 Binary files /dev/null and b/deps/mariadb-client-library/mariadb-connector-c-3.3.8-src.tar.gz differ diff --git a/deps/mariadb-client-library/mariadb_asan.patch b/deps/mariadb-client-library/mariadb_asan.patch index ce675f06b3..cb9c9a6440 100644 --- a/deps/mariadb-client-library/mariadb_asan.patch +++ b/deps/mariadb-client-library/mariadb_asan.patch @@ -1,8 +1,8 @@ diff --git CMakeLists.txt CMakeLists.txt -index 568e4f5..cfac85b 100644 +index 206e4e03..d7150b4d 100644 --- CMakeLists.txt +++ CMakeLists.txt -@@ -136,6 +136,10 @@ SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") +@@ -131,6 +131,10 @@ 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") @@ -12,4 +12,4 @@ index 568e4f5..cfac85b 100644 + IF(CMAKE_COMPILER_IS_GNUCC) INCLUDE(CheckCCompilerFlag) - SET(GCC_FLAGS -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas) + SET(GCC_FLAGS -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas -Wno-stringop-truncation) diff --git a/deps/mariadb-client-library/mariadb_async.c.patch b/deps/mariadb-client-library/mariadb_async.c.patch index 09461aa752..12301dfbde 100644 --- a/deps/mariadb-client-library/mariadb_async.c.patch +++ b/deps/mariadb-client-library/mariadb_async.c.patch @@ -1,4 +1,8 @@ -@@ -479,19 +479,20 @@ +diff --git libmariadb/mariadb_async.c libmariadb/mariadb_async.c +index feb73329..f2fba5d4 100644 +--- libmariadb/mariadb_async.c ++++ libmariadb/mariadb_async.c +@@ -479,19 +479,20 @@ MK_ASYNC_CONT_BODY( struct mysql_set_character_set_params { MYSQL *mysql; const char *csname; @@ -21,7 +25,7 @@ { MK_ASYNC_START_BODY( mysql_set_character_set, -@@ -500,6 +501,7 @@ +@@ -500,6 +501,7 @@ MK_ASYNC_START_BODY( WIN_SET_NONBLOCKING(mysql) parms.mysql= mysql; parms.csname= csname; diff --git a/deps/mariadb-client-library/mariadb_client b/deps/mariadb-client-library/mariadb_client index 8ea53d8c52..718a3e0a19 120000 --- a/deps/mariadb-client-library/mariadb_client +++ b/deps/mariadb-client-library/mariadb_client @@ -1 +1 @@ -mariadb-connector-c-3.1.9-src \ No newline at end of file +mariadb-connector-c-3.3.8-src \ No newline at end of file diff --git a/deps/mariadb-client-library/mariadb_com.h.patch b/deps/mariadb-client-library/mariadb_com.h.patch index f24c5ad3b1..31c32fa015 100644 --- a/deps/mariadb-client-library/mariadb_com.h.patch +++ b/deps/mariadb-client-library/mariadb_com.h.patch @@ -1,15 +1,19 @@ -@@ -178,8 +178,8 @@ +diff --git include/mariadb_com.h include/mariadb_com.h +index 96e6e04f..7acc7403 100644 +--- include/mariadb_com.h ++++ include/mariadb_com.h +@@ -183,9 +183,7 @@ enum enum_server_command + (!(mysql->server_capabilities & CLIENT_MYSQL)) #define MARIADB_CLIENT_SUPPORTED_FLAGS (MARIADB_CLIENT_PROGRESS |\ - MARIADB_CLIENT_COM_MULTI |\ - MARIADB_CLIENT_STMT_BULK_OPERATIONS|\ -- MARIADB_CLIENT_EXTENDED_METADATA) -+ MARIADB_CLIENT_STMT_BULK_OPERATIONS\ -+ ) +- MARIADB_CLIENT_EXTENDED_METADATA|\ +- MARIADB_CLIENT_CACHE_METADATA) ++ MARIADB_CLIENT_STMT_BULK_OPERATIONS) #define CLIENT_SUPPORTED_FLAGS (CLIENT_MYSQL |\ CLIENT_FOUND_ROWS |\ -@@ -210,8 +210,6 @@ +@@ -221,8 +219,6 @@ enum enum_server_command CLIENT_LONG_FLAG |\ CLIENT_TRANSACTIONS |\ CLIENT_SECURE_CONNECTION |\ @@ -17,4 +21,4 @@ - CLIENT_PS_MULTI_RESULTS |\ CLIENT_PROTOCOL_41 |\ CLIENT_PLUGIN_AUTH |\ - CLIENT_SESSION_TRACKING |\ \ No newline at end of file + CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \ diff --git a/deps/mariadb-client-library/mariadb_dyncol.c-multiplication-overflow.patch b/deps/mariadb-client-library/mariadb_dyncol.c-multiplication-overflow.patch index 7df44d4e5a..8264af5d2a 100644 --- a/deps/mariadb-client-library/mariadb_dyncol.c-multiplication-overflow.patch +++ b/deps/mariadb-client-library/mariadb_dyncol.c-multiplication-overflow.patch @@ -1,4 +1,8 @@ -@@ -3999,13 +3999,13 @@ +diff --git libmariadb/mariadb_dyncol.c libmariadb/mariadb_dyncol.c +index 42de69ee..6b040d11 100644 +--- libmariadb/mariadb_dyncol.c ++++ libmariadb/mariadb_dyncol.c +@@ -4000,13 +4000,13 @@ mariadb_dyncol_val_long(longlong *ll, DYNAMIC_COLUMN_VALUE *val) (val->x.time_value.neg ? -1 : 1); break; case DYN_COL_DATE: diff --git a/deps/mariadb-client-library/mariadb_lib.c.collation.patch b/deps/mariadb-client-library/mariadb_lib.c.collation.patch index 3ee686ed63..6ae8090974 100644 --- a/deps/mariadb-client-library/mariadb_lib.c.collation.patch +++ b/deps/mariadb-client-library/mariadb_lib.c.collation.patch @@ -1,4 +1,8 @@ -@@ -1109,7 +1109,10 @@ mysql_init(MYSQL *mysql) +diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c +index 66b44df4..c9aec200 100644 +--- libmariadb/mariadb_lib.c ++++ libmariadb/mariadb_lib.c +@@ -1283,7 +1283,10 @@ mysql_init(MYSQL *mysql) goto error; mysql->options.report_data_truncation= 1; mysql->options.connect_timeout=CONNECT_TIMEOUT; @@ -10,7 +14,7 @@ mysql->methods= &MARIADB_DEFAULT_METHODS; strcpy(mysql->net.sqlstate, "00000"); mysql->net.last_error[0]= mysql->net.last_errno= mysql->net.extension->extended_errno= 0; -@@ -1625,11 +1628,15 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql +@@ -1918,11 +1921,15 @@ restart: } } @@ -31,7 +35,7 @@ if (!mysql->charset) { -@@ -1892,10 +1899,16 @@ my_bool STDCALL mysql_change_user(MYSQL +@@ -2208,10 +2215,16 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, *s_db= mysql->db; int rc; @@ -52,7 +56,7 @@ mysql->user= strdup(user ? user : ""); mysql->passwd= strdup(passwd ? passwd : ""); -@@ -2963,6 +2976,12 @@ mysql_optionsv(MYSQL *mysql,enum mysql_o +@@ -3492,6 +3505,12 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) OPT_SET_VALUE_STR(&mysql->options, charset_dir, arg1); break; case MYSQL_SET_CHARSET_NAME: diff --git a/deps/mariadb-client-library/mariadb_lib.c.ipv6_fix.patch b/deps/mariadb-client-library/mariadb_lib.c.ipv6_fix.patch index b9ea4be5c9..8e76009de5 100644 --- a/deps/mariadb-client-library/mariadb_lib.c.ipv6_fix.patch +++ b/deps/mariadb-client-library/mariadb_lib.c.ipv6_fix.patch @@ -1,23 +1,15 @@ -@@ -1615,6 +1615,11 @@ - if (ma_pvio_connect(pvio, &cinfo) != 0) - { - ma_pvio_close(pvio); -+ if (mysql->options.extension && mysql->options.extension->async_context && -+ mysql->options.extension->async_context->pvio) { -+ /* async_context->pvio contains dangling pointer. Setting async_context->pvio to NULL*/ -+ mysql->options.extension->async_context->pvio = NULL; -+ } - goto error; - } - -@@ -1625,6 +1630,11 @@ +diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c +index c9aec200..be4c91d1 100644 +--- libmariadb/mariadb_lib.c ++++ libmariadb/mariadb_lib.c +@@ -1752,6 +1752,11 @@ restart: if (ma_pvio_write(pvio, (unsigned char *)hdr, len) <= 0) { ma_pvio_close(pvio); + if (mysql->options.extension->async_context && -+ mysql->options.extension->async_context->pvio) { -+ /* async_context->pvio contains dangling pointer. Setting async_context->pvio to NULL*/ -+ mysql->options.extension->async_context->pvio = NULL; ++ mysql->options.extension->async_context->pvio) { ++ /* async_context->pvio contains dangling pointer. Invalidatng pvio pointer in the async context*/ ++ mysql->options.extension->async_context->pvio = NULL; + } goto error; } diff --git a/deps/mariadb-client-library/mariadb_lib.c.patch b/deps/mariadb-client-library/mariadb_lib.c.patch index 6db5e05a00..ab3bbaf2c3 100644 --- a/deps/mariadb-client-library/mariadb_lib.c.patch +++ b/deps/mariadb-client-library/mariadb_lib.c.patch @@ -1,41 +1,45 @@ diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c -index 8c2a99b..cf6114a 100644 +index e8db51a0..684aff1a 100644 --- libmariadb/mariadb_lib.c +++ libmariadb/mariadb_lib.c -@@ -1643,9 +1643,16 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, +@@ -1936,10 +1936,16 @@ restart: mysql->client_flag= client_flag; -+ { -+ volatile my_bool net_blocking = ma_pvio_is_blocking(net->pvio); -+ if (!net_blocking) -+ ma_pvio_blocking(net->pvio, TRUE, 0); - if (run_plugin_auth(mysql, scramble_data, scramble_len, - scramble_plugin, db)) - goto error; -+ if (!net_blocking) -+ ma_pvio_blocking(net->pvio, FALSE, 0); -+ } - - if (mysql->client_flag & CLIENT_COMPRESS) - net->compress= 1; -@@ -1696,6 +1703,15 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, +- if (run_plugin_auth(mysql, scramble_data, scramble_len, +- scramble_plugin, db)) +- goto error; +- ++ { ++ volatile my_bool net_blocking = ma_pvio_is_blocking(net->pvio); ++ if (!net_blocking) ++ ma_pvio_blocking(net->pvio, TRUE, 0); ++ if (run_plugin_auth(mysql, scramble_data, scramble_len, ++ scramble_plugin, db)) ++ goto error; ++ if (!net_blocking) ++ ma_pvio_blocking(net->pvio, FALSE, 0); ++ } + if (mysql->client_flag & CLIENT_COMPRESS || + mysql->client_flag & CLIENT_ZSTD_COMPRESSION) + { +@@ -2006,6 +2012,15 @@ restart: return(mysql); error: + // fix for proxysql bug #2623 + if (mysql->net.extension) { -+ free(mysql->net.extension); -+ mysql->net.extension=NULL; ++ free(mysql->net.extension); ++ mysql->net.extension=NULL; + } + if (mysql->extension) { -+ free(mysql->extension); -+ mysql->extension=NULL; ++ free(mysql->extension); ++ mysql->extension=NULL; + } - /* Free alloced memory */ - end_server(mysql); - /* only free the allocated memory, user needs to call mysql_close */ -@@ -1775,7 +1791,7 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql) + /* Free allocated memory */ + free(host_list); + free(host_copy); +@@ -2087,7 +2102,7 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql) if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, mysql->db, mysql->port, mysql->unix_socket, mysql->client_flag | CLIENT_REMEMBER_OPTIONS) || @@ -44,23 +48,28 @@ index 8c2a99b..cf6114a 100644 { if (ctxt) my_context_install_suspend_resume_hook(ctxt, NULL, NULL); -@@ -1821,6 +1837,7 @@ void ma_invalidate_stmts(MYSQL *mysql, const char *function_name) +@@ -2134,10 +2149,11 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql) + return(0); + } + +-void ma_invalidate_stmts(MYSQL *mysql, const char *function_name) ++void ma_invalidate_stmts(MYSQL *mysql, const char *function_name __attribute__((unused))) { if (mysql->stmts) { -+/* ++ /* LIST *li_stmt= mysql->stmts; for (; li_stmt; li_stmt= li_stmt->next) -@@ -1829,6 +1846,7 @@ void ma_invalidate_stmts(MYSQL *mysql, const char *function_name) +@@ -2146,6 +2162,7 @@ void ma_invalidate_stmts(MYSQL *mysql, const char *function_name) stmt->mysql= NULL; - SET_CLIENT_STMT_ERROR(stmt, CR_STMT_CLOSED, SQLSTATE_UNKNOWN, function_name); + stmt_set_error(stmt, CR_STMT_CLOSED, SQLSTATE_UNKNOWN, 0, function_name); } -+*/ ++ */ mysql->stmts= NULL; } } -@@ -2115,6 +2133,44 @@ mysql_close(MYSQL *mysql) +@@ -2458,6 +2475,42 @@ mysql_close(MYSQL *mysql) return; } @@ -69,28 +78,27 @@ index 8c2a99b..cf6114a 100644 +{ + if (mysql) /* Some simple safety */ + { -+ + if (mysql->methods) { -+ if (mysql->net.pvio) { -+ free_old_query(mysql); -+ mysql->status=MYSQL_STATUS_READY; /* Force command */ -+ mysql->options.reconnect=0; -+ end_server(mysql); -+ } -+ } ++ if (mysql->net.pvio) { ++ free_old_query(mysql); ++ mysql->status=MYSQL_STATUS_READY; /* Force command */ ++ mysql->options.reconnect=0; ++ end_server(mysql); ++ } ++ } + mysql_close_memory(mysql); + mysql_close_options(mysql); + mysql->host_info=mysql->user=mysql->passwd=mysql->db=0; + + // fix for proxysql bug #3204 + if (mysql->net.extension) { -+ free(mysql->net.extension); -+ mysql->net.extension=NULL; ++ free(mysql->net.extension); ++ mysql->net.extension=NULL; + } + + if (mysql->extension) { -+ free(mysql->extension); -+ mysql->extension=NULL; ++ free(mysql->extension); ++ mysql->extension=NULL; + } + + /* Clear pointers for better safety */ @@ -101,20 +109,10 @@ index 8c2a99b..cf6114a 100644 + } + return; +} -+ /************************************************************************** ** Do a query. If query returned rows, free old rows. -@@ -2189,6 +2245,8 @@ int ma_read_ok_packet(MYSQL *mysql, uchar *pos, ulong length) - char *data; - si_type= (enum enum_session_state_type)net_field_length(&pos); - switch(si_type) { -+ case SESSION_TRACK_GTIDS: -+ net_field_length(&pos); /* skip encoding */ - case SESSION_TRACK_SCHEMA: - case SESSION_TRACK_STATE_CHANGE: - case SESSION_TRACK_TRANSACTION_CHARACTERISTICS: -@@ -3670,18 +3728,27 @@ void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs) +@@ -4237,18 +4290,27 @@ void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs) mariadb_get_charset_info(mysql, cs); } @@ -147,11 +145,15 @@ index 8c2a99b..cf6114a 100644 if (!mysql_real_query(mysql, buff, (unsigned long)strlen(buff))) { mysql->charset= cs; -@@ -3691,6 +3758,7 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname) +@@ -4258,8 +4320,9 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname) } error: +- my_set_error(mysql, CR_CANT_READ_CHARSET, SQLSTATE_UNKNOWN, +- 0, csname, "compiled_in"); + if (!cs) - my_set_error(mysql, CR_CANT_READ_CHARSET, SQLSTATE_UNKNOWN, - 0, csname, "compiled_in"); ++ my_set_error(mysql, CR_CANT_READ_CHARSET, SQLSTATE_UNKNOWN, ++ 0, csname, "compiled_in"); return(mysql->net.last_errno); + } + diff --git a/deps/mariadb-client-library/mariadb_lib.c.sslkeylogfile.patch b/deps/mariadb-client-library/mariadb_lib.c.sslkeylogfile.patch deleted file mode 100644 index e0245b5828..0000000000 --- a/deps/mariadb-client-library/mariadb_lib.c.sslkeylogfile.patch +++ /dev/null @@ -1,32 +0,0 @@ -@@ -3277,12 +3277,15 @@ - case MYSQL_OPT_SSL_CRL: - OPT_SET_EXTENDED_VALUE_STR(&mysql->options, ssl_crl, (char *)arg1); - break; - case MYSQL_OPT_SSL_CRLPATH: - OPT_SET_EXTENDED_VALUE_STR(&mysql->options, ssl_crlpath, (char *)arg1); - break; -+ case MARIADB_OPT_SSL_KEYLOG_CALLBACK: -+ OPT_SET_EXTENDED_VALUE(&mysql->options, ssl_keylog_callback, arg1); -+ break; - case MYSQL_OPT_CONNECT_ATTR_DELETE: - { - uchar *h; - CHECK_OPT_EXTENSION_SET(&mysql->options); - if (hash_inited(&mysql->options.extension->connect_attrs) && - (h= (uchar *)hash_search(&mysql->options.extension->connect_attrs, (uchar *)arg1, -@@ -3614,12 +3617,15 @@ - case MYSQL_OPT_SSL_CRL: - *((char **)arg)= mysql->options.extension ? mysql->options.ssl_cipher : NULL; - break; - case MYSQL_OPT_SSL_CRLPATH: - *((char **)arg)= mysql->options.extension ? mysql->options.extension->ssl_crlpath : NULL; - break; -+ case MARIADB_OPT_SSL_KEYLOG_CALLBACK: -+ *((void(**)(const void *, const char *))arg)= mysql->options.extension ? mysql->options.extension->ssl_keylog_callback : NULL; -+ break; - case MYSQL_OPT_CONNECT_ATTRS: - /* mysql_get_optionsv(mysql, MYSQL_OPT_CONNECT_ATTRS, keys, vals, elements) */ - { - unsigned int i, *elements; - char **key= NULL; - void *arg1; diff --git a/deps/mariadb-client-library/mariadb_lib.c.x509cache.patch b/deps/mariadb-client-library/mariadb_lib.c.x509cache.patch deleted file mode 100644 index 1cbae13819..0000000000 --- a/deps/mariadb-client-library/mariadb_lib.c.x509cache.patch +++ /dev/null @@ -1,32 +0,0 @@ -@@ -127,6 +127,11 @@ - uint mysql_port=0; - my_string mysql_unix_port=0; - -+#include -+extern __thread SSL_CTX * thread_ctx; -+extern __thread char **local_x509_files; -+extern __thread char **local_x509_sha1s; -+ - #define CONNECT_TIMEOUT 0 - - struct st_mariadb_methods MARIADB_DEFAULT_METHODS; -@@ -4078,6 +4083,19 @@ - - void STDCALL mysql_thread_end(void) - { -+ if (local_x509_files != NULL) { -+ int i; -+ for (i=0; local_x509_files[i] != NULL ; i++) { -+ free(local_x509_files[i]); -+ free(local_x509_sha1s[i]); -+ } -+ free(local_x509_files); -+ free(local_x509_sha1s); -+ } -+ if (thread_ctx != NULL) { -+ SSL_CTX_free(thread_ctx); -+ thread_ctx = NULL; -+ } - } - - int STDCALL mysql_set_server_option(MYSQL *mysql, diff --git a/deps/mariadb-client-library/mariadb_rpl.c.patch b/deps/mariadb-client-library/mariadb_rpl.c.patch deleted file mode 100644 index cbdd85c744..0000000000 --- a/deps/mariadb-client-library/mariadb_rpl.c.patch +++ /dev/null @@ -1,16 +0,0 @@ -@@ -386,6 +386,15 @@ - memcpy(rpl_event->event.rows.row_data, ev, rpl_event->event.rows.row_data_size); - } - break; -+ case PREVIOUS_GTIDS_LOG_EVENT: -+ case ANONYMOUS_GTID_LOG_EVENT: -+ case WRITE_ROWS_EVENT: -+ case UPDATE_ROWS_EVENT: -+ case DELETE_ROWS_EVENT: -+ case GTID_LOG_EVENT: -+ case HEARTBEAT_LOG_EVENT_V2: -+ case ROWS_QUERY_LOG_EVENT: -+ break; - default: - free(rpl_event); - return NULL; diff --git a/deps/mariadb-client-library/mariadb_rpl.h.patch b/deps/mariadb-client-library/mariadb_rpl.h.patch deleted file mode 100644 index 039536ef51..0000000000 --- a/deps/mariadb-client-library/mariadb_rpl.h.patch +++ /dev/null @@ -1,9 +0,0 @@ -@@ -94,6 +94,8 @@ - VIEW_CHANGE_EVENT= 37, - XA_PREPARE_LOG_EVENT= 38, - -+ HEARTBEAT_LOG_EVENT_V2 = 41, -+ - /* - Add new events here - right above this comment! - Existing events (except ENUM_END_EVENT) should never change their numbers diff --git a/deps/mariadb-client-library/mariadb_rpl.patch b/deps/mariadb-client-library/mariadb_rpl.patch new file mode 100644 index 0000000000..70c1eff114 --- /dev/null +++ b/deps/mariadb-client-library/mariadb_rpl.patch @@ -0,0 +1,29 @@ +diff --git include/mariadb_rpl.h include/mariadb_rpl.h +index ea0ca4db..697e5684 100644 +--- include/mariadb_rpl.h ++++ include/mariadb_rpl.h +@@ -134,7 +134,8 @@ enum mariadb_rpl_event { + VIEW_CHANGE_EVENT= 37, + XA_PREPARE_LOG_EVENT= 38, + PARTIAL_UPDATE_ROWS_EVENT = 39, +- ++ HEARTBEAT_LOG_EVENT_V2 = 41, ++ + /* + Add new events here - right above this comment! + Existing events (except ENUM_END_EVENT) should never change their numbers +diff --git libmariadb/mariadb_rpl.c libmariadb/mariadb_rpl.c +index daa6d242..dd3f905c 100644 +--- libmariadb/mariadb_rpl.c ++++ libmariadb/mariadb_rpl.c +@@ -1888,6 +1888,9 @@ MARIADB_RPL_EVENT * STDCALL mariadb_rpl_fetch(MARIADB_RPL *rpl, MARIADB_RPL_EVEN + } + break; + } ++ case ROWS_QUERY_LOG_EVENT: ++ case HEARTBEAT_LOG_EVENT_V2: ++ break; + default: + /* We need to report an error if this event can't be ignored */ + if (!(rpl_event->flags & LOG_EVENT_IGNORABLE_F)) + diff --git a/deps/mariadb-client-library/mariadb_stmt.c.patch b/deps/mariadb-client-library/mariadb_stmt.c.patch index e9fdf69487..cb4b4f86d7 100644 --- a/deps/mariadb-client-library/mariadb_stmt.c.patch +++ b/deps/mariadb-client-library/mariadb_stmt.c.patch @@ -1,4 +1,8 @@ -@@ -131,6 +131,7 @@ my_bool mthd_supported_buffer_type(enum +diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c +index 5bcecfde..47f0f2b6 100644 +--- libmariadb/mariadb_stmt.c ++++ libmariadb/mariadb_stmt.c +@@ -149,6 +149,7 @@ my_bool mthd_supported_buffer_type(enum enum_field_types type) case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY_BLOB: @@ -6,7 +10,7 @@ case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_YEAR: return 1; -@@ -1229,6 +1230,7 @@ my_bool STDCALL mysql_stmt_bind_param(MY +@@ -1332,6 +1333,7 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind) break; case MYSQL_TYPE_STRING: case MYSQL_TYPE_JSON: diff --git a/deps/mariadb-client-library/mariadb_stmt_store_result_err.patch b/deps/mariadb-client-library/mariadb_stmt_store_result_err.patch index ac493d3299..4b49c428e4 100644 --- a/deps/mariadb-client-library/mariadb_stmt_store_result_err.patch +++ b/deps/mariadb-client-library/mariadb_stmt_store_result_err.patch @@ -1,13 +1,13 @@ diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c -index ba1617b..1c8d2e6 100644 +index 40a8ded1..d6df0825 100644 --- libmariadb/mariadb_stmt.c +++ libmariadb/mariadb_stmt.c -@@ -1838,6 +1838,9 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) +@@ -1903,6 +1903,9 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) stmt->result.data= NULL; stmt->result.rows= 0; stmt->mysql->status= MYSQL_STATUS_READY; + /* In case of error, stmt internal state needs to be reset. Otherwise state machine could be left in an -+ inconsistent state and further calls to 'mysql_stmt_execute' will halt. */ ++ inconsistent state and further calls to 'mysql_stmt_execute' will halt. */ + stmt->state= MYSQL_STMT_FETCH_DONE; return(1); } diff --git a/deps/mariadb-client-library/mysql.h.patch b/deps/mariadb-client-library/mysql.h.patch index ce8c6115da..60d293dc78 100644 --- a/deps/mariadb-client-library/mysql.h.patch +++ b/deps/mariadb-client-library/mysql.h.patch @@ -1,4 +1,8 @@ -@@ -517,7 +517,7 @@ +diff --git include/mysql.h include/mysql.h +index 76b16830..9ee86227 100644 +--- include/mysql.h ++++ include/mysql.h +@@ -531,7 +531,7 @@ const char * STDCALL mysql_info(MYSQL *mysql); unsigned long STDCALL mysql_thread_id(MYSQL *mysql); const char * STDCALL mysql_character_set_name(MYSQL *mysql); void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs); @@ -7,7 +11,7 @@ my_bool mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *arg, ...); my_bool STDCALL mariadb_get_info(MYSQL *mysql, enum mariadb_value value, void *arg); -@@ -536,6 +536,7 @@ +@@ -550,6 +550,7 @@ MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, const char *unix_socket, unsigned long clientflag); void STDCALL mysql_close(MYSQL *sock); @@ -15,7 +19,7 @@ int STDCALL mysql_select_db(MYSQL *mysql, const char *db); int STDCALL mysql_query(MYSQL *mysql, const char *q); int STDCALL mysql_send_query(MYSQL *mysql, const char *q, -@@ -635,7 +636,7 @@ +@@ -649,7 +650,7 @@ int STDCALL mysql_stmt_next_result_start(int *ret, MYSQL_STMT *stmt); int STDCALL mysql_stmt_next_result_cont(int *ret, MYSQL_STMT *stmt, int status); int STDCALL mysql_set_character_set_start(int *ret, MYSQL *mysql, @@ -24,7 +28,7 @@ int STDCALL mysql_set_character_set_cont(int *ret, MYSQL *mysql, int status); int STDCALL mysql_change_user_start(my_bool *ret, MYSQL *mysql, -@@ -752,7 +752,7 @@ +@@ -765,7 +766,7 @@ struct st_mariadb_api { unsigned long (STDCALL *mysql_thread_id)(MYSQL *mysql); const char * (STDCALL *mysql_character_set_name)(MYSQL *mysql); void (STDCALL *mysql_get_character_set_info)(MYSQL *mysql, MY_CHARSET_INFO *cs); diff --git a/deps/mariadb-client-library/mysql.h.sslkeylogfile.patch b/deps/mariadb-client-library/mysql.h.sslkeylogfile.patch deleted file mode 100644 index 793d16f17d..0000000000 --- a/deps/mariadb-client-library/mysql.h.sslkeylogfile.patch +++ /dev/null @@ -1,16 +0,0 @@ -@@ -242,13 +242,14 @@ - MARIADB_OPT_DEBUG, - MARIADB_OPT_FOUND_ROWS, - MARIADB_OPT_MULTI_RESULTS, - MARIADB_OPT_MULTI_STATEMENTS, - MARIADB_OPT_INTERACTIVE, - MARIADB_OPT_PROXY_HEADER, -- MARIADB_OPT_IO_WAIT -+ MARIADB_OPT_IO_WAIT, -+ MARIADB_OPT_SSL_KEYLOG_CALLBACK - }; - - enum mariadb_value { - MARIADB_CHARSET_ID, - MARIADB_CHARSET_NAME, - MARIADB_CLIENT_ERRORS, diff --git a/deps/mariadb-client-library/openssl.c.sslkeylogfile.patch b/deps/mariadb-client-library/openssl.c.sslkeylogfile.patch deleted file mode 100644 index 7c53663f14..0000000000 --- a/deps/mariadb-client-library/openssl.c.sslkeylogfile.patch +++ /dev/null @@ -1,34 +0,0 @@ -@@ -529,12 +529,19 @@ - memset(buf, 0, size); - if (userdata) - strncpy(buf, (char *)userdata, size); - return (int)strlen(buf); - } - -+static void ma_tls_set_sslkeylog_callback(MYSQL *mysql, SSL_CTX *ssl_ctx) -+{ -+ if (mysql->options.extension && mysql->options.extension->ssl_keylog_callback) -+ { -+ SSL_CTX_set_keylog_callback(ssl_ctx, (void(*)(const SSL*, const char*))mysql->options.extension->ssl_keylog_callback); -+ } -+} - - static int ma_tls_set_certs(MYSQL *mysql, SSL *ssl) - { - char *certfile= mysql->options.ssl_cert, - *keyfile= mysql->options.ssl_key; - char *pw= (mysql->options.extension) ? -@@ -656,12 +663,13 @@ - if (!(ctx= SSL_CTX_new(SSLv23_client_method()))) - #endif - goto error; - if (mysql->options.extension) - options|= ma_tls_version_options(mysql->options.extension->tls_version); - SSL_CTX_set_options(ctx, options); -+ ma_tls_set_sslkeylog_callback(mysql, ctx); - #ifdef HAVE_TLS_SESSION_CACHE - SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_CLIENT); - ma_tls_sessions= (MA_SSL_SESSION *)calloc(1, sizeof(struct st_ma_tls_session) * ma_tls_session_cache_size); - SSL_CTX_sess_set_new_cb(ctx, ma_tls_session_cb); - SSL_CTX_sess_set_remove_cb(ctx, ma_tls_remove_session_cb); - #endif diff --git a/deps/mariadb-client-library/plugin_auth_CMakeLists.txt.patch b/deps/mariadb-client-library/plugin_auth_CMakeLists.txt.patch index 989b9cf567..ed4aca87d1 100644 --- a/deps/mariadb-client-library/plugin_auth_CMakeLists.txt.patch +++ b/deps/mariadb-client-library/plugin_auth_CMakeLists.txt.patch @@ -1,4 +1,8 @@ -@@ -70,7 +70,7 @@ +diff --git plugins/auth/CMakeLists.txt plugins/auth/CMakeLists.txt +index 83e324b9..7c4ed019 100644 +--- plugins/auth/CMakeLists.txt ++++ plugins/auth/CMakeLists.txt +@@ -77,7 +77,7 @@ IF(CRYPTO_PLUGIN) REGISTER_PLUGIN(TARGET caching_sha2_password TYPE MARIADB_CLIENT_PLUGIN_AUTH CONFIGURATIONS DYNAMIC STATIC OFF @@ -7,7 +11,7 @@ SOURCES ${CC_SOURCE_DIR}/plugins/auth/caching_sha2_pw.c ${CRYPT_SOURCE} LIBRARIES ${CRYPT_LIBS}) -@@ -81,7 +81,7 @@ +@@ -88,7 +88,7 @@ IF(CRYPTO_PLUGIN) REGISTER_PLUGIN(TARGET sha256_password TYPE MARIADB_CLIENT_PLUGIN_AUTH CONFIGURATIONS DYNAMIC STATIC OFF @@ -16,7 +20,7 @@ SOURCES ${AUTH_DIR}/sha256_pw.c LIBRARIES ${CRYPT_LIBS}) ENDIF() -@@ -123,6 +123,6 @@ +@@ -137,6 +137,6 @@ REGISTER_PLUGIN(TARGET mysql_old_password REGISTER_PLUGIN(TARGET mysql_clear_password TYPE MARIADB_CLIENT_PLUGIN_AUTH CONFIGURATIONS DYNAMIC STATIC OFF diff --git a/deps/mariadb-client-library/ps_buffer_stmt_read_all_rows.patch b/deps/mariadb-client-library/ps_buffer_stmt_read_all_rows.patch index 373e4c3dd9..ee0f3c8a21 100644 --- a/deps/mariadb-client-library/ps_buffer_stmt_read_all_rows.patch +++ b/deps/mariadb-client-library/ps_buffer_stmt_read_all_rows.patch @@ -1,10 +1,10 @@ diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c -index bbc2831..e66d810 100644 +index 7c6482ac..40a8ded1 100644 --- libmariadb/mariadb_stmt.c +++ libmariadb/mariadb_stmt.c -@@ -207,6 +207,24 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) +@@ -218,6 +218,24 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) - while ((packet_len = ma_net_safe_read(stmt->mysql, &is_data_packet)) != packet_error) + while ((packet_len = ma_net_safe_read(stmt->mysql)) != packet_error) { + // This change is required due to the new algorithm introduced in ProxySQL in #3295. + // ******************************************************************************** @@ -25,5 +25,5 @@ index bbc2831..e66d810 100644 + // ******************************************************************************** + p= stmt->mysql->net.read_pos; - // The check is by 'ma_net_safe_read' - if (p[0] == 0 || is_data_packet) + if (packet_len > 7 || p[0] != 254) + { diff --git a/deps/mariadb-client-library/sslkeylogfile.patch b/deps/mariadb-client-library/sslkeylogfile.patch new file mode 100644 index 0000000000..76766679dc --- /dev/null +++ b/deps/mariadb-client-library/sslkeylogfile.patch @@ -0,0 +1,77 @@ +diff --git include/ma_common.h include/ma_common.h +index 1ac0cb68..0d3f39b3 100644 +--- include/ma_common.h ++++ include/ma_common.h +@@ -80,6 +80,7 @@ struct st_mysql_options_extension { + char *proxy_header; + size_t proxy_header_len; + int (*io_wait)(my_socket handle, my_bool is_read, int timeout); ++ void (*ssl_keylog_callback)(const void *ssl, const char *line); + my_bool skip_read_response; + char *restricted_auth; + char *rpl_host; +diff --git include/mysql.h include/mysql.h +index 9ee86227..c07717c5 100644 +--- include/mysql.h ++++ include/mysql.h +@@ -257,7 +257,8 @@ extern const char *SQLSTATE_UNKNOWN; + MARIADB_OPT_RESTRICTED_AUTH, + MARIADB_OPT_RPL_REGISTER_REPLICA, + MARIADB_OPT_STATUS_CALLBACK, +- MARIADB_OPT_SERVER_PLUGINS ++ MARIADB_OPT_SERVER_PLUGINS, ++ MARIADB_OPT_SSL_KEYLOG_CALLBACK + }; + + enum mariadb_value { +diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c +index be4c91d1..87dd7c3e 100644 +--- libmariadb/mariadb_lib.c ++++ libmariadb/mariadb_lib.c +@@ -3634,6 +3634,9 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) + case MYSQL_OPT_SSL_CRLPATH: + OPT_SET_EXTENDED_VALUE_STR(&mysql->options, ssl_crlpath, (char *)arg1); + break; ++ case MARIADB_OPT_SSL_KEYLOG_CALLBACK: ++ OPT_SET_EXTENDED_VALUE(&mysql->options, ssl_keylog_callback, arg1); ++ break; + case MYSQL_OPT_CONNECT_ATTR_DELETE: + { + uchar *h; +@@ -4000,6 +4003,9 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...) + case MYSQL_OPT_SSL_CRLPATH: + *((char **)arg)= mysql->options.extension ? mysql->options.extension->ssl_crlpath : NULL; + break; ++ case MARIADB_OPT_SSL_KEYLOG_CALLBACK: ++ *((void(**)(const void *, const char *))arg)= mysql->options.extension ? mysql->options.extension->ssl_keylog_callback : NULL; ++ break; + case MARIADB_OPT_TLS_VERSION: + case MYSQL_OPT_TLS_VERSION: + *((char **)arg)= mysql->options.extension ? mysql->options.extension->tls_version : NULL; +diff --git libmariadb/secure/openssl.c libmariadb/secure/openssl.c +index 2a272504..67d90c6a 100644 +--- libmariadb/secure/openssl.c ++++ libmariadb/secure/openssl.c +@@ -317,6 +317,13 @@ int ma_tls_get_password(char *buf, int size, + return (int)strlen(buf); + } + ++static void ma_tls_set_sslkeylog_callback(MYSQL *mysql, SSL_CTX *ctx) ++{ ++ if (mysql->options.extension && mysql->options.extension->ssl_keylog_callback) ++ { ++ SSL_CTX_set_keylog_callback(ctx, (void(*)(const SSL*, const char*))mysql->options.extension->ssl_keylog_callback); ++ } ++} + + static int ma_tls_set_certs(MYSQL *mysql, SSL_CTX *ctx) + { +@@ -433,7 +440,7 @@ void *ma_tls_init(MYSQL *mysql) + if (mysql->options.extension) + options= ma_tls_version_options(mysql->options.extension->tls_version); + SSL_CTX_set_options(ctx, options ? options : default_options); +- ++ ma_tls_set_sslkeylog_callback(mysql, ctx); + if (ma_tls_set_certs(mysql, ctx)) + { + goto error; diff --git a/deps/mariadb-client-library/unittest_basic-t.c.patch b/deps/mariadb-client-library/unittest_basic-t.c.patch index 3f0737041a..11b156e5f7 100644 --- a/deps/mariadb-client-library/unittest_basic-t.c.patch +++ b/deps/mariadb-client-library/unittest_basic-t.c.patch @@ -1,6 +1,8 @@ ---- /tmp/basic-t.c 2017-12-28 14:55:55.958512116 +0100 -+++ unittest/libmariadb/basic-t.c 2017-12-28 14:56:08.770490417 +0100 -@@ -48,7 +48,7 @@ +diff --git unittest/libmariadb/basic-t.c unittest/libmariadb/basic-t.c +index 40a44962..9d3219be 100644 +--- unittest/libmariadb/basic-t.c ++++ unittest/libmariadb/basic-t.c +@@ -52,7 +52,7 @@ static int test_conc75(MYSQL *my) rc= mysql_query(mysql, "CREATE TABLE a (a varchar(200))"); check_mysql_rc(rc, mysql); diff --git a/deps/mariadb-client-library/unittest_charset.c.patch b/deps/mariadb-client-library/unittest_charset.c.patch index 196218d8d0..8f2212078b 100644 --- a/deps/mariadb-client-library/unittest_charset.c.patch +++ b/deps/mariadb-client-library/unittest_charset.c.patch @@ -1,19 +1,24 @@ -@@ -74,12 +74,12 @@ - char *csname= (char*) "utf8"; +diff --git unittest/libmariadb/charset.c unittest/libmariadb/charset.c +index b438f8d9..0c7c5d7d 100644 +--- unittest/libmariadb/charset.c ++++ unittest/libmariadb/charset.c +@@ -75,13 +75,13 @@ int test_client_character_set(MYSQL *mysql) char *csdefault= (char*)mysql_character_set_name(mysql); + - FAIL_IF(mysql_set_character_set(mysql, csname), mysql_error(mysql)); + FAIL_IF(mysql_set_character_set(mysql, csname, 0), mysql_error(mysql)); mysql_get_character_set_info(mysql, &cs); - FAIL_IF(strcmp(cs.csname, "utf8") || strcmp(cs.name, "utf8_general_ci"), "Character set != UTF8"); + FAIL_IF(strcmp(cs.csname, "latin2") || strcmp(cs.name, "latin2_general_ci"), + "Character set != latin2"); - FAIL_IF(mysql_set_character_set(mysql, csdefault), mysql_error(mysql)); + FAIL_IF(mysql_set_character_set(mysql, csdefault, 0), mysql_error(mysql)); return OK; } -@@ -542,7 +542,7 @@ +@@ -546,7 +546,7 @@ static int test_bug30472(MYSQL *mysql) } /* Retrieve character set information. */ @@ -22,16 +27,16 @@ bug30472_retrieve_charset_info(mysql, character_set_name_1, character_set_client_1, -@@ -551,7 +551,7 @@ +@@ -555,7 +555,7 @@ static int test_bug30472(MYSQL *mysql) /* Switch client character set. */ -- FAIL_IF(mysql_set_character_set(mysql, "utf8"), "Setting cs to utf8 failed"); -+ FAIL_IF(mysql_set_character_set(mysql, "utf8", 0), "Setting cs to utf8 failed"); +- FAIL_IF(mysql_set_character_set(mysql, "ascii"), ++ FAIL_IF(mysql_set_character_set(mysql, "ascii", 0), + "Setting cs to ascii failed"); /* Retrieve character set information. */ - -@@ -581,7 +581,7 @@ +@@ -587,7 +587,7 @@ static int test_bug30472(MYSQL *mysql) /* Call mysql_change_user() with the same username, password, database. */ rc= mysql_change_user(mysql, username, password, (schema) ? schema : "test"); @@ -40,17 +45,17 @@ check_mysql_rc(rc, mysql); /* Retrieve character set information. */ -@@ -647,7 +647,7 @@ - /* ignore ucs2 */ - if (strcmp(row[0], "ucs2") && strcmp(row[0], "utf16le") && strcmp(row[0], "utf8mb4") && - strcmp(row[0], "utf16") && strcmp(row[0], "utf32")) { +@@ -658,7 +658,7 @@ static int test_bug_54100(MYSQL *mysql) + && (strcmp(row[0], "utf8") && mariadb_connection(mysql) && mysql_get_server_version(mysql) >= 100600) + && strcmp(row[0], "utf16") + && strcmp(row[0], "utf32")) { - rc= mysql_set_character_set(mysql, row[0]); + rc= mysql_set_character_set(mysql, row[0], 0); check_mysql_rc(rc, mysql); } } -@@ -748,7 +748,7 @@ - +@@ -765,14 +765,14 @@ static int charset_auto(MYSQL *my __attribute__((unused))) + "character set is not os character set"); if (strcmp(osname, "utf8")) { - rc= mysql_set_character_set(mysql, "utf8"); @@ -58,8 +63,7 @@ check_mysql_rc(rc, mysql); csname2= mysql_character_set_name(mysql); -@@ -756,7 +756,7 @@ - + diag("Character set: %s", csname2); FAIL_IF(!strcmp(csname2, csname1), "Wrong charset: expected utf8"); - rc= mysql_set_character_set(mysql, "auto"); diff --git a/deps/mariadb-client-library/openssl.c.x509cache.patch b/deps/mariadb-client-library/x509cache.patch similarity index 70% rename from deps/mariadb-client-library/openssl.c.x509cache.patch rename to deps/mariadb-client-library/x509cache.patch index 81109405c9..08233ad408 100644 --- a/deps/mariadb-client-library/openssl.c.x509cache.patch +++ b/deps/mariadb-client-library/x509cache.patch @@ -1,4 +1,44 @@ -@@ -30,6 +30,12 @@ +diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c +index 916024a8..79564a10 100644 +--- libmariadb/mariadb_lib.c ++++ libmariadb/mariadb_lib.c +@@ -133,6 +133,11 @@ my_context_install_suspend_resume_hook(struct mysql_async_context *b, + uint mysql_port=0; + my_string mysql_unix_port=0; + ++#include ++extern __thread SSL_CTX * thread_ctx; ++extern __thread char **local_x509_files; ++extern __thread char **local_x509_sha1s; ++ + #define CONNECT_TIMEOUT 0 + + struct st_mariadb_methods MARIADB_DEFAULT_METHODS; +@@ -4650,6 +4655,19 @@ my_bool STDCALL mysql_thread_init(void) + + void STDCALL mysql_thread_end(void) + { ++ if (local_x509_files != NULL) { ++ int i; ++ for (i=0; local_x509_files[i] != NULL ; i++) { ++ free(local_x509_files[i]); ++ free(local_x509_sha1s[i]); ++ } ++ free(local_x509_files); ++ free(local_x509_sha1s); ++ } ++ if (thread_ctx != NULL) { ++ SSL_CTX_free(thread_ctx); ++ thread_ctx = NULL; ++ } + } + + int STDCALL mysql_set_server_option(MYSQL *mysql, +diff --git libmariadb/secure/openssl.c libmariadb/secure/openssl.c +index 67d90c6a..26938959 100644 +--- libmariadb/secure/openssl.c ++++ libmariadb/secure/openssl.c +@@ -30,6 +30,11 @@ #include #include @@ -6,12 +46,11 @@ +#include +#include +#include -+ + #if defined(_WIN32) && !defined(_OPENSSL_Applink) && defined(HAVE_OPENSSL_APPLINK_C) #include #endif -@@ -73,6 +79,84 @@ +@@ -70,6 +75,82 @@ extern my_bool ma_tls_initialized; extern unsigned int mariadb_deinitialize_ssl; @@ -21,10 +60,8 @@ +__thread char **local_x509_sha1s = NULL; + +static int proxysql_SSL_CTX_local_x509store_add_file(SSL_CTX *ctx, const char *CAfile, int add_in_store) { -+ int found = 0; -+ int i = 0; ++ int found=0, i=0, fd=-1; + -+ int fd = -1; + struct stat statbuf; + unsigned char temp[SHA_DIGEST_LENGTH]; + char file_sha1[SHA_DIGEST_LENGTH*2+2]; @@ -36,8 +73,8 @@ + if(fstat(fd, &statbuf) == 0) { + unsigned char *fb = (unsigned char *)mmap(0, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (fb != MAP_FAILED) { ++ int i; + SHA1(fb, statbuf.st_size, temp); -+ int i; + for (i=0; i < SHA_DIGEST_LENGTH; i++) { + sprintf((char*)&(file_sha1[i*2]), "%02x", temp[i]); + } @@ -60,11 +97,11 @@ + } + + while (found == 0 && local_x509_files[i] != NULL) { -+ if (strcmp(CAfile, local_x509_files[i]) == 0) { -+ found = 1; -+ } else { -+ i++; -+ } ++ if (strcmp(CAfile, local_x509_files[i]) == 0) { ++ found = 1; ++ } else { ++ i++; ++ } + } + if (found == 1) { + if (strncmp(local_x509_sha1s[i],file_sha1,SHA_DIGEST_LENGTH*2)==0) { @@ -96,17 +133,17 @@ #define MAX_SSL_ERR_LEN 100 char tls_library_version[TLS_VERSION_LENGTH]; -@@ -456,7 +540,7 @@ +@@ -331,7 +412,7 @@ static int ma_tls_set_certs(MYSQL *mysql, SSL_CTX *ctx) + *keyfile= mysql->options.ssl_key; char *pw= (mysql->options.extension) ? mysql->options.extension->tls_pw : NULL; - SSL_CTX *ctx= SSL_get_SSL_CTX(ssl); - + int ssl_rc = 0; - /* add cipher */ if ((mysql->options.ssl_cipher && -@@ -467,16 +551,32 @@ - } + mysql->options.ssl_cipher[0] != 0)) +@@ -345,10 +426,27 @@ static int ma_tls_set_certs(MYSQL *mysql, SSL_CTX *ctx) + } /* ca_file and ca_path */ - if (!SSL_CTX_load_verify_locations(ctx, @@ -129,25 +166,11 @@ + if (mysql->options.ssl_ca != NULL) { + proxysql_SSL_CTX_local_x509store_add_file(ctx,mysql->options.ssl_ca, 0); + } -+ } ++ } + } + } + if (ssl_rc == 0) { if (mysql->options.ssl_ca || mysql->options.ssl_capath) goto error; if (SSL_CTX_set_default_verify_paths(ctx) == 0) - goto error; - } -- - if (keyfile && !certfile) - certfile= keyfile; - if (certfile && !keyfile) -@@ -566,6 +666,8 @@ - SSL_CTX_sess_set_remove_cb(ctx, ma_tls_remove_session_cb); - #endif - -+// if (local_x509store != NULL) -+// SSL_CTX_set1_cert_store(ctx, local_x509store); - if (!(ssl= SSL_new(ctx))) - goto error; - + diff --git a/deps/mariadb-client-library/zutil.c-multiplication-overflow.patch b/deps/mariadb-client-library/zutil.c-multiplication-overflow.patch index 524149f842..f1388ac893 100644 --- a/deps/mariadb-client-library/zutil.c-multiplication-overflow.patch +++ b/deps/mariadb-client-library/zutil.c-multiplication-overflow.patch @@ -1,7 +1,11 @@ -@@ -303,7 +303,7 @@ +diff --git external/zlib/zutil.c external/zlib/zutil.c +index 9543ae82..6a1ed031 100644 +--- external/zlib/zutil.c ++++ external/zlib/zutil.c +@@ -310,7 +310,7 @@ voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) unsigned size; { - if (opaque) items += size - size; /* make compiler happy */ + (void)opaque; - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : + return sizeof(uInt) > 2 ? (voidpf)malloc((long) items * size) : (voidpf)calloc(items, size); diff --git a/include/proxysql_admin.h b/include/proxysql_admin.h index 4b86dc5634..94fed715c4 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 5e178ed0bd..b2b2066fc3 100644 --- a/include/proxysql_glovars.hpp +++ b/include/proxysql_glovars.hpp @@ -6,7 +6,7 @@ #include #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..52a3d626ee 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,224 +1,232 @@ #!/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 -UNAME_S := $(shell uname -s) +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) 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= -ifeq ($(PROXYSQLCLICKHOUSE),1) - PSQLCH=-DPROXYSQLCLICKHOUSE -ifeq ($(IS_CXX17),1) - PSQLCH=-DPROXYSQLCLICKHOUSE -std=c++17 -DCXX17 +### handle clang issue https://bugs.llvm.org/show_bug.cgi?id=16404 +CLANGFIX := +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) }') +ifneq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER)))) + CLANGFIX := --rtlib=compiler-rt --unwindlib=libgcc endif endif - -WITHGCOVVAR := $(shell echo $(WITHGCOV)) -ifeq ($(WITHGCOVVAR),1) -WGCOV=-DWITHGCOV --coverage -else -WGCOV= +PSQLCH := +ifeq ($(PROXYSQLCLICKHOUSE),1) + PSQLCH := -DPROXYSQLCLICKHOUSE 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= +WGCOV := +ifeq ($(WITHGCOV),1) + WGCOV := -DWITHGCOV -lgcov --coverage endif -TEST_WITHASANVAR := $(shell echo $(TEST_WITHASAN)) -ifeq ($(TEST_WITHASANVAR),1) -WASAN+= -DTEST_WITHASAN +WASAN := +ifeq ($(WITHASAN),1) + WASAN := -fsanitize=address + # Force the disable of JEMALLOC, since ASAN isn't compatible. + export NOJEMALLOC=1 endif - -MYCXXFLAGS=-std=c++11 -ifeq ($(CXX),clang++) - MYCXXFLAGS+= -fuse-ld=lld +ifeq ($(TEST_WITHASAN),1) + WASAN += -DTEST_WITHASAN endif -MYCXXFLAGS+= $(IDIRS) $(OPTZ) $(DEBUG) $(PSQLCH) -DGITVERSION=\"$(GIT_VERSION)\" $(WGCOV) $(WASAN) -ifeq ($(WITHGCOVVAR),1) -LDFLAGS+= -lgcov --coverage +MYCXXFLAGS := $(STDCPP) +ifeq ($(CXX),clang++) + MYCXXFLAGS += -fuse-ld=lld endif +MYCXXFLAGS += $(IDIRS) $(OPTZ) $(DEBUG) $(PSQLCH) -DGITVERSION=\"$(GIT_VERSION)\" $(WGCOV) $(WASAN) -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) $(CLANGFIX) $(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) $(CLANGFIX) $(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_4402-mysql_fields-t.cpp b/test/tap/tests/reg_test_4402-mysql_fields-t.cpp new file mode 100644 index 0000000000..7ab0a0bbdb --- /dev/null +++ b/test/tap/tests/reg_test_4402-mysql_fields-t.cpp @@ -0,0 +1,129 @@ +/** + * @file reg_test_4402-mysql-fields-t.cpp + * @brief This TAP test checks if the length of the column alias and table alias surpasses 250 characters, + * should not impact MySQL field name length (MySQL_FIELD::name_length) and the MySQL field database length (MySQL_FIELD::db_length) + */ + +#include +#include +#include +#include +#include "tap.h" +#include "command_line.h" +#include "utils.h" + +#define MYSQL_QUERY__(mysql, query) \ + do { \ + if (mysql_query(mysql, query)) { \ + fprintf(stderr, "File %s, line %d, Error: %s\n", \ + __FILE__, __LINE__, mysql_error(mysql)); \ + goto cleanup; \ + } \ + } while(0) + +CommandLine cl; + +std::string generate_random_string(size_t length) { + std::srand(static_cast(std::time(nullptr))); + static const char characters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + static const int numCharacters = (sizeof(characters) - 1)/ sizeof(char); + + std::string randomString; + randomString.reserve(length); + + for (size_t i = 0; i < length; ++i) { + char randomChar = characters[std::rand() % numCharacters]; + randomString.push_back(randomChar); + } + + return randomString; +} + +int main(int argc, char** argv) { + + if (cl.getEnv()) { + diag("Failed to get the required environmental variables."); + return -1; + } + + plan(256*2); + + // Initialize ProxySQL connection + MYSQL* proxysql = mysql_init(NULL); + if (!proxysql) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql)); + return -1; + } + + // Connect to ProxySQL + if (!mysql_real_connect(proxysql, cl.host, cl.username, cl.password, NULL, cl.port, NULL, 0)) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql)); + return exit_status(); + } + + MYSQL_QUERY__(proxysql, "DROP DATABASE IF EXISTS testdb"); + MYSQL_QUERY__(proxysql, "CREATE DATABASE testdb"); + + diag("Creating echo_int function..."); + MYSQL_QUERY__(proxysql, "CREATE FUNCTION testdb.echo_int(N INT) RETURNS INT DETERMINISTIC RETURN N;"); + + diag("Creating dummy_table..."); + MYSQL_QUERY__(proxysql, "CREATE TABLE testdb.dummy_table(data VARCHAR(10))"); + + // wait for replication + std::this_thread::sleep_for(std::chrono::seconds(2)); + + // alias maximum length is 256. + // https://dev.mysql.com/doc/refman/8.2/en/identifier-length.html + // https://mariadb.com/kb/en/identifier-names/#maximum-length + for (unsigned int length = 1; length <= 256; length++) { + + // to check column alias issue: + { + const std::string& query = "SELECT testdb.echo_int(1) AS " + generate_random_string(length); + MYSQL_QUERY__(proxysql, query.c_str()); + + MYSQL_RES* res = mysql_use_result(proxysql); + if (!res) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql)); + return exit_status(); + } + + MYSQL_FIELD* field = mysql_fetch_fields(res); + + ok(field->name_length == length, "name_length: '%u'. Expected length: '%u'", field->name_length, length); + + if (res) { + mysql_free_result(res); + res = NULL; + } + } + + // to check table alias issue: + { + const std::string& query = "SELECT data FROM testdb.dummy_table AS " + generate_random_string(length); + MYSQL_QUERY__(proxysql, query.c_str()); + + MYSQL_RES* res = mysql_use_result(proxysql); + if (!res) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql)); + return exit_status(); + } + + MYSQL_FIELD* field = mysql_fetch_fields(res); + + ok(field->db_length == (sizeof("testdb")-1), "db_length: '%u'. Expected length: '%u'", + field->db_length, (unsigned int)(sizeof("testdb")-1)); + + if (res) { + mysql_free_result(res); + res = NULL; + } + } + } +cleanup: + mysql_query(proxysql, "DROP DATABASE IF EXISTS testdb"); + mysql_close(proxysql); + + return exit_status(); +} 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..6f9c98befb 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" @@ -38,13 +38,17 @@ std::vector adminQ_set1 = { int pull_replication(MYSQL *mysql, int server_id) { MARIADB_RPL_EVENT *event= NULL; MARIADB_RPL *rpl= mariadb_rpl_init(mysql); + if (!rpl) { + fprintf(stderr, "File %s, line %d, Error: mariadb_rpl_init failed\n", __FILE__, __LINE__); + return exit_status(); + } rpl->server_id= server_id; rpl->start_position= 4; rpl->flags= MARIADB_RPL_BINLOG_SEND_ANNOTATE_ROWS; - - if (mariadb_rpl_open(rpl)) + if (mariadb_rpl_open(rpl)) { + fprintf(stderr, "File %s, line %d, Error: '%d':%s\n", __FILE__, __LINE__, mysql_errno(rpl->mysql), mysql_error(rpl->mysql)); return exit_status(); - + } int num_heartbeats = 0; int num_events = 0; @@ -149,6 +153,16 @@ int main(int argc, char** argv) { __FILE__, __LINE__, mysql_error(mysqladmin)); return exit_status(); } + + const std::vector query_rules = { "INSERT OR IGNORE INTO mysql_query_rules (rule_id,active,match_digest,destination_hostgroup,multiplex,apply) VALUES\ + (-1,1,'^(SELECT @rpl_semi_sync_slave=\\?.*|SET @rpl_semi_sync_slave=\\?.*)$',0,0,1)", + "LOAD MYSQL QUERY RULES TO RUNTIME" }; + + for (const auto& query : query_rules) { + diag("Running on Admin: %s", query.c_str()); + MYSQL_QUERY(mysqladmin, query.c_str()); + } + // we now test various combination setup_replication(11, false, false, repl_queries_set1); setup_replication(12, true, false, repl_queries_set1); 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 d2a45b6b56..6b79383cb4 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;