Merge pull request #5308 from sysown/v3.0_mac

Support for ProxySQL compilation on macOS (Darwin/Apple Silicon)
pull/5348/head
René Cannaò 2 weeks ago committed by GitHub
commit a360dc22ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -188,7 +188,16 @@ zypper install -y automake bzip2 cmake make gcc-c++ gcc git openssl openssl-deve
### macOS (using Homebrew):
```bash
brew install automake bzip2 cmake make git gpatch gnutls ossp-uuid
brew install automake bzip2 cmake make git gpatch gnutls openssl@3 icu4c pkg-config libiconv zlib
```
To compile on macOS, you must set the following environment variables to ensure the build system can find OpenSSL and Homebrew dependencies:
```bash
export PATH="/opt/homebrew/bin:$PATH"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig:$PKG_CONFIG_PATH"
export OPENSSL_ROOT_DIR="/opt/homebrew/opt/openssl@3"
make # or make debug
```
For more details, inspect the docker build images:

@ -89,6 +89,7 @@ endif
### multiprocessing
NPROCS := 1
OS := $(shell uname -s)
UNAME_S := $(OS)
ifeq ($(OS),Linux)
NPROCS := $(shell nproc)
endif
@ -107,8 +108,12 @@ ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system)
endif
### check user/group
USERCHECK :=
GROUPCHECK :=
ifeq ($(OS),Linux)
USERCHECK := $(shell getent passwd proxysql)
GROUPCHECK := $(shell getent group proxysql)
endif
### main targets
@ -329,7 +334,11 @@ SYS_ARCH := $(shell uname -m)
REL_ARCH = $(subst x86_64,amd64,$(subst aarch64,arm64,$(SYS_ARCH)))
RPM_ARCH = .$(SYS_ARCH)
DEB_ARCH = _$(REL_ARCH)
ifeq ($(UNAME_S),Darwin)
REL_VERS := $(shell echo ${GIT_VERSION} | sed -E 's/^v//' | grep -Eo '^[0-9\.]+')
else
REL_VERS := $(shell echo ${GIT_VERSION} | grep -Po '(?<=^v|^)[\d\.]+')
endif
RPM_VERS := -$(REL_VERS)-1
DEB_VERS := _$(REL_VERS)

@ -8,27 +8,79 @@ ifeq ($(CENTOSVER),8)
endif
endif
$(info OPENSSL_PACKAGE: $(OPENSSL_PACKAGE))
# Use pkg-config to get the compiler and linker flags for OpenSSL if CUSTOM_OPENSSL_PATH is not set
ifeq ($(CUSTOM_OPENSSL_PATH),)
$(info No custom path specified.)
ifeq ($(UNAME_S),Darwin)
ifneq ($(OPENSSL_ROOT_DIR),)
CUSTOM_OPENSSL_PATH := $(OPENSSL_ROOT_DIR)
endif
endif
endif
ifeq ($(CUSTOM_OPENSSL_PATH),)
ifeq ($(OPENSSL_PACKAGE),openssl3)
ifeq ($(UNAME_S),Darwin)
SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | sed -E 's/-I/ /g' | awk '{for(i=1;i<=NF;i++) if($$i ~ /^\//) print $$i}' | head -n 1)
else
SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+")
endif
SSL_LDIR := $(shell pkg-config --variable=libdir $(OPENSSL_PACKAGE))
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so.3" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so.3" 2>/dev/null | head -n 1)
else
ifeq ($(UNAME_S),Darwin)
SSL_IDIR := $(shell export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1; export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1; pkg-config --cflags $(OPENSSL_PACKAGE) | sed -E 's/-I/ /g' | awk '{for(i=1;i<=NF;i++) if($$i ~ /^\//) print $$i}' | head -n 1)
else
SSL_IDIR := $(shell export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1; export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1; pkg-config --cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+")
endif
SSL_LDIR := $(shell pkg-config --variable=libdir $(OPENSSL_PACKAGE))
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so" 2>/dev/null | head -n 1)
ifeq ($(UNAME_S),Darwin)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.dylib" 2>/dev/null | head -n 1)
ifeq ($(LIB_SSL_PATH),)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.a" 2>/dev/null | head -n 1)
endif
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.dylib" 2>/dev/null | head -n 1)
ifeq ($(LIB_CRYPTO_PATH),)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.a" 2>/dev/null | head -n 1)
endif
else
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so*" 2>/dev/null | head -n 1)
ifeq ($(LIB_SSL_PATH),)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.a" 2>/dev/null | head -n 1)
endif
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so*" 2>/dev/null | head -n 1)
ifeq ($(LIB_CRYPTO_PATH),)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.a" 2>/dev/null | head -n 1)
endif
endif
endif
else
SSL_IDIR := $(CUSTOM_OPENSSL_PATH)/include
ifeq ($(UNAME_S),Darwin)
SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib
else
SSL_LDIR := $(CUSTOM_OPENSSL_PATH)/lib64
endif
ifeq ($(UNAME_S),Darwin)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.dylib" 2>/dev/null | head -n 1)
ifeq ($(LIB_SSL_PATH),)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.a" 2>/dev/null | head -n 1)
endif
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.dylib" 2>/dev/null | head -n 1)
ifeq ($(LIB_CRYPTO_PATH),)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.a" 2>/dev/null | head -n 1)
endif
else
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.so" 2>/dev/null | head -n 1)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so" 2>/dev/null | head -n 1)
ifeq ($(LIB_SSL_PATH),)
LIB_SSL_PATH := $(shell find $(SSL_LDIR) -name "libssl.a" 2>/dev/null | head -n 1)
endif
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.so" 2>/dev/null | head -n 1)
ifeq ($(LIB_CRYPTO_PATH),)
LIB_CRYPTO_PATH := $(shell find $(SSL_LDIR) -name "libcrypto.a" 2>/dev/null | head -n 1)
endif
endif
$(info Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH))
endif

