From 8ec62a01d0394d4a7c19138107fa915db4b39e78 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 10:59:06 -0500 Subject: [PATCH 01/12] Ensure CopyCmdMatcher exists even without IDLE_THREADS being defined --- include/PgSQL_Thread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/PgSQL_Thread.h b/include/PgSQL_Thread.h index 35657449a5..da08e70f42 100644 --- a/include/PgSQL_Thread.h +++ b/include/PgSQL_Thread.h @@ -226,10 +226,10 @@ class __attribute__((aligned(64))) PgSQL_Thread : public Base_Thread //PtrArray* mysql_sessions; PtrArray* mirror_queue_mysql_sessions; PtrArray* mirror_queue_mysql_sessions_cache; + CopyCmdMatcher *copy_cmd_matcher; #ifdef IDLE_THREADS PtrArray* idle_mysql_sessions; PtrArray* resume_mysql_sessions; - CopyCmdMatcher *copy_cmd_matcher; pgsql_conn_exchange_t myexchange; #endif // IDLE_THREADS From 44ce78cc5205f9cba5c78009ddaa446aa7ab5b50 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 10:59:48 -0500 Subject: [PATCH 02/12] Add missing FreeBSD includes/definitions for ULLONG_MAX --- lib/PgSQL_Monitor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/PgSQL_Monitor.cpp b/lib/PgSQL_Monitor.cpp index 4db02cf77a..fce3c62ce0 100644 --- a/lib/PgSQL_Monitor.cpp +++ b/lib/PgSQL_Monitor.cpp @@ -17,6 +17,11 @@ #include #include +#ifdef __FreeBSD__ +#include +#define ULONG_LONG_MAX ULLONG_MAX +#endif + using std::function; using std::unique_ptr; using std::vector; From cbe4eb679387d861a0ee5919387f8b222f7b9be8 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 11:00:34 -0500 Subject: [PATCH 03/12] Add missing include for AF_INET* under FreeBSD --- lib/proxy_protocol_info.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/proxy_protocol_info.cpp b/lib/proxy_protocol_info.cpp index 522463f643..2e84235283 100644 --- a/lib/proxy_protocol_info.cpp +++ b/lib/proxy_protocol_info.cpp @@ -3,6 +3,9 @@ #include #include #include +#ifdef __FreeBSD__ +#include +#endif static bool DEBUG_ProxyProtocolInfo = false; From 3eec7d32bfd9bed2e3acabd295a1e10b3f2a2551 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 11:15:45 -0500 Subject: [PATCH 04/12] Ignore whitespace when applying postgres patches --- deps/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/Makefile b/deps/Makefile index 59440ec1f2..38ed8c0a7e 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -302,7 +302,7 @@ 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 - cd postgresql/postgresql && patch -p0 < ../get_result_from_pgconn.patch + cd postgresql/postgresql && patch -p0 -l < ../get_result_from_pgconn.patch cd postgresql/postgresql && patch -p0 < ../handle_row_data.patch cd postgresql/postgresql && patch -p0 < ../fmt_err_msg.patch cd postgresql/postgresql && patch -p0 < ../bind_fmt_text.patch From 2e33b70613e0ad212b9cae2c7366f18be6b0493f Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 11:16:48 -0500 Subject: [PATCH 05/12] Explicitly disable ICU support when building libpq --- deps/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/Makefile b/deps/Makefile index 38ed8c0a7e..15e8674056 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -307,7 +307,7 @@ 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 && 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" - cd postgresql/postgresql && LD_LIBRARY_PATH="$(SSL_LDIR)" ./configure --with-ssl=openssl --with-includes="$(SSL_IDIR)" --with-libraries="$(SSL_LDIR)" --without-readline + cd postgresql/postgresql && LD_LIBRARY_PATH="$(SSL_LDIR)" ./configure --with-ssl=openssl --with-includes="$(SSL_IDIR)" --with-libraries="$(SSL_LDIR)" --without-readline --without-icu 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 From ce6f5f8c1e826c4a9d09252114a1f860eaa08439 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 11:18:12 -0500 Subject: [PATCH 06/12] Do not try to enable EPOLL under FreeBSD or Darwin --- lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Makefile b/lib/Makefile index 8653118f00..a405fb7c88 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -51,7 +51,7 @@ endif # 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) +ifeq (,$(findstring $(OS),Darwin FreeBSD)) ENABLE_EPOLL := endif From 64b38875fdd0c69bc55c06d151769877d861afae Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 11:43:43 -0500 Subject: [PATCH 07/12] Do not require gnugrep --- common_mk/openssl_flags.mk | 6 +++--- common_mk/openssl_version_check.mk | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common_mk/openssl_flags.mk b/common_mk/openssl_flags.mk index 4b709e7aa9..5054274763 100644 --- a/common_mk/openssl_flags.mk +++ b/common_mk/openssl_flags.mk @@ -14,12 +14,12 @@ $(info OPENSSL_PACKAGE: $(OPENSSL_PACKAGE)) ifeq ($(CUSTOM_OPENSSL_PATH),) $(info No custom path specified.) ifeq ($(OPENSSL_PACKAGE),openssl3) - SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | grep -oP "(?<=-I)[^ ]+") + SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | sed 's/-I//g') 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 - 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)[^ ]+") + SSL_IDIR := $(shell export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1; export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1; pkg-config --cflags $(OPENSSL_PACKAGE) | sed 's/-I//g') 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) @@ -44,4 +44,4 @@ else endif else $(error Warning: OpenSSL headers (SSL_IDIR) not found. Exiting. Please install OpenSSL version 3.) -endif \ No newline at end of file +endif diff --git a/common_mk/openssl_version_check.mk b/common_mk/openssl_version_check.mk index fceccbca1a..d75128fdfb 100644 --- a/common_mk/openssl_version_check.mk +++ b/common_mk/openssl_version_check.mk @@ -11,7 +11,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 OPENSSL_VERSION_STR $$header_path | awk -F\" '{print $2}'); \ if [ -z "$$version_number" ]; then \ echo "Failed to extract OPENSSL_VERSION_STR from $$header_path"; \ exit 1; \ @@ -41,4 +41,4 @@ check_openssl_version: echo "OpenSSL version must be >= $(REQUIRED_OPENSSL_VERSION). Detected: $$openssl_version"; \ exit 1; \ fi; \ - fi \ No newline at end of file + fi From a7dc62e93a6e033f25a840121416d576f0788551 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 11:56:35 -0500 Subject: [PATCH 08/12] Update OS -> UNAME_S for EPOLL check Signed-off-by: Ryan Steinmetz --- lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Makefile b/lib/Makefile index a405fb7c88..d4e2836c4f 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -51,7 +51,7 @@ endif # 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 (,$(findstring $(OS),Darwin FreeBSD)) +ifeq (,$(findstring $(UNAME_S),Darwin FreeBSD)) ENABLE_EPOLL := endif From b1c0f3585c611367203f6b15b16f77fc41947ba5 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 12:04:12 -0500 Subject: [PATCH 09/12] Update sed expression used Signed-off-by: Ryan Steinmetz --- common_mk/openssl_flags.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common_mk/openssl_flags.mk b/common_mk/openssl_flags.mk index 5054274763..7b7cc1bc24 100644 --- a/common_mk/openssl_flags.mk +++ b/common_mk/openssl_flags.mk @@ -14,7 +14,7 @@ $(info OPENSSL_PACKAGE: $(OPENSSL_PACKAGE)) ifeq ($(CUSTOM_OPENSSL_PATH),) $(info No custom path specified.) ifeq ($(OPENSSL_PACKAGE),openssl3) - SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | sed 's/-I//g') + SSL_IDIR := $(shell pkg-config --cflags $(OPENSSL_PACKAGE) | sed -n 's/.*-I\([^ ]*\).*/\1/p') 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) From 783a5b81d5f0b0e68edb049c26fa42074f2b92c7 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 12:04:57 -0500 Subject: [PATCH 10/12] Update sed expression Signed-off-by: Ryan Steinmetz --- common_mk/openssl_flags.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common_mk/openssl_flags.mk b/common_mk/openssl_flags.mk index 7b7cc1bc24..97d2764eaa 100644 --- a/common_mk/openssl_flags.mk +++ b/common_mk/openssl_flags.mk @@ -19,7 +19,7 @@ ifeq ($(CUSTOM_OPENSSL_PATH),) 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 - SSL_IDIR := $(shell export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1; export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1; pkg-config --cflags $(OPENSSL_PACKAGE) | sed 's/-I//g') + SSL_IDIR := $(shell export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1; export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1; pkg-config --cflags $(OPENSSL_PACKAGE) | sed -n 's/.*-I\([^ ]*\).*/\1/p') 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) From 53182a757ed5e6cc063173a63b0db339ca2ee1a5 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 12:10:50 -0500 Subject: [PATCH 11/12] Switch to sed for version extraction Signed-off-by: Ryan Steinmetz --- common_mk/openssl_version_check.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common_mk/openssl_version_check.mk b/common_mk/openssl_version_check.mk index d75128fdfb..f15d312e63 100644 --- a/common_mk/openssl_version_check.mk +++ b/common_mk/openssl_version_check.mk @@ -11,7 +11,7 @@ check_openssl_version: echo "OpenSSL header file not found at $$header_path"; \ exit 1; \ fi; \ - version_number=$$(grep OPENSSL_VERSION_STR $$header_path | awk -F\" '{print $2}'); \ + version_number=$$(grep OPENSSL_VERSION_STR $$header_path | sed -n 's/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/p'); \ if [ -z "$$version_number" ]; then \ echo "Failed to extract OPENSSL_VERSION_STR from $$header_path"; \ exit 1; \ From 9d7ab7d79f1b72bb938ad07399c838578500ae48 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 10 Nov 2025 12:14:38 -0500 Subject: [PATCH 12/12] Update Darwin/FreeBSD detection logic Signed-off-by: Ryan Steinmetz --- lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Makefile b/lib/Makefile index d4e2836c4f..37ef2bb079 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -51,7 +51,7 @@ endif # 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 (,$(findstring $(UNAME_S),Darwin FreeBSD)) +ifneq (,$(findstring $(UNAME_S),Darwin FreeBSD)) ENABLE_EPOLL := endif