@ -3,6 +3,44 @@ REQUIRED_OPENSSL_VERSION := 3.0.0
$(info OPENSSL_PACKAGE: $(OPENSSL_PACKAGE))
check_openssl_version:
ifeq ($(UNAME_S),Darwin)
@if [ -n "$(CUSTOM_OPENSSL_PATH)" ]; then \
header_path="$(CUSTOM_OPENSSL_PATH)/include/openssl/opensslv.h"; \
if [ ! -f "$$header_path" ]; then \
echo "OpenSSL header file not found at $$header_path"; \
exit 1; \
fi; \
version_number=$$(grep "# *define OPENSSL_VERSION_STR" $$header_path | sed -E 's/.*"([^"]+)".*/\1/'); \
if [ -z "$$version_number" ]; then \
echo "Failed to extract OPENSSL_VERSION_STR from $$header_path"; \
exit 1; \
fi; \
major=$$(echo $$version_number | cut -d'.' -f1); \
minor=$$(echo $$version_number | cut -d'.' -f2); \
patch=$$(echo $$version_number | cut -d'.' -f3); \
if [ $$major -gt 3 ] || { [ $$major -eq 3 ] && { [ $$minor -gt 0 ] || { [ $$minor -eq 0 ] && [ $$patch -ge 0 ]; }; }; }; then \
: ; \
else \
echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$major.$$minor.$$patch"; \
exit 1; \
fi; \
else \
openssl_version=$$(pkg-config --modversion $(OPENSSL_PACKAGE) 2>/dev/null); \
if [ -z "$$openssl_version" ]; then \
echo "OpenSSL not found via pkg-config."; \
exit 1; \
fi; \
major=$$(echo $$openssl_version | cut -d'.' -f1); \
minor=$$(echo $$openssl_version | cut -d'.' -f2); \
patch=$$(echo $$openssl_version | cut -d'.' -f3); \
if [ $$major -gt 3 ] || { [ $$major -eq 3 ] && { [ $$minor -gt 0 ] || { [ $$minor -eq 0 ] && [ $$patch -ge 0 ]; }; }; }; then \
: ; \
else \
echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$openssl_version"; \
exit 1; \
fi; \
fi
else
@echo "Checking OpenSSL version..."
@if [ -n "$(CUSTOM_OPENSSL_PATH)" ]; then \
echo "Using custom OpenSSL path: $(CUSTOM_OPENSSL_PATH)"; \
@ -11,7 +49,7 @@ check_openssl_version:
echo "OpenSSL header file not found at $$header_path"; \
exit 1; \
fi; \
version_number=$$(grep -oP '# define OPENSSL_VERSION_STR "\K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?' $$header_path | tr -d '[:space:]'); \
version_number=$$(grep "# *define OPENSSL_VERSION_STR" $$header_path | sed -E 's/.*"([^"]+)".*/\1/'); \
if [ -z "$$version_number" ]; then \
echo "Failed to extract OPENSSL_VERSION_STR from $$header_path"; \
exit 1; \
@ -41,4 +79,5 @@ check_openssl_version:
echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$openssl_version"; \
exit 1; \
fi; \
fi
fi
endif

30
deps/Makefile vendored

@ -137,9 +137,11 @@ curl/curl/lib/.libs/libcurl.a:
cd curl && tar -zxf curl-*.tar.gz
cd curl/curl && autoreconf -fi
ifeq ($(UNAME_S),Darwin)
cd curl/curl && patch configure < ../configure.patch
endif
cd curl/curl && sed -i '' 's/as_fn_error \$$? "one or more libs available at link-time are not available run-time/echo "Skipped check: one or more libs available at link-time are not available run-time/' configure
cd curl/curl && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" DYLD_LIBRARY_PATH="$(SSL_LDIR):$$DYLD_LIBRARY_PATH" ./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 --enable-shared=yes
else
cd curl/curl && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" ./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 --enable-shared=yes
endif
cd curl/curl && CFLAGS=-fPIC CC=${CC} CXX=${CXX} ${MAKE}
curl: curl/curl/lib/.libs/libcurl.a
@ -206,7 +208,15 @@ mariadb-client-library/mariadb_client/libmariadb/libmariadbclient.a:
cd mariadb-client-library && rm -rf mariadb-connector-c-*/ || true
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 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(SSL_IDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DICONV_LIBRARIES=$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$(brew --prefix libiconv)/include .
ifeq ($(UNAME_S),Darwin)
cd mariadb-client-library/mariadb_client && patch -p0 < ../zutil.c.patch
cd mariadb-client-library/mariadb_client && patch -p0 < ../zutil.h.patch
endif
ifeq ($(UNAME_S),Darwin)
cd mariadb-client-library/mariadb_client && cmake . -Wno-dev -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(SSL_IDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DICONV_LIBRARIES=$$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$$(brew --prefix libiconv)/include -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .
else
cd mariadb-client-library/mariadb_client && cmake . -Wno-dev -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(SSL_IDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .
endif
ifeq ($(PROXYDEBUG),1)
cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_context.h.patch
else ifeq ($(USEVALGRIND),1)
@ -249,7 +259,7 @@ endif
# new compilers fix
cd mariadb-client-library/mariadb_client && patch -p0 < ../bool_keyword.patch
cd mariadb-client-library/mariadb_client && CC=${CC} CXX=${CXX} ${MAKE} mariadbclient
cd mariadb-client-library/mariadb_client && CC=${CC} CXX=${CXX} ${MAKE} mariadbclient VERBOSE=1
# cd mariadb-client-library/mariadb_client/include && make my_config.h
mariadb_client: mariadb-client-library/mariadb_client/libmariadb/libmariadbclient.a
@ -326,8 +336,6 @@ pcre/pcre/.libs/libpcre.a:
cd pcre/pcre && CC=${CC} CXX=${CXX} ${MAKE}
pcre: pcre/pcre/.libs/libpcre.a
postgresql/postgresql/src/interfaces/libpq/libpq.a:
cd postgresql && rm -rf postgresql-*/ || true
cd postgresql && tar -zxf postgresql-*.tar.gz
@ -336,10 +344,12 @@ postgresql/postgresql/src/interfaces/libpq/libpq.a:
cd postgresql/postgresql && patch -p0 < ../fmt_err_msg.patch
cd postgresql/postgresql && patch -p0 < ../bind_fmt_text.patch
cd postgresql/postgresql && patch -p0 < ../pqsendpipelinesync.patch
#cd postgresql/postgresql && LD_LIBRARY_PATH="$(shell pwd)/libssl/openssl" ./configure --with-ssl=openssl --with-includes="$(shell pwd)/libssl/openssl/include/" --with-libraries="$(shell pwd)/libssl/openssl/" --without-readline --enable-debug CFLAGS="-ggdb -O0 -fno-omit-frame-pointer" CPPFLAGS="-g -O0"
ifeq ($(UNAME_S),Darwin)
cd postgresql/postgresql && LDFLAGS="-L$$(brew --prefix icu4c)/lib" CPPFLAGS="-I$$(brew --prefix icu4c)/include" PKG_CONFIG_PATH="$$(brew --prefix icu4c)/lib/pkgconfig:$$PKG_CONFIG_PATH" DYLD_LIBRARY_PATH="$(SSL_LDIR):$$DYLD_LIBRARY_PATH" ./configure --with-ssl=openssl --with-includes="$(SSL_IDIR)" --with-libraries="$(SSL_LDIR)" --without-readline --with-icu
else
cd postgresql/postgresql && LD_LIBRARY_PATH="$(SSL_LDIR)" ./configure --with-ssl=openssl --with-includes="$(SSL_IDIR)" --with-libraries="$(SSL_LDIR)" --without-readline
endif
cd postgresql/postgresql/src/interfaces/libpq && CC=${CC} CXX=${CXX} ${MAKE} MAKELEVEL=0
#cd postgresql/postgresql && CC=${CC} CXX=${CXX} ${MAKE} -f src/interfaces/libpq/Makefile all
postgresql: postgresql/postgresql/src/interfaces/libpq/libpq.a
@ -348,7 +358,11 @@ libusual/libusual/.libs/libusual.a:
cd libusual && rm -rf libusual-*/ || true
cd libusual && tar -zxf libusual-*.tar.gz
cd libusual/libusual && ./autogen.sh
ifeq ($(UNAME_S),Darwin)
cd libusual/libusual && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" DYLD_LIBRARY_PATH="$(SSL_LDIR):$$DYLD_LIBRARY_PATH" ./configure --with-openssl="$(patsubst %/include,%,$(SSL_IDIR))" --disable-shared
else
cd libusual/libusual && CPPFLAGS="-I$(SSL_IDIR)" LDFLAGS="$(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)" ./configure --with-openssl="$(SSL_LDIR)" --disable-shared
endif
cd libusual/libusual && CC=${CC} CXX=${CXX} ${MAKE}
libusual: libusual/libusual/.libs/libusual.a

@ -0,0 +1,35 @@
--- external/zlib/zutil.c.orig 2024-05-22 17:34:00.000000000 +0200
+++ external/zlib/zutil.c 2024-05-22 17:34:00.000000000 +0200
@@ -132,8 +132,7 @@
/* exported to allow conversion of error code to string for compress() and
* uncompress()
*/
-const char * ZEXPORT zError(err)
- int err;
+const char * ZEXPORT zError(int err)
{
return ERR_MSG(err);
}
@@ -304,10 +304,7 @@
extern void free OF((voidpf ptr));
#endif
-voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
+voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
{
(void)opaque;
return sizeof(uInt) > 2 ? (voidpf)malloc((long) items * size) :
@@ -315,9 +312,7 @@
(voidpf)calloc(items, size);
}
-void ZLIB_INTERNAL zcfree(opaque, ptr)
- voidpf opaque;
- voidpf ptr;
+void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
{
(void)opaque;
free(ptr);

@ -0,0 +1,13 @@
--- external/zlib/zutil.h.orig 2024-05-22 17:34:00.000000000 +0200
+++ external/zlib/zutil.h 2024-05-22 17:34:00.000000000 +0200
@@ -143,9 +143,7 @@
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
+
# endif
# endif
#endif

@ -1,10 +1,9 @@
diff --git src/interfaces/libpq/fe-exec.c src/interfaces/libpq/fe-exec.c
index fa9d6aad..cd5cd23d 100644
--- src/interfaces/libpq/fe-exec.c
+++ src/interfaces/libpq/fe-exec.c
@@ -4467,3 +4467,20 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
*retbuflen = buflen;
return tmpbuf;
diff -ruN ../tmp/src/interfaces/libpq/fe-exec.c ./src/interfaces/libpq/fe-exec.c
--- ../tmp/src/interfaces/libpq/fe-exec.c 2025-08-11 21:06:43.000000000 +0000
+++ ./src/interfaces/libpq/fe-exec.c 2026-02-06 13:03:06.060890335 +0000
@@ -4528,3 +4528,20 @@
*retbuflen = buflen;
return tmpbuf;
}
+
+/*
@ -23,18 +22,16 @@ index fa9d6aad..cd5cd23d 100644
+ return conn->result;
+}
+
diff --git src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-fe.h
index 7476dbe0..472d0083 100644
--- src/interfaces/libpq/libpq-fe.h
+++ src/interfaces/libpq/libpq-fe.h
@@ -668,6 +668,9 @@ extern PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void);
diff -ruN ../tmp/src/interfaces/libpq/libpq-fe.h ./src/interfaces/libpq/libpq-fe.h
--- ../tmp/src/interfaces/libpq/libpq-fe.h 2025-08-11 21:06:43.000000000 +0000
+++ ./src/interfaces/libpq/libpq-fe.h 2026-02-06 13:03:06.060890335 +0000
@@ -668,6 +668,9 @@
extern void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook);
extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn);
extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn);
+/* Get PGresult directly from PGconn. WARNING: DO NOT RELEASE THIS RESULT */
+extern const PGresult *PQgetResultFromPGconn(PGconn *conn);
+
#ifdef __cplusplus
}
#endif

@ -1,8 +1,7 @@
diff --git src/interfaces/libpq/fe-exec.c src/interfaces/libpq/fe-exec.c
index 2265ab5..56883ec 100644
--- src/interfaces/libpq/fe-exec.c
+++ src/interfaces/libpq/fe-exec.c
@@ -4484,3 +4484,9 @@ PQgetResultFromPGconn(PGconn *conn)
diff -ruN ../tmp/src/interfaces/libpq/fe-exec.c ./src/interfaces/libpq/fe-exec.c
--- ../tmp/src/interfaces/libpq/fe-exec.c 2026-02-06 13:03:06.060890335 +0000
+++ ./src/interfaces/libpq/fe-exec.c 2026-02-06 13:05:13.935067795 +0000
@@ -4545,3 +4545,9 @@
return conn->result;
}
@ -12,11 +11,10 @@ index 2265ab5..56883ec 100644
+ return psHandleRowData(conn, is_first_packet, result);
+}
+
diff --git src/interfaces/libpq/fe-misc.c src/interfaces/libpq/fe-misc.c
index 488f7d6..65beb87 100644
--- src/interfaces/libpq/fe-misc.c
+++ src/interfaces/libpq/fe-misc.c
@@ -1344,3 +1344,39 @@ libpq_append_conn_error(PGconn *conn, const char *fmt,...)
diff -ruN ../tmp/src/interfaces/libpq/fe-misc.c ./src/interfaces/libpq/fe-misc.c
--- ../tmp/src/interfaces/libpq/fe-misc.c 2025-08-11 21:06:43.000000000 +0000
+++ ./src/interfaces/libpq/fe-misc.c 2026-02-06 13:05:13.936067804 +0000
@@ -1367,3 +1367,39 @@
appendPQExpBufferChar(&conn->errorMessage, '\n');
}
@ -56,11 +54,10 @@ index 488f7d6..65beb87 100644
+ *result = (int) pg_ntoh32(tmp4);
+ return 0;
+}
diff --git src/interfaces/libpq/fe-protocol3.c src/interfaces/libpq/fe-protocol3.c
index 9c4aa7e..de0746c 100644
--- src/interfaces/libpq/fe-protocol3.c
+++ src/interfaces/libpq/fe-protocol3.c
@@ -2299,3 +2299,109 @@ build_startup_packet(const PGconn *conn, char *packet,
diff -ruN ../tmp/src/interfaces/libpq/fe-protocol3.c ./src/interfaces/libpq/fe-protocol3.c
--- ../tmp/src/interfaces/libpq/fe-protocol3.c 2025-08-11 21:06:43.000000000 +0000
+++ ./src/interfaces/libpq/fe-protocol3.c 2026-02-06 13:05:13.936067804 +0000
@@ -2299,3 +2299,109 @@
return packet_len;
}
@ -170,15 +167,13 @@ index 9c4aa7e..de0746c 100644
+ return 1;
+}
+
diff --git src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-fe.h
index c5170d1..3e3cc34 100644
--- src/interfaces/libpq/libpq-fe.h
+++ src/interfaces/libpq/libpq-fe.h
@@ -269,6 +269,18 @@ typedef struct pgresAttDesc
int atttypmod; /* type-specific modifier info */
diff -ruN ../tmp/src/interfaces/libpq/libpq-fe.h ./src/interfaces/libpq/libpq-fe.h
--- ../tmp/src/interfaces/libpq/libpq-fe.h 2026-02-06 13:03:06.060890335 +0000
+++ ./src/interfaces/libpq/libpq-fe.h 2026-02-06 13:05:13.936067804 +0000
@@ -270,6 +270,18 @@
} PGresAttDesc;
+/* ----------------
/* ----------------
+ * PSresult --
+ * ----------------
+ */
@ -190,10 +185,11 @@ index c5170d1..3e3cc34 100644
+ //int fieldcount;
+} PSresult;
+
/* ----------------
+/* ----------------
* Exported functions of libpq
* ----------------
@@ -671,6 +683,9 @@ extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn);
*/
@@ -671,6 +683,9 @@
/* Get PGresult directly from PGconn. WARNING: DO NOT RELEASE THIS RESULT */
extern const PGresult *PQgetResultFromPGconn(PGconn *conn);
@ -203,11 +199,10 @@ index c5170d1..3e3cc34 100644
#ifdef __cplusplus
}
#endif
diff --git src/interfaces/libpq/libpq-int.h src/interfaces/libpq/libpq-int.h
index a951f49..e1df8b5 100644
--- src/interfaces/libpq/libpq-int.h
+++ src/interfaces/libpq/libpq-int.h
@@ -727,6 +727,11 @@ extern PGresult *pqFunctionCall3(PGconn *conn, Oid fnid,
diff -ruN ../tmp/src/interfaces/libpq/libpq-int.h ./src/interfaces/libpq/libpq-int.h
--- ../tmp/src/interfaces/libpq/libpq-int.h 2025-08-11 21:06:43.000000000 +0000
+++ ./src/interfaces/libpq/libpq-int.h 2026-02-06 13:05:13.936067804 +0000
@@ -728,6 +728,11 @@
int result_is_int,
const PQArgBlock *args, int nargs);
@ -219,7 +214,7 @@ index a951f49..e1df8b5 100644
/* === in fe-misc.c === */
/*
@@ -756,6 +761,13 @@ extern int pqWaitTimed(int forRead, int forWrite, PGconn *conn,
@@ -757,6 +762,13 @@
extern int pqReadReady(PGconn *conn);
extern int pqWriteReady(PGconn *conn);

@ -0,0 +1,63 @@
# Compiling ProxySQL on macOS
This guide provides step-by-step instructions for compiling ProxySQL from source on macOS (Intel or Apple Silicon) using Homebrew.
## Prerequisites
Ensure you have [Homebrew](https://brew.sh/) installed.
### Install Dependencies
Run the following command to install the required build tools and libraries:
```bash
brew install automake bzip2 cmake make git gpatch gnutls openssl@3 icu4c pkg-config libiconv zlib
```
## Compilation Steps
To compile ProxySQL, you must set the following environment variables so the build system can locate OpenSSL and other Homebrew-provided libraries.
### 1. Set Environment Variables
```bash
export PATH="/opt/homebrew/bin:$PATH"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig:$PKG_CONFIG_PATH"
export OPENSSL_ROOT_DIR="/opt/homebrew/opt/openssl@3"
```
### 2. Run the Build
You can now run the standard build command:
```bash
make
```
Or for a debug build:
```bash
make debug
```
## Troubleshooting
### Linking Issues
If the linker fails to find `libssl` or `libcrypto`, ensure that `OPENSSL_ROOT_DIR` and `PKG_CONFIG_PATH` are correctly set to point to your Homebrew OpenSSL installation.
### Missing ICU Headers
The build system is configured to find `icu4c` via Homebrew. If you encounter errors related to ICU, ensure `icu4c` is installed and the Homebrew prefix is correct.
### Building TAP Tests (Optional)
If you wish to run the TAP tests, you need to build the test dependencies first:
```bash
export OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)
make build_tap_test_debug
```
This will automatically:
1. Build the main ProxySQL debug binary.
2. Download and build MariaDB and MySQL connectors (patched for macOS compatibility).
3. Build the TAP test framework.

@ -9,7 +9,7 @@ endif
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
DISTRO := $(shell grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
DISTRO := $(shell if [ -f /etc/os-release ]; then grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"'; else echo "unknown"; fi)
CENTOSVER := Unknown
ifneq (,$(wildcard /etc/system-release))

@ -11,6 +11,7 @@
#include "configfile.hpp"
#include "proxy_defines.h"
#include "proxysql_utils.h"
#include <openssl/ssl.h>
namespace ez {
class ezOptionParser;

@ -26,17 +26,19 @@
#define ETIME ETIMEDOUT
#endif
#ifdef CXX17
#if defined(__APPLE__)
using std::conjunction;
#elif defined(CXX17)
template<class...> struct conjunction : std::true_type { };
template<class B1> struct std::conjunction<B1> : B1 { };
template<class B1, class... Bn>
struct std::conjunction<B1, Bn...>
struct std::conjunction<B1, Bn...>
: std::conditional<bool(B1::value), std::conjunction<Bn...>, B1>::type {};
#else
template<class...> struct conjunction : std::true_type { };
template<class B1> struct conjunction<B1> : B1 { };
template<class B1, class... Bn>
struct conjunction<B1, Bn...>
struct conjunction<B1, Bn...>
: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
#endif // CXX17
/**

@ -43,7 +43,9 @@ void Base_Thread::register_session(T thr, S _sess, bool up_start) {
// }
_sess->match_regexes=match_regexes;
if constexpr (std::is_same_v<T, PgSQL_Thread*>) {
#ifdef IDLE_THREADS
_sess->copy_cmd_matcher = (static_cast<PgSQL_Thread*>(this))->copy_cmd_matcher;
#endif
}
if (up_start)

@ -12,6 +12,7 @@
#include <functional>
#include <memory>
#include <queue>
#include <climits>
#include <stdint.h>
#include <utility>
#include <vector>
@ -1820,7 +1821,7 @@ void* worker_thread(void* args) {
add_task(task_poll, POLLOUT, std::move(init_st));
}
uint64_t next_timeout_at = ULONG_LONG_MAX;
uint64_t next_timeout_at = ULLONG_MAX;
uint64_t tasks_start = monotonic_time();
// Continue processing tasks; Next async operation

@ -2709,10 +2709,12 @@ PgSQL_Thread::~PgSQL_Thread() {
match_regexes = NULL;
}
#ifdef IDLE_THREADS
if (copy_cmd_matcher) {
delete copy_cmd_matcher;
copy_cmd_matcher = NULL;
}
#endif
if (thr_SetParser != NULL) {
delete thr_SetParser;
@ -2767,7 +2769,9 @@ bool PgSQL_Thread::init() {
match_regexes[2] = new Session_Regex((char*)"^SET(?: +)(|SESSION +)TRANSACTION(?: +)(?:(?:(ISOLATION(?: +)LEVEL)(?: +)(REPEATABLE(?: +)READ|READ(?: +)COMMITTED|READ(?: +)UNCOMMITTED|SERIALIZABLE))|(?:(READ)(?: +)(WRITE|ONLY)))");
match_regexes[3] = new Session_Regex((char*)"^SET(?: +)(|SESSION +)`?(client_encoding|names)`?( *)(|=|TO)( *)");
#ifdef IDLE_THREADS
copy_cmd_matcher = new CopyCmdMatcher();
#endif
return true;
}
@ -4010,7 +4014,9 @@ PgSQL_Thread::PgSQL_Thread() {
status_variables.stvar[i] = 0;
}
match_regexes = NULL;
#ifdef IDLE_THREADS
copy_cmd_matcher = NULL;
#endif
variables.min_num_servers_lantency_awareness = 1000;
variables.aurora_max_lag_ms_only_read_from_replicas = 2;

@ -2823,8 +2823,10 @@ ProxySQL_Admin::ProxySQL_Admin() :
// processlist configuration
variables.mysql_processlist.show_extended = 0;
variables.pgsql_processlist.show_extended = 0;
#ifdef IDLE_THREADS
variables.mysql_processlist.show_idle_session = true;
variables.pgsql_processlist.show_idle_session = true;
#endif
variables.mysql_processlist.max_query_length = PROCESSLIST_MAX_QUERY_LEN_DEFAULT;
variables.pgsql_processlist.max_query_length = PROCESSLIST_MAX_QUERY_LEN_DEFAULT;

@ -496,6 +496,8 @@ const void sqlite3_global_stats_row_step(
if constexpr (std::is_same_v<T, int32_t>) {
sprintf(buf, "%d", val);
} else if constexpr (std::is_same_v<T, uint64_t>) {
sprintf(buf, "%lu", (unsigned long)val);
} else if constexpr (std::is_same_v<T, unsigned long>) {
sprintf(buf, "%lu", val);
} else if constexpr (std::is_same_v<T, unsigned long long>) {
sprintf(buf, "%llu", val);

@ -340,7 +340,9 @@ void update_string_var_if_set(char** cur_val, ez::ezOptionParser* opt, const cha
void update_ulong_var_if_set(uint64_t& cur_val, ez::ezOptionParser* opt, const char* cmd_opt) {
if (opt->isSet(cmd_opt)) {
opt->get(cmd_opt)->getULong(cur_val);
unsigned long val;
opt->get(cmd_opt)->getULong(val);
cur_val = val;
}
}

@ -19,7 +19,9 @@
#include <unistd.h>
#include <dirent.h>
#include <sys/syscall.h>
#ifdef __linux__
#include <linux/close_range.h>
#endif
using std::function;
using std::string;

@ -1,7 +1,29 @@
/* SHA256-based Unix crypt implementation.
Released into the Public Domain by Ulrich Drepper <drepper@redhat.com>. */
#ifdef __APPLE__
#include <machine/endian.h>
#include <libkern/OSByteOrder.h>
#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)
#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)
#define htobe64(x) OSSwapHostToBigInt64(x)
#define htole64(x) OSSwapHostToLittleInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)
#define mempcpy(dest, src, n) ((char *)memcpy(dest, src, n) + (n))
#else
#include <endian.h>
#endif
#include <errno.h>
#include <limits.h>
#include <stdint.h>

@ -119,7 +119,7 @@ endif
endif
ifeq ($(UNAME_S),Darwin)
MYLIBS :=-lre2 -lmariadbclient -lpq -lpthread -lm -lz -liconv -lgnutls -lprometheus-cpp-pull -lprometheus-cpp-core -luuid
MYLIBS :=-lre2 -lmariadbclient -lssl -lcrypto -lpthread -lm -lz -liconv -lgnutls -lprometheus-cpp-pull -lprometheus-cpp-core -luuid
else
CURL_DIR := $(DEPS_PATH)/curl/curl
IDIRS += -L$(CURL_DIR)/include
@ -151,6 +151,11 @@ ifeq ($(UNAME_S),Darwin)
LIBPROXYSQLAR += $(SQLITE3_LDIR)/sqlite3.o
LIBPROXYSQLAR += $(LIBINJECTION_LDIR)/libinjection.a
LIBPROXYSQLAR += $(EV_LDIR)/libev.a
LIBPROXYSQLAR += $(LIBSCRAM_LDIR)/libscram.a
LIBPROXYSQLAR += $(LIBUSUAL_LDIR)/libusual.a
LIBPROXYSQLAR += $(POSTGRESQL_PATH)/interfaces/libpq/libpq.a
LIBPROXYSQLAR += $(POSTGRESQL_PATH)/common/libpgcommon.a
LIBPROXYSQLAR += $(POSTGRESQL_PATH)/port/libpgport.a
endif
LIBPROXYSQLAR += $(CITYHASH_LDIR)/libcityhash.a
ifeq ($(PROXYSQLGENAI),1)

@ -3,6 +3,8 @@
PROXYSQL_PATH := $(shell while [ ! -f ./src/proxysql_global.cpp ]; do cd ..; done; pwd)
DEPS_PATH := $(PROXYSQL_PATH)/deps
include $(PROXYSQL_PATH)/include/makefiles_vars.mk
include $(PROXYSQL_PATH)/include/makefiles_paths.mk
.DEFAULT: default
@ -20,8 +22,16 @@ mariadb-connector-c/mariadb-connector-c/libmariadb/libmariadbclient.a:
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
ifeq ($(UNAME_S),Darwin)
cd mariadb-connector-c/mariadb-connector-c && cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DOPENSSL_ROOT_DIR=$(SSL_IDIR) -DOPENSSL_LIBRARIES=$(SSL_LDIR) -DICONV_LIBRARIES=$$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$$(brew --prefix libiconv)/include
else
cd mariadb-connector-c/mariadb-connector-c && cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_POLICY_VERSION_MINIMUM=3.5
endif
ifeq ($(UNAME_S),Darwin)
cd mariadb-connector-c/mariadb-connector-c && CC=${CC} CXX=${CXX} ${MAKE} -j1 mariadbclient
else
cd mariadb-connector-c/mariadb-connector-c && CC=${CC} CXX=${CXX} ${MAKE} mariadbclient
endif
mariadb_client: mariadb-connector-c/mariadb-connector-c/libmariadb/libmariadbclient.a
@ -31,9 +41,25 @@ mysql-connector-c/mysql-boost-5.7.44.tar.gz:
mysql-connector-c/mysql-connector-c/libmysql/libmysqlclient.a: mysql-connector-c/mysql-boost-5.7.44.tar.gz
cd mysql-connector-c && rm -rf mysql-*/ || true
cd mysql-connector-c && tar -zxf mysql-boost-5.7.*.tar.gz
ifeq ($(UNAME_S),Darwin)
cd mysql-connector-c && mysql_dir=$$(ls -1d mysql-5.7.*/) && \
sed -i '' 's/CMAKE_POLICY(SET CMP0018 OLD)/CMAKE_POLICY(SET CMP0018 NEW)/' $${mysql_dir}CMakeLists.txt && \
sed -i '' 's/CMAKE_POLICY(SET CMP0022 OLD)/CMAKE_POLICY(SET CMP0022 NEW)/' $${mysql_dir}CMakeLists.txt && \
sed -i '' 's/CMAKE_POLICY(SET CMP0045 OLD)/CMAKE_POLICY(SET CMP0045 NEW)/' $${mysql_dir}CMakeLists.txt && \
sed -i '' 's/CMAKE_POLICY(SET CMP0042 OLD)/CMAKE_POLICY(SET CMP0042 NEW)/' $${mysql_dir}CMakeLists.txt && \
sed -i '' 's/CMAKE_POLICY(SET CMP0075 OLD)/CMAKE_POLICY(SET CMP0075 NEW)/' $${mysql_dir}CMakeLists.txt && \
sed -i '' 's/# ifndef fdopen/# if !defined(fdopen) \&\& !defined(__APPLE__)/' $${mysql_dir}extra/zlib/zlib-1.2.13/zutil.h
cd mysql-connector-c && ln -fsh $$(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" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DWITH_SSL=$$(brew --prefix openssl@3) -DOPENSSL_ROOT_DIR=$$(brew --prefix openssl@3)
else
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"
cd mysql-connector-c/mysql-connector-c && cmake . -DWITH_BOOST=./boost -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O0 -ggdb -DNDEBUG -fPIC" -DCMAKE_POLICY_VERSION_MINIMUM=3.5
endif
ifeq ($(UNAME_S),Darwin)
cd mysql-connector-c/mysql-connector-c && CC=${CC} CXX=${CXX} ${MAKE} -j1 mysqlclient mysql
else
cd mysql-connector-c/mysql-connector-c && CC=${CC} CXX=${CXX} ${MAKE} mysqlclient mysql
endif
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
@ -44,11 +70,25 @@ mysql-connector-c-8.4.0/mysql-8.4.0.tar.gz:
mysql-connector-c-8.4.0/mysql-connector-c/libmysql/libmysqlclient.a: mysql-connector-c-8.4.0/mysql-8.4.0.tar.gz
cd mysql-connector-c-8.4.0 && rm -rf mysql-*/ || true
cd mysql-connector-c-8.4.0 && tar -zxf mysql-*.tar.gz
ifeq ($(UNAME_S),Darwin)
cd mysql-connector-c-8.4.0 && mysql_dir=$$(ls -1d mysql-8.4.*/) && \
sed -i '' 's/# ifndef fdopen/# if !defined(fdopen) \&\& !defined(__APPLE__)/' $${mysql_dir}extra/zlib/zlib-1.2.13/zutil.h
cd mysql-connector-c-8.4.0 && ln -fsh $$(ls -1d mysql-8.4.*/) mysql-connector-c
cd mysql-connector-c-8.4.0/mysql-connector-c && patch -p0 --batch < ../../mysql-8.4.0-clang17.patch
cd mysql-connector-c-8.4.0/mysql-connector-c && cmake . -DFORCE_INSOURCE_BUILD=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DWITHOUT_SERVER=ON -DDOWNLOAD_BOOST=1 -DWITH_BOOST=./mysql-server/downloads/ -DWITH_UNIT_TESTS=OFF \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O0 -ggdb -DNDEBUG -fPIC" -DWITH_SSL=$$(brew --prefix openssl@3) -DOPENSSL_ROOT_DIR=$$(brew --prefix openssl@3)
else
cd mysql-connector-c-8.4.0 && ln -fsT $$(ls -1d mysql-8.4.*/) mysql-connector-c
cd mysql-connector-c-8.4.0/mysql-connector-c && cmake . -DFORCE_INSOURCE_BUILD=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
cd mysql-connector-c-8.4.0/mysql-connector-c && cmake . -DFORCE_INSOURCE_BUILD=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DWITHOUT_SERVER=ON -DDOWNLOAD_BOOST=1 -DWITH_BOOST=./mysql-server/downloads/ -DWITH_UNIT_TESTS=OFF \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O0 -ggdb -DNDEBUG -fPIC"
endif
ifeq ($(UNAME_S),Darwin)
cd mysql-connector-c-8.4.0/mysql-connector-c && CC=${CC} CXX=${CXX} ${MAKE} -j1
else
cd mysql-connector-c-8.4.0/mysql-connector-c && CC=${CC} CXX=${CXX} ${MAKE}
endif
cd mysql-connector-c-8.4.0/mysql-connector-c && cp archive_output_directory/libmysqlclient.a libmysql/
mysql8_client: mysql-connector-c-8.4.0/mysql-connector-c/libmysql/libmysqlclient.a

@ -0,0 +1,178 @@
--- libs/mysql/serialization/archive.h 2024-04-10 08:26:28
+++ libs/mysql/serialization/archive.h 2026-01-21 00:07:15
@@ -81,14 +81,15 @@
/// @note To be implemented in Archive_derived_type
template <typename Type>
static std::size_t get_size(Type &&arg) {
- return Archive_derived_type::template get_size(std::forward<Type>(arg));
+ return Archive_derived_type::template get_size<Type>(
+ std::forward<Type>(arg));
}
/// @brief Returns archive size - size of data written to the archive
/// @return archive size - size of data written to the archive
/// @note To be implemented in Archive_derived_type
inline std::size_t get_size_written() const {
- return Archive_derived_type::template get_size_written();
+ return Archive_derived_type::get_size_written();
}
/// @brief Function returns maximum size of the Type
--- libs/mysql/serialization/serializer_impl.hpp 2024-04-10 08:26:28
+++ libs/mysql/serialization/serializer_impl.hpp 2026-01-21 00:07:15
@@ -51,8 +51,8 @@
Serializer<Serializer_derived_type, Archive_type>::get_size_field_def(
Field_id_type field_id,
const Field_definition<Field_type, field_size_defined> &field_definition) {
- return Serializer_derived_type::template get_size_field_def(field_id,
- field_definition);
+ return Serializer_derived_type::template get_size_field_def<
+ Field_type, field_size_defined>(field_id, field_definition);
}
template <class Serializer_derived_type, class Archive_type>
@@ -61,8 +61,8 @@
Serializer<Serializer_derived_type, Archive_type>::get_size_serializable(
Field_id_type field_id, const Serializable_concrete_type &serializable,
bool skip_id) {
- return Serializer_derived_type::template get_size_serializable(
- field_id, serializable, skip_id);
+ return Serializer_derived_type::template get_size_serializable<
+ Serializable_concrete_type>(field_id, serializable, skip_id);
}
template <class Serializer_derived_type, class Archive_type>
@@ -83,8 +83,8 @@
template <class Serializer_derived_type, class Archive_type>
template <typename T>
-Serializer<Serializer_derived_type, Archive_type>
- &Serializer<Serializer_derived_type, Archive_type>::operator>>(T &arg) {
+Serializer<Serializer_derived_type, Archive_type> &
+Serializer<Serializer_derived_type, Archive_type>::operator>>(T &arg) {
Field_id_type field_id = serialization_format_version;
// passing 0 as serializable_end_pos
decode_serializable(m_level, field_id, 0, arg, false);
@@ -101,12 +101,11 @@
void Serializer<Serializer_derived_type, Archive_type>::
encode_serializable_fields(const Serializable_type &serializable,
Level_type level) {
- auto process_serializable =
- [ this, level ](const auto &field, auto field_id) -> auto {
+ auto process_serializable = [this, level](const auto &field,
+ auto field_id) -> auto {
this->encode_serializable(level, field_id, field, false);
};
- auto process_field =
- [ this, level ](const auto &field, auto field_id) -> auto {
+ auto process_field = [this, level](const auto &field, auto field_id) -> auto {
this->encode_field(level, field_id, field);
++field_id;
};
@@ -139,13 +138,13 @@
decode_serializable_fields(Serializable_type &serializable,
Level_type level,
std::size_t serializable_end_pos) {
- auto process_serializable = [ this, level, serializable_end_pos ](
- auto &field, auto field_id) -> auto {
+ auto process_serializable = [this, level, serializable_end_pos](
+ auto &field, auto field_id) -> auto {
this->decode_serializable(level, field_id, serializable_end_pos, field,
false);
};
- auto process_field = [ this, level, serializable_end_pos ](
- auto &field, auto field_id) -> auto {
+ auto process_field = [this, level, serializable_end_pos](
+ auto &field, auto field_id) -> auto {
this->decode_field(level, field_id, serializable_end_pos, field);
++field_id;
--- libs/mysql/serialization/serializer_default_impl.hpp 2024-04-10 08:26:28
+++ libs/mysql/serialization/serializer_default_impl.hpp 2026-01-21 00:11:38
@@ -205,8 +205,8 @@
template <class Field_type, Field_size field_size_defined, typename Enabler>
void Serializer_default<Archive_concrete_type>::encode_field(
const Field_type &field, Serializer_array_tag) {
- using value_type = std::remove_reference_t<decltype(
- *std::begin(std::declval<Field_type &>()))>;
+ using value_type = std::remove_reference_t<decltype(*std::begin(
+ std::declval<Field_type &>()))>;
for (const auto &internal_field : field) {
// we use default size for internal fields (0)
encode_field<value_type, 0>(internal_field);
@@ -219,8 +219,8 @@
template <class Field_type, Field_size field_size_defined, typename Enabler>
void Serializer_default<Archive_concrete_type>::decode_field(
Field_type &field, Serializer_array_tag) {
- using value_type = std::remove_reference_t<decltype(
- *std::begin(std::declval<Field_type &>()))>;
+ using value_type = std::remove_reference_t<decltype(*std::begin(
+ std::declval<Field_type &>()))>;
for (auto &internal_field : field) {
// we use default size for internal fields (0)
decode_field<value_type, 0>(internal_field);
@@ -233,7 +233,8 @@
template <class Field_type, Field_size field_size_defined, typename Enabler>
std::size_t Serializer_default<Archive_concrete_type>::get_field_size(
const Field_type &field) {
- return Archive_concrete_type::template get_size(
+ return Archive_concrete_type::template get_size<
+ Field_wrapper<const Field_type, field_size_defined>>(
Field_wrapper<const Field_type, field_size_defined>(field));
}
@@ -304,8 +305,8 @@
std::size_t Serializer_default<Archive_concrete_type>::get_field_size(
const Field_type &field, Serializer_array_tag) {
std::size_t field_size = 0;
- using value_type = std::remove_reference_t<decltype(
- *std::begin(std::declval<Field_type &>()))>;
+ using value_type = std::remove_reference_t<decltype(*std::begin(
+ std::declval<Field_type &>()))>;
for (const auto &internal_field : field) {
field_size += get_field_size<value_type, 0>(internal_field);
}
@@ -397,7 +398,7 @@
}
};
auto func_f = [&last_non_ignorable_field_id](
- const auto &field, auto processed_field_id) -> auto {
+ const auto &field, auto processed_field_id) -> auto {
if (field.run_encode_predicate() && field.is_field_ignorable() == false) {
last_non_ignorable_field_id = processed_field_id + 1;
}
@@ -473,8 +474,8 @@
std::size_t calculated_size = 0;
bool is_provided = field_definition.run_encode_predicate();
if (is_provided) {
- auto size_id_type = Archive_concrete_type::template get_size(
- create_varlen_field_wrapper(field_id));
+ auto size_id_type = Archive_concrete_type::template get_size<
+ Field_wrapper<Field_id_type, 0>>(create_varlen_field_wrapper(field_id));
calculated_size = get_field_size<Field_type, field_size_defined>(
field_definition.get_ref()) +
size_id_type;
@@ -489,18 +490,19 @@
bool skip_id) {
std::size_t serializable_overhead_type = 0;
if (skip_id == false) {
- serializable_overhead_type = Archive_concrete_type::template get_size(
- create_varlen_field_wrapper(field_id));
+ serializable_overhead_type = Archive_concrete_type::template get_size<
+ Field_wrapper<Field_id_type, 0>>(create_varlen_field_wrapper(field_id));
}
auto serializable_size = serializable.template get_size_internal<Base_type>();
- auto serializable_overhead_size = Archive_concrete_type::template get_size(
+ auto serializable_overhead_size = Archive_concrete_type::template get_size<
+ Field_wrapper<decltype(serializable_size), 0>>(
create_varlen_field_wrapper(serializable_size));
Field_id_type last_non_ignorable_field_id =
find_last_non_ignorable_field_id(serializable);
auto serializable_overhead_last_non_ignorable_field_id =
- Archive_concrete_type::template get_size(
+ Archive_concrete_type::template get_size<Field_wrapper<Field_id_type, 0>>(
create_varlen_field_wrapper(last_non_ignorable_field_id));
return serializable_overhead_type + serializable_overhead_size +
serializable_overhead_last_non_ignorable_field_id + serializable_size;
Loading…
Cancel
Save