aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Neumeister <joneum@FreeBSD.org>2023-12-18 06:51:37 +0000
committerJochen Neumeister <joneum@FreeBSD.org>2023-12-18 06:54:41 +0000
commit7e5dafecce04d97df3963192d41f25984c7e57d2 (patch)
treea8ff371587bfe302adfe76b7a196f8f4fc24a63b
parentcba62a5bdd98976ccbd3dacde1c9769ed936e520 (diff)
downloadports-7e5dafecce04d97df3963192d41f25984c7e57d2.tar.gz
ports-7e5dafecce04d97df3963192d41f25984c7e57d2.zip
add databases/mysql81-server and databases/mysql81-client
Welcome MySQL81 to the Port Tree Special thanks for help: fluffy, both Sponsored by: Netzkommune GmbH
-rw-r--r--Mk/Uses/mysql.mk1
-rw-r--r--Mk/bsd.default-versions.mk2
-rw-r--r--databases/Makefile2
-rw-r--r--databases/mysql81-client/Makefile47
-rw-r--r--databases/mysql81-client/pkg-message8
-rw-r--r--databases/mysql81-client/pkg-plist40
-rw-r--r--databases/mysql81-server/Makefile221
-rw-r--r--databases/mysql81-server/distinfo3
-rw-r--r--databases/mysql81-server/files/extra-patch-boost_boost__1__77__0_boost_move_detail_type__traits.hpp20
-rw-r--r--databases/mysql81-server/files/extra-patch-scripts_CMakeLists.txt10
-rw-r--r--databases/mysql81-server/files/extra-patch-storage_innobase_log_log0recv.cc11
-rw-r--r--databases/mysql81-server/files/my.cnf.sample.in57
-rw-r--r--databases/mysql81-server/files/mysql-server.in78
-rw-r--r--databases/mysql81-server/files/patch-CMakeLists.txt95
-rw-r--r--databases/mysql81-server/files/patch-client_CMakeLists.txt70
-rw-r--r--databases/mysql81-server/files/patch-cmake_install__layout.cmake95
-rw-r--r--databases/mysql81-server/files/patch-cmake_os_DragonFly.cmake27
-rw-r--r--databases/mysql81-server/files/patch-cmake_os_FreeBSD.cmake25
-rw-r--r--databases/mysql81-server/files/patch-cmake_plugin.cmake27
-rw-r--r--databases/mysql81-server/files/patch-cmake_ssl.cmake23
-rw-r--r--databases/mysql81-server/files/patch-include_my__compare.h11
-rw-r--r--databases/mysql81-server/files/patch-include_my__stacktrace.h11
-rw-r--r--databases/mysql81-server/files/patch-include_my__thread__os__id.h15
-rw-r--r--databases/mysql81-server/files/patch-include_myisam.h11
-rw-r--r--databases/mysql81-server/files/patch-libmysql_CMakeLists.txt68
-rw-r--r--databases/mysql81-server/files/patch-libservices_CMakeLists.txt12
-rw-r--r--databases/mysql81-server/files/patch-man_CMakeLists.txt76
-rw-r--r--databases/mysql81-server/files/patch-mysys_my__default.cc62
-rw-r--r--databases/mysql81-server/files/patch-mysys_my__kdf.cc20
-rw-r--r--databases/mysql81-server/files/patch-plugin_password__validation_validate__password.cc11
-rw-r--r--databases/mysql81-server/files/patch-plugin_x_CMakeLists.txt11
-rw-r--r--databases/mysql81-server/files/patch-plugin_x_client_authentication_sha256__scramble__generator.cc11
-rw-r--r--databases/mysql81-server/files/patch-plugin_x_configure.cmake15
-rw-r--r--databases/mysql81-server/files/patch-router_src_harness_include_mysql_harness_net__ts_impl_kqueue__io__service.h13
-rw-r--r--databases/mysql81-server/files/patch-router_src_harness_include_mysql_harness_net__ts_internet.h10
-rw-r--r--databases/mysql81-server/files/patch-router_src_harness_src_CMakeLists.txt24
-rw-r--r--databases/mysql81-server/files/patch-router_src_harness_src_tls__client__context.cc11
-rw-r--r--databases/mysql81-server/files/patch-router_src_harness_src_tls__context.cc44
-rw-r--r--databases/mysql81-server/files/patch-router_src_http_src_CMakeLists.txt26
-rw-r--r--databases/mysql81-server/files/patch-router_src_io_src_CMakeLists.txt10
-rw-r--r--databases/mysql81-server/files/patch-router_src_router_src_CMakeLists.txt10
-rw-r--r--databases/mysql81-server/files/patch-scripts_CMakeLists.txt52
-rw-r--r--databases/mysql81-server/files/patch-scripts_mysqld__safe.sh19
-rw-r--r--databases/mysql81-server/files/patch-sql_auth_sha2__password__common.cc11
-rw-r--r--databases/mysql81-server/files/patch-sql_auth_sql__authorization.cc13
-rw-r--r--databases/mysql81-server/files/patch-sql_conn__handler_socket__connection.cc32
-rw-r--r--databases/mysql81-server/files/patch-sql_mysqld.cc11
-rw-r--r--databases/mysql81-server/files/patch-sql_ssl__init__callback.cc36
-rw-r--r--databases/mysql81-server/files/patch-sql_sys__vars.cc29
-rw-r--r--databases/mysql81-server/files/patch-storage_innobase_include_srv0mon.h13
-rw-r--r--databases/mysql81-server/files/patch-storage_innobase_include_ut0crc32.h12
-rw-r--r--databases/mysql81-server/files/patch-storage_innobase_ut_crc32.cc104
-rw-r--r--databases/mysql81-server/files/patch-storage_myisam_mi__dynrec.cc22
-rw-r--r--databases/mysql81-server/files/patch-storage_temptable_include_temptable_lock__free__type.h17
-rw-r--r--databases/mysql81-server/files/patch-support-files_CMakeLists.txt39
-rw-r--r--databases/mysql81-server/files/patch-utilities_CMakeLists.txt79
-rw-r--r--databases/mysql81-server/files/patch-vio_viossl.cc30
-rw-r--r--databases/mysql81-server/files/patch-vio_viosslfactories.cc46
-rw-r--r--databases/mysql81-server/files/pkg-message.in21
-rw-r--r--databases/mysql81-server/pkg-descr12
-rw-r--r--databases/mysql81-server/pkg-plist253
61 files changed, 2194 insertions, 1 deletions
diff --git a/Mk/Uses/mysql.mk b/Mk/Uses/mysql.mk
index 6805867a0076..eb8419f56b59 100644
--- a/Mk/Uses/mysql.mk
+++ b/Mk/Uses/mysql.mk
@@ -67,6 +67,7 @@ DEFAULT_MYSQL_VER?= ${MYSQL_DEFAULT:S/.//}
MYSQL57_LIBVER= 20
MYSQL57p_LIBVER= 20
MYSQL80_LIBVER= 21
+MYSQL81_LIBVER= 22
. for v in 5 6 11
MYSQL10${v}m_LIBVER= 3
. endfor
diff --git a/Mk/bsd.default-versions.mk b/Mk/bsd.default-versions.mk
index 580a5be8c7c8..1c185478f6d9 100644
--- a/Mk/bsd.default-versions.mk
+++ b/Mk/bsd.default-versions.mk
@@ -105,7 +105,7 @@ LUAJIT_DEFAULT?= luajit-devel
. endif
# Possible values: 5.10, 5.20, 6.8
MONO_DEFAULT?= 5.20
-# Possible values: 5.7, 8.0, 10.5m, 10.6m, 10.11m, 5.7p, 5.7w
+# Possible values: 5.7, 8.0, 8.1, 10.5m, 10.6m, 10.11m, 5.7p, 5.7w
MYSQL_DEFAULT?= 8.0
# Possible values: ninja, samurai
NINJA_DEFAULT?= ninja
diff --git a/databases/Makefile b/databases/Makefile
index aa34af96a0e6..1419b72701ea 100644
--- a/databases/Makefile
+++ b/databases/Makefile
@@ -198,6 +198,8 @@
SUBDIR += mysql57-server
SUBDIR += mysql80-client
SUBDIR += mysql80-server
+ SUBDIR += mysql81-client
+ SUBDIR += mysql81-server
SUBDIR += mysqlbackup
SUBDIR += mysqldump-secure
SUBDIR += mysqlreport
diff --git a/databases/mysql81-client/Makefile b/databases/mysql81-client/Makefile
new file mode 100644
index 000000000000..398c1429a8d4
--- /dev/null
+++ b/databases/mysql81-client/Makefile
@@ -0,0 +1,47 @@
+PORTNAME= mysql
+PORTREVISION= 0
+PKGNAMESUFFIX= 81-client
+
+COMMENT= Multithreaded SQL database (client)
+
+LICENSE+= LGPL21
+
+MASTERDIR= ${.CURDIR}/../mysql81-server
+
+PKGMESSAGE= ${.CURDIR}/pkg-message
+PATCHDIR= ${MASTERDIR}/files
+PLIST= ${.CURDIR}/pkg-plist
+
+CONFLICTS_INSTALL= mysql8[1-9]-client \
+ mysql[0-79][0-9]-client \
+ mariadb[0-9][0-9]-client \
+ percona[0-9][0-9]-client
+
+CMAKE_ARGS+= -DWITHOUT_SERVER=1 -DINSTALL_SUPPORTFILESDIR=0
+
+USE_LDCONFIG+= ${PREFIX}/lib/mysql
+
+MMAN1= comp_err.1 lz4_decompress.1 mysql.1 mysql_config.1 mysql_config_editor.1 \
+ mysqladmin.1 mysqlbinlog.1 mysqlcheck.1 mysqldump.1 mysqlimport.1 mysqlman.1 \
+ mysqlpump.1 mysqlshow.1 mysqlslap.1 perror.1 zlib_decompress.1
+
+CLIENT_ONLY= yes
+
+OPTIONS_GROUP+= PLUGINS
+PLUGINS_DESC= Default Client Plugins
+OPTIONS_GROUP_PLUGINS= SASLCLIENT
+SASLCLIENT_DESC= SASL client plugin module
+SASLCLIENT_CMAKE_BOOL= WITH_AUTHENTICATION_LDAP
+SASLCLIENT_LIB_DEPENDS= libsasl2.so:security/cyrus-sasl2
+SASLCLIENT_USES= ldap
+
+OPTIONS_DEFAULT+= SASLCLIENT
+OPTIONS_SUB= yes
+
+post-install:
+ @${RM} -r ${STAGEDIR}${PREFIX}/lib/mysql/private
+ @${LN} -s libmysqlclient.a ${STAGEDIR}${PREFIX}/lib/mysql/libmysqlclient_r.a
+ @${LN} -s libmysqlclient.so ${STAGEDIR}${PREFIX}/lib/mysql/libmysqlclient_r.so
+ @${LN} -s libmysqlclient.so.22 ${STAGEDIR}${PREFIX}/lib/mysql/libmysqlclient_r.so.22
+
+.include "${MASTERDIR}/Makefile"
diff --git a/databases/mysql81-client/pkg-message b/databases/mysql81-client/pkg-message
new file mode 100644
index 000000000000..dbbd72fe1c67
--- /dev/null
+++ b/databases/mysql81-client/pkg-message
@@ -0,0 +1,8 @@
+[
+{ type: install
+ message: <<EOM
+This is the mysql CLIENT without the server.
+for complete server and client, please install databases/mysql80-server
+EOM
+}
+]
diff --git a/databases/mysql81-client/pkg-plist b/databases/mysql81-client/pkg-plist
new file mode 100644
index 000000000000..343d742a8e81
--- /dev/null
+++ b/databases/mysql81-client/pkg-plist
@@ -0,0 +1,40 @@
+bin/comp_err
+bin/my_print_defaults
+bin/mysql
+bin/mysql_config
+bin/mysql_config_editor
+bin/mysql_migrate_keyring
+bin/mysqladmin
+bin/mysqlbinlog
+bin/mysqlcheck
+bin/mysqldump
+bin/mysqlimport
+bin/mysqlpump
+bin/mysqlshow
+bin/mysqlslap
+bin/perror
+bin/zlib_decompress
+include/mysql/errmsg.h
+include/mysql/field_types.h
+include/mysql/my_command.h
+include/mysql/my_compress.h
+include/mysql/my_list.h
+include/mysql/mysql.h
+include/mysql/mysql/client_plugin.h
+include/mysql/mysql/plugin_auth_common.h
+include/mysql/mysql/udf_registration_types.h
+include/mysql/mysql_com.h
+include/mysql/mysql_time.h
+include/mysql/mysql_version.h
+include/mysql/mysqld_error.h
+lib/mysql/libmysqlclient.a
+lib/mysql/libmysqlclient.so
+lib/mysql/libmysqlclient.so.22
+lib/mysql/libmysqlclient_r.a
+lib/mysql/libmysqlclient_r.so
+lib/mysql/libmysqlclient_r.so.22
+lib/mysql/plugin/authentication_fido_client.so
+lib/mysql/plugin/authentication_ldap_sasl_client.so
+lib/mysql/plugin/authentication_oci_client.so
+libdata/pkgconfig/mysqlclient.pc
+share/aclocal/mysql.m4
diff --git a/databases/mysql81-server/Makefile b/databases/mysql81-server/Makefile
new file mode 100644
index 000000000000..6e1f76506644
--- /dev/null
+++ b/databases/mysql81-server/Makefile
@@ -0,0 +1,221 @@
+PORTNAME?= mysql
+PORTVERSION= 8.1.0
+PORTREVISION?= 0
+CATEGORIES= databases
+MASTER_SITES= MYSQL/MySQL-8.1
+PKGNAMESUFFIX?= 81-server
+DISTNAME= ${PORTNAME}-boost-${PORTVERSION}${DISTVERSIONSUFFIX}
+
+MAINTAINER= joneum@FreeBSD.org
+COMMENT?= Multithreaded SQL database (server)
+WWW= https://www.mysql.com/
+
+LICENSE= GPLv2
+
+WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION}${DISTVERSIONSUFFIX}
+
+SLAVEDIRS= databases/mysql81-client
+USES= bison:build cmake:noninja cpe groff:run libedit localbase \
+ ncurses perl5 pkgconfig shebangfix ssl
+
+CPE_VENDOR= oracle
+
+USE_CXXSTD= c++17
+USE_PERL5= run
+
+MY_DBDIR= /var/db/mysql
+MY_SECDIR= /var/db/mysql_secure
+MY_TMPDIR= /var/db/mysql_tmpdir
+
+LIB_DEPENDS+= libcurl.so:ftp/curl \
+ libevent.so:devel/libevent \
+ libicutu.so:devel/icu \
+ liblz4.so:archivers/liblz4 \
+ libfido2.so:security/libfido2 \
+ libhidapi.so:comms/hidapi \
+ ${LIB_DEPENDS_${ARCH}}
+LIB_DEPENDS_aarch64= libunwind.so:devel/libunwind
+LIB_DEPENDS_amd64= libunwind.so:devel/libunwind
+LIB_DEPENDS_armv7= libunwind.so:devel/libunwind
+LIB_DEPENDS_i386= libunwind.so:devel/libunwind
+LIB_DEPENDS_powerpc= libunwind.so:devel/libunwind
+LIB_DEPENDS_powerpc64= libunwind.so:devel/libunwind
+LIB_DEPENDS_powerpc64le= libunwind.so:devel/libunwind
+
+BUILD_DEPENDS= liblz4>0:archivers/liblz4 \
+ ${BUILD_DEPENDS_${ARCH}}
+BUILD_DEPENDS_aarch64= libunwind>0:devel/libunwind
+BUILD_DEPENDS_amd64= libunwind>0:devel/libunwind
+BUILD_DEPENDS_armv7= libunwind>0:devel/libunwind
+BUILD_DEPENDS_i386= libunwind>0:devel/libunwind
+BUILD_DEPENDS_powerpc= libunwind>0:devel/libunwind
+BUILD_DEPENDS_powerpc64= libunwind>0:devel/libunwind
+BUILD_DEPENDS_powerpc64le= libunwind>0:devel/libunwind
+
+CMAKE_BUILD_TYPE= Release
+CFLAGS+= -fPIC
+CFLAGS_aarch64?= -march=armv8-a+crc+crypto
+
+CMAKE_ARGS+= -DINSTALL_LAYOUT=FREEBSD \
+ -DINSTALL_LDCONFIGDIR="${LOCALBASE}/libdata/ldconfig" \
+ -DINSTALL_PKGCONFIGDIR="${LOCALBASE}/libdata/pkgconfig" \
+ -DINSTALL_DOCDIR="share/doc/mysql" \
+ -DINSTALL_DOCREADMEDIR="share/doc/mysql" \
+ -DINSTALL_INCLUDEDIR="include/mysql" \
+ -DINSTALL_INFODIR="${INFO_PATH}" \
+ -DINSTALL_LIBDIR="lib/mysql" \
+ -DINSTALL_PRIV_LIBDIR="lib/mysql/private" \
+ -DINSTALL_MANDIR="share/man" \
+ -DINSTALL_MYSQLDATADIR="${MY_DBDIR}" \
+ -DINSTALL_MYSQLKEYRINGDIR="etc/mysql/keyring" \
+ -DINSTALL_MYSQLSHAREDIR="share/mysql" \
+ -DINSTALL_MYSQLTESTDIR="" \
+ -DINSTALL_PLUGINDIR="lib/mysql/plugin" \
+ -DINSTALL_SBINDIR="libexec" \
+ -DINSTALL_SCRIPTDIR="bin" \
+ -DINSTALL_SECURE_FILE_PRIVDIR="${MY_SECDIR}" \
+ -DINSTALL_SHAREDIR="share" \
+ -DINSTALL_SUPPORTFILESDIR="share/mysql" \
+ -DMYSQL_KEYRINGDIR="${ETCDIR}/keyring" \
+ -DWITH_BOOST="${WRKSRC}/boost" \
+ -DWITH_SYSTEM_LIBS=1 \
+ -DWITH_EDITLINE=system \
+ -DWITH_LIBEVENT=system \
+ -DWITH_LZ4=system \
+ -DWITH_ICU=system \
+ -DWITH_CURL=system \
+ -DWITH_ZSTD=bundled \
+ -DWITH_PROTOBUF=bundled \
+ -DWITH_SSL=system \
+ -DWITH_AUTHENTICATION_FIDO=1 \
+ -DBUILD_BUNDLED_ZLIB=0 \
+ -DBUILD_BUNDLED_LZ4=0
+
+# The Mroonga, RocksDB, and TokuDB storage engines are disabled.
+# Mroonga is only buildable on little endian archs.
+# RocksDB is only buildable on little endian archs and requires POSIX timers.
+# TokuDB is only buildable on 64-bit little endian archs.
+CMAKE_ARGS+= -DWITHOUT_MROONGA_STORAGE_ENGINE=1 \
+ -DWITHOUT_ROCKSDB_STORAGE_ENGINE=1 \
+ -DWITHOUT_TOKUDB_STORAGE_ENGINE=1
+
+SHEBANG_FILES= scripts/*.pl* scripts/*.sh
+
+.ifdef USE_MYSQL
+IGNORE= You have `USE_MYSQL' variable defined either in environment or in make(1) arguments. Please undefine and try again.
+.endif
+
+SUB_LIST= MY_DBDIR=${MY_DBDIR} \
+ MY_SECDIR=${MY_SECDIR} \
+ MY_TMPDIR=${MY_TMPDIR}
+
+PLIST_SUB= MY_DBDIR=${MY_DBDIR} \
+ MY_SECDIR=${MY_SECDIR} \
+ MY_TMPDIR=${MY_TMPDIR} \
+ MYSQL80_LIBVER=${MYSQL80_LIBVER}
+
+# MySQL-Server part
+.if !defined(CLIENT_ONLY)
+USES+= mysql:81
+
+CONFLICTS_INSTALL= mysql*-server \
+ mysqlwsrep*-server \
+ mariadb*-server \
+ percona*-server
+
+USE_RC_SUBR= mysql-server
+
+SUB_FILES= my.cnf.sample pkg-message
+
+USERS= mysql
+GROUPS= mysql
+
+USE_LDCONFIG+= ${PREFIX}/lib/mysql/plugin
+
+MMAN1= ibd2sdi.1 innochecksum.1 my_print_defaults.1 myisam_ftdump.1 myisamchk.1 \
+ myisamlog.1 myisampack.1 mysql_secure_installation.1 mysql_ssl_rsa_setup.1 \
+ mysql_tzinfo_to_sql.1 mysql_upgrade.1 mysql.server.1 mysqldumpslow.1 mysqld_multi.1 \
+ mysqld_safe.1 mysqlrouter_passwd.1 mysqlrouter_plugin_info.1 mysqlrouter.1
+MMAN8= mysqld.8
+
+CMAKE_ARGS+= -DWITH_EMBEDDED_SERVER="ON"
+CMAKE_ARGS+= -DWITHOUT_CLIENTLIBS="ON"
+# Disable unit tests, it fails on !amd64 and <13.0 due to c++17 rules
+CMAKE_ARGS+= -DWITH_UNIT_TESTS="OFF"
+
+OPTIONS_GROUP= STORAGE
+OPTIONS_GROUP_STORAGE= ARCHIVE BLACKHOLE EXAMPLE FEDERATED INNOBASE PARTITION PERFSCHEMA
+OPTIONS_SUB= YES
+STORAGE_DESC= Permissible "Storage Engines" (to compile statically into the server)
+ARCHIVE_DESC= Compile "Archive Storage" statically in server
+BLACKHOLE_DESC= Compile "Blackhole Storage" statically in server
+EXAMPLE_DESC= Compile "Example Storage" statically in server
+FEDERATED_DESC= Compile "Federated Storage" statically in server
+INNOBASE_DESC= Compile "InnoDB Storage" statically in server
+PARTITION_DESC= Compile "Partitioning support Storage" statically in server
+PERFSCHEMA_DESC= Compile "Performance Schema Storage" statically in server
+
+ARCHIVE_CMAKE_ON= -DWITH_ARCHIVE_STORAGE_ENGINE=1
+BLACKHOLE_CMAKE_ON= -DWITH_BLACKHOLE_STORAGE_ENGINE=1
+EXAMPLE_CMAKE_ON= -DWITH_EXAMPLE_STORAGE_ENGINE=1
+FEDERATED_CMAKE_ON= -DWITH_FEDERATED_STORAGE_ENGINE=1
+INNOBASE_CMAKE_ON= -DWITH_INNOBASE_STORAGE_ENGINE=1
+PARTITION_CMAKE_ON= -DWITH_PARTITION_STORAGE_ENGINE=1
+PERFSCHEMA_CMAKE_ON= -DWITH_PERFSCHEMA_STORAGE_ENGINE=1
+
+OPTIONS_GROUP+= FEATURES
+OPTIONS_GROUP_FEATURES= PERFSCHM
+FEATURES_DESC= Default features knobs
+PERFSCHM_DESC= Enable "Performance Schema" by default (High RAM usage)
+OPTIONS_DEFAULT+= PERFSCHM
+
+PERFSCHM_SUB_LIST+= PERFSCHEMRC=""
+PERFSCHM_SUB_LIST_OFF+= PERFSCHEMRC="--skip-performance-schema"
+FEDERATED_SUB_LIST+= FEDER="--federated"
+FEDERATED_SUB_LIST_OFF+= FEDER=""
+.endif
+
+.include <bsd.port.options.mk>
+
+# Since 8.0.20 release innodb engine uses new memory alligned allocator
+# which is broken on i386 due to different size of types and caused a
+# 'static_assert(alignof(T) <= alignof(std::max_align_t))' error
+.if ${ARCH} == i386
+CMAKE_ARGS+= -DDISABLE_PSI_MEMORY=1
+SSP_UNSAFE= yes
+.endif
+
+.if ${ARCH} == powerpc
+LDFLAGS+= -latomic
+USES+= compiler:gcc-c++11-lib
+.else
+CXXFLAGS+= -malign-double
+USES+= compiler:c++17-lang
+.endif
+
+.include <bsd.port.pre.mk>
+
+post-extract:
+ @${RM} -rv ${WRKSRC}/sql/sql_hints.yy.cc ${WRKSRC}/sql/sql_hints.yy.h
+
+# This can be removed after FreeBSD 12.4 and 13.1 EoL
+.if defined(CLIENT_ONLY) && !exists(${OPENSSLBASE}/libdata/pkgconfig/openssl.pc)
+EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-scripts_CMakeLists.txt
+.endif
+
+# XXX MBi alignment issue
+.if ${ARCH} == i386
+EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-boost_boost__1__77__0_boost_move_detail_type__traits.hpp \
+ ${PATCHDIR}/extra-patch-storage_innobase_log_log0recv.cc
+.endif
+
+.if !defined(CLIENT_ONLY)
+post-install:
+ ${MKDIR} ${STAGEDIR}${ETCDIR}
+ ${INSTALL_DATA} ${WRKDIR}/my.cnf.sample ${STAGEDIR}${ETCDIR}/my.cnf.sample
+ ${MKDIR} ${STAGEDIR}${ETCDIR}/keyring
+ ${MKDIR} ${STAGEDIR}${MY_SECDIR}
+ ${MKDIR} ${STAGEDIR}${MY_TMPDIR}
+.endif
+
+.include <bsd.port.post.mk>
diff --git a/databases/mysql81-server/distinfo b/databases/mysql81-server/distinfo
new file mode 100644
index 000000000000..13d3c57ad112
--- /dev/null
+++ b/databases/mysql81-server/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1695150470
+SHA256 (mysql-boost-8.1.0.tar.gz) = cb19648bc8719b9f6979924bfea806b278bd26b8d67740e5742c6f363f142188
+SIZE (mysql-boost-8.1.0.tar.gz) = 440038191
diff --git a/databases/mysql81-server/files/extra-patch-boost_boost__1__77__0_boost_move_detail_type__traits.hpp b/databases/mysql81-server/files/extra-patch-boost_boost__1__77__0_boost_move_detail_type__traits.hpp
new file mode 100644
index 000000000000..ee630b3a3655
--- /dev/null
+++ b/databases/mysql81-server/files/extra-patch-boost_boost__1__77__0_boost_move_detail_type__traits.hpp
@@ -0,0 +1,20 @@
+--- boost/boost_1_77_0/boost/move/detail/type_traits.hpp.orig 2021-08-05 09:42:11 UTC
++++ boost/boost_1_77_0/boost/move/detail/type_traits.hpp
+@@ -1104,7 +1104,7 @@ struct alignment_struct
+ typedef int (alignment_dummy::*member_ptr);
+ typedef int (alignment_dummy::*member_function_ptr)();
+ struct alignment_struct
+-{ long double dummy[4]; };
++{ double XXXdummy[4]; };
+
+ /////////////////////////////
+ // max_align_t
+@@ -1122,7 +1122,7 @@ union max_align
+ float float_;
+ double double_;
+ void * void_ptr_;
+- long double long_double_[4];
++ double XXXlong_double_[4];
+ alignment_dummy *unknown_class_ptr_;
+ function_ptr function_ptr_;
+ member_function_ptr member_function_ptr_;
diff --git a/databases/mysql81-server/files/extra-patch-scripts_CMakeLists.txt b/databases/mysql81-server/files/extra-patch-scripts_CMakeLists.txt
new file mode 100644
index 000000000000..df891b025ccd
--- /dev/null
+++ b/databases/mysql81-server/files/extra-patch-scripts_CMakeLists.txt
@@ -0,0 +1,10 @@
+--- scripts/CMakeLists.txt.orig 2022-12-16 15:34:44 UTC
++++ scripts/CMakeLists.txt
+@@ -362,7 +362,6 @@ IF (WITH_SSL STREQUAL "system")
+ # We have implemented "system" for other platforms as well, but those
+ # are non-native packages.
+ IF(LINUX OR SOLARIS OR FREEBSD)
+- SET(CONFIG_REQUIRES_PRIVATE "openssl")
+ STRING(REPLACE "-lssl" "" CONFIG_LIBS_PRIVATE "${CONFIG_LIBS_PRIVATE}")
+ STRING(REPLACE "-lcrypto" "" CONFIG_LIBS_PRIVATE "${CONFIG_LIBS_PRIVATE}")
+ STRING(REGEX REPLACE "[ ]+" " " CONFIG_LIBS_PRIVATE
diff --git a/databases/mysql81-server/files/extra-patch-storage_innobase_log_log0recv.cc b/databases/mysql81-server/files/extra-patch-storage_innobase_log_log0recv.cc
new file mode 100644
index 000000000000..0a6d0d4ec0df
--- /dev/null
+++ b/databases/mysql81-server/files/extra-patch-storage_innobase_log_log0recv.cc
@@ -0,0 +1,11 @@
+--- storage/innobase/log/log0recv.cc.orig 2023-12-17 10:36:48 UTC
++++ storage/innobase/log/log0recv.cc
+@@ -3695,7 +3695,7 @@ static void recv_recovery_begin(log_t &log, const lsn_
+ than number of concurrent IOs we want to sustain. We should also keep in
+ mind that the limit for the deltas hashmap is not strictly enforced and
+ this number includes the not-well specified safety margin. */
+- size_t{256} * srv_buf_pool_instances);
++ static_cast<unsigned int>(size_t{256} * srv_buf_pool_instances));
+ const size_t delta_hashmap_max_mem =
+ UNIV_PAGE_SIZE * (buf_pool_get_n_pages() - pages_to_be_kept_free);
+
diff --git a/databases/mysql81-server/files/my.cnf.sample.in b/databases/mysql81-server/files/my.cnf.sample.in
new file mode 100644
index 000000000000..3d1264c1bd61
--- /dev/null
+++ b/databases/mysql81-server/files/my.cnf.sample.in
@@ -0,0 +1,57 @@
+[client]
+port = 3306
+socket = /tmp/mysql.sock
+
+[mysql]
+prompt = \u@\h [\d]>\_
+no_auto_rehash
+
+[mysqld]
+user = mysql
+port = 3306
+socket = /tmp/mysql.sock
+bind-address = 127.0.0.1
+basedir = %%PREFIX%%
+datadir = %%MY_DBDIR%%
+tmpdir = %%MY_TMPDIR%%
+replica-load-tmpdir = %%MY_TMPDIR%%
+secure-file-priv = %%MY_SECDIR%%
+log-bin = mysql-bin
+log-output = TABLE
+relay-log-recovery = 1
+slow-query-log = 1
+server-id = 1
+sync_binlog = 1
+sync_relay_log = 1
+binlog_cache_size = 16M
+binlog_expire_logs_seconds = 2592000
+default_password_lifetime = 0
+enforce-gtid-consistency = 1
+gtid-mode = ON
+safe-user-create = 1
+lower_case_table_names = 1
+explicit-defaults-for-timestamp = 1
+myisam-recover-options = BACKUP,FORCE
+open_files_limit = 32768
+table_open_cache = 16384
+table_definition_cache = 8192
+net_retry_count = 16384
+key_buffer_size = 256M
+max_allowed_packet = 64M
+long_query_time = 0.5
+innodb_buffer_pool_size = 1G
+innodb_data_home_dir = %%MY_DBDIR%%
+innodb_log_group_home_dir = %%MY_DBDIR%%
+innodb_data_file_path = ibdata1:128M:autoextend
+innodb_temp_data_file_path = ibtmp1:128M:autoextend
+innodb_flush_method = O_DIRECT
+innodb_redo_log_capacity = 512M
+innodb_log_buffer_size = 16M
+innodb_write_io_threads = 8
+innodb_read_io_threads = 8
+innodb_autoinc_lock_mode = 2
+
+[mysqldump]
+max_allowed_packet = 256M
+quote_names
+quick
diff --git a/databases/mysql81-server/files/mysql-server.in b/databases/mysql81-server/files/mysql-server.in
new file mode 100644
index 000000000000..c79874df9f2c
--- /dev/null
+++ b/databases/mysql81-server/files/mysql-server.in
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# PROVIDE: mysql
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+#
+# Add the following line to /etc/rc.conf to enable mysql:
+# mysql_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable MySQL.
+# mysql_dbdir (str): Default to "%%MY_DBDIR%%"
+# Base database directory.
+# mysql_confdir (str): Default to "%%ETCDIR%%"
+# Base configuration directory.
+# mysql_optfile (str): Server-specific option file.
+# Set it in the rc.conf or default behaviour of
+# `mysqld_safe` itself, will be picking
+# ${mysql_confdir}/my.cnf if it exists.
+# mysql_pidfile (str): Custom PID file path and name.
+# Default to "${mysql_dbdir}/${hostname}.pid".
+# mysql_args (str): Custom additional arguments to be passed
+# to mysqld_safe (default empty).
+#
+
+. /etc/rc.subr
+
+name="mysql"
+rcvar=mysql_enable
+
+load_rc_config $name
+
+: ${mysql_enable="NO"}
+: ${mysql_dbdir="%%MY_DBDIR%%"}
+: ${mysql_confdir="%%ETCDIR%%"}
+if [ -f "${mysql_confdir}/my.cnf" ]; then
+: ${mysql_optfile="${mysql_confdir}/my.cnf"}
+elif [ -f "${mysql_dbdir}/my.cnf" ]; then
+: ${mysql_optfile="${mysql_dbdir}/my.cnf"}
+fi
+if [ ! -z "${mysql_optfile}" ]; then
+mysql_extra="--defaults-extra-file=${mysql_optfile}"
+fi
+
+mysql_user="mysql"
+: ${hostname:=`/bin/hostname`}
+pidfile=${mysql_pidfile:-"${mysql_dbdir}/${hostname}.pid"}
+command="/usr/sbin/daemon"
+command_args="-c -f %%PREFIX%%/bin/mysqld_safe ${mysql_extra} --basedir=%%PREFIX%% --datadir=${mysql_dbdir} --pid-file=${pidfile} --user=${mysql_user} ${mysql_args} %%FEDER%% %%PERFSCHEMRC%%"
+procname="%%PREFIX%%/libexec/mysqld"
+start_precmd="${name}_prestart"
+start_postcmd="${name}_poststart"
+mysqld_init="${procname}"
+mysqld_init_args="${mysql_extra} --initialize-insecure --basedir=%%PREFIX%% --datadir=${mysql_dbdir} --user=${mysql_user}"
+
+mysql_create_auth_tables()
+{
+ eval $mysqld_init $mysqld_init_args >/dev/null 2>/dev/null
+}
+
+mysql_prestart()
+{
+ if [ ! -d "${mysql_dbdir}/mysql/." ]; then
+ mysql_create_auth_tables || return 1
+ fi
+ return 0
+}
+
+mysql_poststart()
+{
+ local timeout=15
+ while [ ! -f "${pidfile}" -a ${timeout} -gt 0 ]; do
+ timeout=$(( timeout - 1 ))
+ sleep 1
+ done
+ return 0
+}
+
+run_rc_command "$1"
diff --git a/databases/mysql81-server/files/patch-CMakeLists.txt b/databases/mysql81-server/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..a7c3d317d734
--- /dev/null
+++ b/databases/mysql81-server/files/patch-CMakeLists.txt
@@ -0,0 +1,95 @@
+--- CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ CMakeLists.txt
+@@ -1850,7 +1850,7 @@ IF(WITH_AUTHENTICATION_LDAP)
+ ENDIF()
+
+ IF(WITH_AUTHENTICATION_LDAP)
+- IF(LINUX AND KNOWN_CUSTOM_LIBRARIES)
++ IF(LINUX OR FREEBSD AND KNOWN_CUSTOM_LIBRARIES)
+ # LDAP / SASL / KERBEROS / SSL must all be "system" or "custom", not a mix.
+ IF(WITH_LDAP STREQUAL "system" OR
+ WITH_SASL STREQUAL "system" OR
+@@ -1899,6 +1899,7 @@ ENDIF()
+ ENDIF()
+ ENDIF()
+
++IF(NOT WITHOUT_TOOLS)
+ # Add system/bundled editline.
+ MYSQL_CHECK_EDITLINE()
+ SET(EDITLINE_WARN_GIVEN)
+@@ -1909,7 +1910,9 @@ ENDIF()
+ "You can use -DWITH_EDITLINE=bundled instead."
+ )
+ ENDIF()
++ENDIF(NOT WITHOUT_TOOLS)
+
++IF(NOT WITHOUT_SERVER)
+ # Add libevent
+ MYSQL_CHECK_LIBEVENT()
+ UNSET(LIBEVENT_WARN_GIVEN)
+@@ -1920,6 +1923,7 @@ ENDIF()
+ "You can use -DWITH_LIBEVENT=bundled instead."
+ )
+ ENDIF()
++ENDIF(NOT WITHOUT_SERVER)
+
+ # Add lz4 library
+ MYSQL_CHECK_LZ4()
+@@ -2186,7 +2190,9 @@ ADD_DEPENDENCIES(clang_tidy_prerequisites GenError)
+ ADD_DEPENDENCIES(clang_tidy_prerequisites protobuf_generated_all)
+ ADD_DEPENDENCIES(clang_tidy_prerequisites GenError)
+
+-ADD_SUBDIRECTORY(include)
++IF(NOT WITHOUT_CLIENTLIBS)
++ ADD_SUBDIRECTORY(include)
++ENDIF(NOT WITHOUT_CLIENTLIBS)
+ ADD_SUBDIRECTORY(strings)
+ ADD_SUBDIRECTORY(vio)
+ ADD_SUBDIRECTORY(mysys)
+@@ -2232,12 +2238,15 @@ ENDIF()
+ ADD_SUBDIRECTORY(unittest/mytap/t)
+ ENDIF()
+
+-ADD_SUBDIRECTORY(client)
++IF(NOT WITHOUT_TOOLS)
++ ADD_SUBDIRECTORY(client)
++ENDIF(NOT WITHOUT_TOOLS)
++
+ ADD_SUBDIRECTORY(utilities)
+-ADD_SUBDIRECTORY(share)
+ ADD_SUBDIRECTORY(libservices)
+
+ IF(NOT WITHOUT_SERVER)
++ ADD_SUBDIRECTORY(share)
+ ADD_SUBDIRECTORY(testclients)
+ ADD_SUBDIRECTORY(sql)
+ ENDIF()
+@@ -2300,11 +2309,11 @@ ADD_SUBDIRECTORY(scripts)
+ # scripts/mysql_config depends on client and server targets loaded above.
+ # It is referenced by some of the directories below, so we insert it here.
+ ADD_SUBDIRECTORY(scripts)
++ADD_SUBDIRECTORY(support-files)
+
+ IF(NOT WITHOUT_SERVER)
+ ADD_SUBDIRECTORY(mysql-test)
+ ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
+- ADD_SUBDIRECTORY(support-files)
+ IF(WITH_INTERNAL)
+ ADD_SUBDIRECTORY(internal)
+ ENDIF()
+@@ -2331,6 +2340,7 @@ ENDIF()
+ INCLUDE(fastcov)
+ ENDIF()
+
++IF(FALSE)
+ IF(UNIX)
+ ADD_SUBDIRECTORY(man)
+ ENDIF()
+@@ -2530,6 +2540,7 @@ IF(NOT INSTALL_LAYOUT MATCHES "RPM")
+ PATTERN "sp-imp-spec.txt" EXCLUDE
+ PATTERN "README.build" EXCLUDE
+ )
++ENDIF()
+ ENDIF()
+
+ # Now that we're done with all ADD_SUBDIRECTORY and thus all feature tests,
diff --git a/databases/mysql81-server/files/patch-client_CMakeLists.txt b/databases/mysql81-server/files/patch-client_CMakeLists.txt
new file mode 100644
index 000000000000..55269b16ec3f
--- /dev/null
+++ b/databases/mysql81-server/files/patch-client_CMakeLists.txt
@@ -0,0 +1,70 @@
+--- client/CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ client/CMakeLists.txt
+@@ -28,10 +28,13 @@ ADD_SUBDIRECTORY(base)
+ ## Subdirectory with common client code.
+ ADD_SUBDIRECTORY(base)
+ ## Subdirectory for mysqlpump code.
++IF(WITHOUT_SERVER)
+ ADD_SUBDIRECTORY(dump)
+ ## Subdirectory for mysql_migrate_keyring code.
+ ADD_SUBDIRECTORY(migrate_keyring)
++ENDIF()
+
++IF(NOT WITHOUT_CLIENTLIBS)
+ INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ )
+@@ -47,6 +50,7 @@ MYSQL_ADD_EXECUTABLE(mysql
+ ${CMAKE_CURRENT_SOURCE_DIR}/common/user_registration.cc
+ LINK_LIBRARIES mysqlclient client_base ${EDITLINE_LIBRARY}
+ )
++ENDIF()
+
+ IF(NOT WITHOUT_SERVER)
+ MYSQL_ADD_EXECUTABLE(mysql_upgrade
+@@ -55,6 +59,7 @@ ENDIF()
+ )
+ ENDIF()
+
++IF(NOT WITHOUT_SERVER)
+ MYSQL_ADD_EXECUTABLE(mysqltest
+ mysqltest.cc
+ mysqltest/error_names.cc
+@@ -71,6 +76,9 @@ MYSQL_ADD_EXECUTABLE(mysqltest
+ ENABLE_EXPORTS
+ LINK_LIBRARIES mysqlclient
+ )
++ENDIF()
++
++IF(WITHOUT_SERVER)
+ MYSQL_ADD_EXECUTABLE(mysqlcheck
+ check/mysqlcheck.cc
+ check/mysqlcheck_core.cc
+@@ -275,7 +283,9 @@ TARGET_INCLUDE_DIRECTORIES(mysqlbinlog PRIVATE ${CMAKE
+
+ TARGET_COMPILE_DEFINITIONS(mysqlbinlog PRIVATE DISABLE_PSI_MUTEX)
+ TARGET_INCLUDE_DIRECTORIES(mysqlbinlog PRIVATE ${CMAKE_SOURCE_DIR}/sql)
++ENDIF()
+
++IF(WITHOUT_SERVER)
+ MYSQL_ADD_EXECUTABLE(mysqladmin
+ mysqladmin.cc
+ multi_factor_passwordopt-vars.cc
+@@ -290,6 +300,9 @@ MYSQL_ADD_EXECUTABLE(mysql_config_editor
+ mysql_config_editor.cc
+ LINK_LIBRARIES mysqlclient
+ )
++ENDIF()
++
++IF(NOT WITHOUT_SERVER)
+ MYSQL_ADD_EXECUTABLE(mysql_secure_installation
+ mysql_secure_installation.cc
+ LINK_LIBRARIES mysqlclient
+@@ -300,6 +313,7 @@ MYSQL_ADD_EXECUTABLE(mysql_ssl_rsa_setup
+ path.cc
+ LINK_LIBRARIES mysys
+ )
++ENDIF()
+
+ # "WIN32" also covers 64 bit. "echo" is used in some files below "mysql-test/".
+ IF(WIN32)
diff --git a/databases/mysql81-server/files/patch-cmake_install__layout.cmake b/databases/mysql81-server/files/patch-cmake_install__layout.cmake
new file mode 100644
index 000000000000..ca0779443e0d
--- /dev/null
+++ b/databases/mysql81-server/files/patch-cmake_install__layout.cmake
@@ -0,0 +1,95 @@
+--- cmake/install_layout.cmake.orig 2023-06-21 07:52:10 UTC
++++ cmake/install_layout.cmake
+@@ -41,6 +41,10 @@
+ # Build with prefix=/usr/local/mysql, create tarball with install prefix="."
+ # and relative links.
+ #
++# FREEBSD
++# Build with prefix=/usr/local, create tarball with install prefix="."
++# and relative links.
++#
+ # To force a directory layout, use -DINSTALL_LAYOUT=<layout>.
+ #
+ # The default is STANDALONE.
+@@ -80,7 +84,7 @@ SET(INSTALL_LAYOUT "${DEFAULT_INSTALL_LAYOUT}"
+ ENDIF()
+
+ SET(INSTALL_LAYOUT "${DEFAULT_INSTALL_LAYOUT}"
+- CACHE STRING "Installation directory layout. Options are: TARGZ (as in tar.gz installer), STANDALONE, RPM, DEB, SVR4"
++ CACHE STRING "Installation directory layout. Options are: TARGZ (as in tar.gz installer), STANDALONE, FREEBSD, RPM, DEB, SVR4"
+ )
+
+ IF(UNIX)
+@@ -98,7 +102,7 @@ IF(UNIX)
+ CACHE PATH "install prefix" FORCE)
+ ENDIF()
+ SET(VALID_INSTALL_LAYOUTS
+- "RPM" "DEB" "SVR4" "TARGZ" "STANDALONE")
++ "RPM" "DEB" "SVR4" "TARGZ" "FREEBSD" "STANDALONE")
+ LIST(FIND VALID_INSTALL_LAYOUTS "${INSTALL_LAYOUT}" ind)
+ IF(ind EQUAL -1)
+ MESSAGE(FATAL_ERROR "Invalid INSTALL_LAYOUT parameter:${INSTALL_LAYOUT}."
+@@ -167,6 +171,32 @@ SET(INSTALL_SECURE_FILE_PRIVDIR_STANDALONE ${secure_fi
+ SET(INSTALL_SECURE_FILE_PRIVDIR_STANDALONE ${secure_file_priv_path})
+
+ #
++# FREEBSD layout
++#
++SET(INSTALL_BINDIR_FREEBSD "bin")
++SET(INSTALL_SBINDIR_FREEBSD "bin")
++#
++SET(INSTALL_LIBDIR_FREEBSD "lib")
++SET(INSTALL_PRIV_LIBDIR_FREEBSD "lib/private")
++SET(INSTALL_PLUGINDIR_FREEBSD "lib/plugin")
++#
++SET(INSTALL_INCLUDEDIR_FREEBSD "include")
++#
++SET(INSTALL_DOCDIR_FREEBSD "docs")
++SET(INSTALL_DOCREADMEDIR_FREEBSD ".")
++SET(INSTALL_MANDIR_FREEBSD "man")
++SET(INSTALL_INFODIR_FREEBSD "docs")
++#
++SET(INSTALL_SHAREDIR_FREEBSD "share")
++SET(INSTALL_MYSQLSHAREDIR_FREEBSD "share")
++SET(INSTALL_MYSQLTESTDIR_FREEBSD "mysql-test")
++SET(INSTALL_SUPPORTFILESDIR_FREEBSD "support-files")
++#
++SET(INSTALL_MYSQLDATADIR_FREEBSD "data")
++SET(INSTALL_MYSQLKEYRINGDIR_FREEBSD "keyring")
++SET(INSTALL_SECURE_FILE_PRIVDIR_FREEBSD ${secure_file_priv_path})
++
++#
+ # TARGZ layout
+ #
+ SET(INSTALL_BINDIR_TARGZ "bin")
+@@ -361,7 +391,7 @@ SET(ROUTER_INSTALL_LAYOUT "${DEFAULT_ROUTER_INSTALL_LA
+ SET(ROUTER_INSTALL_LAYOUT "${DEFAULT_ROUTER_INSTALL_LAYOUT}"
+ CACHE
+ STRING
+- "Installation directory layout. Options are: STANDALONE RPM DEB SVR4 TARGZ")
++ "Installation directory layout. Options are: STANDALONE FREEBSD RPM DEB SVR4 TARGZ")
+
+ # If we are shared STANDALONE with the the server, we shouldn't write
+ # into the server's data/ as that would create a "schemadir" in
+@@ -405,6 +435,21 @@ ENDFOREACH()
+ )
+ SET(ROUTER_INSTALL_${var}DIR_TARGZ ${ROUTER_INSTALL_${var}DIR_STANDALONE})
+ ENDFOREACH()
++
++#
++# FreeBSD layout
++#
++SET(ROUTER_INSTALL_CONFIGDIR_FREEBSD "/usr/local/etc/mysqlrouter")
++SET(ROUTER_INSTALL_DATADIR_FREEBSD "/var/db/mysqlrouter")
++SET(ROUTER_INSTALL_LOGDIR_FREEBSD "/var/log/mysqlrouter")
++SET(ROUTER_INSTALL_RUNTIMEDIR_FREEBSD "/var/run/mysqlrouter")
++
++SET(ROUTER_INSTALL_BINDIR_FREEBSD "bin")
++SET(ROUTER_INSTALL_LIBDIR_FREEBSD "lib/mysql")
++SET(ROUTER_INSTALL_PLUGINDIR_FREEBSD "lib/mysql/mysqlrouter")
++SET(ROUTER_INSTALL_LOGROTATEDIR_FREEBSD "etc/logrotate.d")
++SET(ROUTER_INSTALL_LOGROTATEFILE_FREEBSD "mysqlrouter")
++SET(ROUTER_INSTALL_DOCDIR_FREEBSD "share/mysqlrouter/docs")
+
+ FOREACH(var
+ LOGROTATE
diff --git a/databases/mysql81-server/files/patch-cmake_os_DragonFly.cmake b/databases/mysql81-server/files/patch-cmake_os_DragonFly.cmake
new file mode 100644
index 000000000000..83c154ee3bcf
--- /dev/null
+++ b/databases/mysql81-server/files/patch-cmake_os_DragonFly.cmake
@@ -0,0 +1,27 @@
+--- cmake/os/DragonFly.cmake.orig 2016-04-14 10:16:17 UTC
++++ cmake/os/DragonFly.cmake
+@@ -0,0 +1,24 @@
++INCLUDE(CheckCSourceRuns)
++
++# We require at least GCC 4.4 or Clang 3.3.
++IF(NOT FORCE_UNSUPPORTED_COMPILER)
++ IF(CMAKE_COMPILER_IS_GNUCC)
++ EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion
++ OUTPUT_VARIABLE GCC_VERSION)
++ IF(GCC_VERSION VERSION_LESS 4.4)
++ MESSAGE(FATAL_ERROR "GCC 4.4 or newer is required!")
++ ENDIF()
++ ELSEIF(CMAKE_C_COMPILER_ID MATCHES "Clang")
++ CHECK_C_SOURCE_RUNS("
++ int main()
++ {
++ return (__clang_major__ < 3) ||
++ (__clang_major__ == 3 && __clang_minor__ < 3);
++ }" HAVE_SUPPORTED_CLANG_VERSION)
++ IF(NOT HAVE_SUPPORTED_CLANG_VERSION)
++ MESSAGE(FATAL_ERROR "Clang 3.3 or newer is required!")
++ ENDIF()
++ ELSE()
++ MESSAGE(FATAL_ERROR "Unsupported compiler!")
++ ENDIF()
++ENDIF()
diff --git a/databases/mysql81-server/files/patch-cmake_os_FreeBSD.cmake b/databases/mysql81-server/files/patch-cmake_os_FreeBSD.cmake
new file mode 100644
index 000000000000..90629de01287
--- /dev/null
+++ b/databases/mysql81-server/files/patch-cmake_os_FreeBSD.cmake
@@ -0,0 +1,25 @@
+--- cmake/os/FreeBSD.cmake.orig 2021-12-17 16:07:27 UTC
++++ cmake/os/FreeBSD.cmake
+@@ -48,8 +48,20 @@ IF(NOT FORCE_UNSUPPORTED_COMPILER)
+ IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.1)
+ MESSAGE(FATAL_ERROR "GCC 7.1 or newer is required")
+ ENDIF()
+- ELSE()
+- MESSAGE(FATAL_ERROR "Unsupported compiler!")
++ CHECK_C_SOURCE_RUNS("
++ int main()
++ {
++ return (__clang_major__ >= 4);
++ }" I386_ATOMIC_BUILTINS)
++ IF((CMAKE_SYSTEM_PROCESSOR MATCHES "i386") AND (NOT I386_ATOMIC_BUILTINS))
++ SET(HAVE_GCC_ATOMIC_BUILTINS CACHE INTERNAL "")
++ ENDIF()
++ ELSEIF(CMAKE_COMPILER_IS_GNUCC)
++ EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion
++ OUTPUT_VARIABLE GCC_VERSION)
++ IF(GCC_VERSION VERSION_LESS 4.4)
++ MESSAGE(FATAL_ERROR "GCC 4.4 or newer is required!")
++ ENDIF()
+ ENDIF()
+ ENDIF()
+
diff --git a/databases/mysql81-server/files/patch-cmake_plugin.cmake b/databases/mysql81-server/files/patch-cmake_plugin.cmake
new file mode 100644
index 000000000000..15406bae9ec0
--- /dev/null
+++ b/databases/mysql81-server/files/patch-cmake_plugin.cmake
@@ -0,0 +1,27 @@
+--- cmake/plugin.cmake.orig 2023-06-21 07:52:10 UTC
++++ cmake/plugin.cmake
+@@ -273,15 +273,15 @@ MACRO(MYSQL_ADD_PLUGIN plugin_arg)
+
+ # For testing purposes, we need
+ # <...>/lib/plugin/debug/authentication_ldap_sasl_client.so
+- IF(ARG_CLIENT_ONLY)
+- INSTALL_DEBUG_TARGET(${target}
+- DESTINATION ${INSTALL_PLUGINDIR}/debug
+- COMPONENT Test)
+- ELSE()
+- INSTALL_DEBUG_TARGET(${target}
+- DESTINATION ${INSTALL_PLUGINDIR}/debug
+- COMPONENT ${INSTALL_COMPONENT})
+- ENDIF()
++# IF(ARG_CLIENT_ONLY)
++# INSTALL_DEBUG_TARGET(${target}
++# DESTINATION ${INSTALL_PLUGINDIR}/debug
++# COMPONENT Test)
++# ELSE()
++# INSTALL_DEBUG_TARGET(${target}
++# DESTINATION ${INSTALL_PLUGINDIR}/debug
++# COMPONENT ${INSTALL_COMPONENT})
++# ENDIF()
+ ENDIF()
+ ELSE()
+ IF(WITHOUT_${plugin})
diff --git a/databases/mysql81-server/files/patch-cmake_ssl.cmake b/databases/mysql81-server/files/patch-cmake_ssl.cmake
new file mode 100644
index 000000000000..e7688d6e50ad
--- /dev/null
+++ b/databases/mysql81-server/files/patch-cmake_ssl.cmake
@@ -0,0 +1,23 @@
+--- cmake/ssl.cmake.orig 2022-07-06 21:36:34 UTC
++++ cmake/ssl.cmake
+@@ -142,7 +142,7 @@ MACRO(FIND_OPENSSL_VERSION)
+ # Encoded as MNNFFPPS: major minor fix patch status
+ FILE(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h"
+ OPENSSL_VERSION_NUMBER
+- REGEX "^#[ ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x[0-9].*"
++ REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x[0-9].*"
+ )
+ STRING(REGEX REPLACE
+ "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9]).*$" "\\1"
+@@ -380,8 +380,9 @@ MACRO (MYSQL_CHECK_SSL)
+ "Not a supported openssl version in WITH_SSL=${WITH_SSL}.")
+ ENDIF()
+
+- IF("${OPENSSL_MAJOR_MINOR_FIX_VERSION}" VERSION_GREATER "1.1.0")
+- ADD_DEFINITIONS(-DHAVE_TLSv13)
++ CHECK_SYMBOL_EXISTS(TLS1_3_VERSION "openssl/tls1.h" HAVE_TLS1_3_VERSION)
++ IF(HAVE_TLS1_3_VERSION)
++ #ADD_DEFINITIONS(-DHAVE_TLSv13)
+ ENDIF()
+
+ IF(OPENSSL_INCLUDE_DIR AND
diff --git a/databases/mysql81-server/files/patch-include_my__compare.h b/databases/mysql81-server/files/patch-include_my__compare.h
new file mode 100644
index 000000000000..83e2c6f371ca
--- /dev/null
+++ b/databases/mysql81-server/files/patch-include_my__compare.h
@@ -0,0 +1,11 @@
+--- include/my_compare.h.orig 2019-09-20 08:30:51 UTC
++++ include/my_compare.h
+@@ -49,7 +49,7 @@
+ But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and HA_MAX_KEY_LENGTH.
+ */
+
+-#define HA_MAX_KEY_LENGTH 1000 /* Max length in bytes */
++#define HA_MAX_KEY_LENGTH 4000 /* Max length in bytes */
+ #define HA_MAX_KEY_SEG 16 /* Max segments for key */
+
+ #define HA_MAX_POSSIBLE_KEY_BUFF (HA_MAX_KEY_LENGTH + 24 + 6 + 6)
diff --git a/databases/mysql81-server/files/patch-include_my__stacktrace.h b/databases/mysql81-server/files/patch-include_my__stacktrace.h
new file mode 100644
index 000000000000..1654014bd77b
--- /dev/null
+++ b/databases/mysql81-server/files/patch-include_my__stacktrace.h
@@ -0,0 +1,11 @@
+--- include/my_stacktrace.h.orig 2021-12-17 16:07:27 UTC
++++ include/my_stacktrace.h
+@@ -43,7 +43,7 @@
+ HAVE_BACKTRACE - Linux, FreeBSD, OSX, Solaris
+ _WIN32 - Windows
+ */
+-#if defined(HAVE_BACKTRACE) || defined(_WIN32)
++#if (defined(HAVE_BACKTRACE) || defined(_WIN32)) && (defined(__aarch64__) || defined(__amd64__) || defined(__i386__))
+ #define HAVE_STACKTRACE 1
+ void my_init_stacktrace();
+ void my_print_stacktrace(const uchar *stack_bottom, ulong thread_stack);
diff --git a/databases/mysql81-server/files/patch-include_my__thread__os__id.h b/databases/mysql81-server/files/patch-include_my__thread__os__id.h
new file mode 100644
index 000000000000..56af9be42579
--- /dev/null
+++ b/databases/mysql81-server/files/patch-include_my__thread__os__id.h
@@ -0,0 +1,15 @@
+--- include/my_thread_os_id.h.orig 2019-09-20 08:30:51 UTC
++++ include/my_thread_os_id.h
+@@ -84,8 +84,12 @@ static inline my_thread_os_id_t my_thread_os_id() {
+ return pthread_getthreadid_np();
+ #else
+ #ifdef HAVE_INTEGER_PTHREAD_SELF
++# ifdef __DragonFly__
++ return syscall(SYS_lwp_gettid);
++# else
+ /* Unknown platform, fallback. */
+ return pthread_self();
++# endif
+ #else
+ /* Feature not available. */
+ return 0;
diff --git a/databases/mysql81-server/files/patch-include_myisam.h b/databases/mysql81-server/files/patch-include_myisam.h
new file mode 100644
index 000000000000..d47119576543
--- /dev/null
+++ b/databases/mysql81-server/files/patch-include_myisam.h
@@ -0,0 +1,11 @@
+--- include/myisam.h.orig 2023-06-21 07:52:10 UTC
++++ include/myisam.h
+@@ -59,7 +59,7 @@
+ The following defines can be increased if necessary.
+ But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and MI_MAX_KEY_LENGTH.
+ */
+-#define MI_MAX_KEY_LENGTH 1000 /* Max length in bytes */
++#define MI_MAX_KEY_LENGTH 4000 /* Max length in bytes */
+ #define MI_MAX_KEY_SEG 16 /* Max segments for key */
+
+ #define MI_MAX_KEY_BUFF (MI_MAX_KEY_LENGTH + MI_MAX_KEY_SEG * 6 + 8 + 8)
diff --git a/databases/mysql81-server/files/patch-libmysql_CMakeLists.txt b/databases/mysql81-server/files/patch-libmysql_CMakeLists.txt
new file mode 100644
index 000000000000..453e0f37652f
--- /dev/null
+++ b/databases/mysql81-server/files/patch-libmysql_CMakeLists.txt
@@ -0,0 +1,68 @@
+--- libmysql/CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ libmysql/CMakeLists.txt
+@@ -206,6 +206,11 @@ ENDIF()
+ )
+ ENDIF()
+
++INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)
++IF (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
++ ADD_COMPILE_FLAGS(${CLIENT_SOURCES} COMPILE_FLAGS "-fPIC")
++ENDIF()
++
+ #
+ # Include protocol tracing infrastructure and the test
+ # trace plugin if enabled by build options.
+@@ -282,8 +287,15 @@ ENDIF()
+ LIST(APPEND LIBS_TO_MERGE auth_win_client)
+ ENDIF()
+
+-# LDAP authentication SASL client plug-in
+-ADD_SUBDIRECTORY(authentication_ldap)
++IF(WITHOUT_CLIENTLIBS)
++ # Merge several convenience libraries into one big mysqlclient
++ MERGE_CONVENIENCE_LIBRARIES(mysqlclient ${LIBS_TO_MERGE}
++ COMPONENT Development
++ SKIP_INSTALL)
++ELSE(WITHOUT_CLIENTLIBS)
++ # LDAP authentication SASL client plugin
++ MESSAGE(STATUS "Creating LDAP authentication SASL client library.")
++ ADD_SUBDIRECTORY(authentication_ldap)
+
+ # FIDO authentication client plugin
+ ADD_SUBDIRECTORY(authentication_fido)
+@@ -299,6 +311,7 @@ MERGE_CONVENIENCE_LIBRARIES(mysqlclient ${LIBS_TO_MERG
+ COMPONENT Development
+ LINK_LIBRARIES ${LIBS_TO_LINK}
+ )
++ENDIF(WITHOUT_CLIENTLIBS)
+
+ # Visual Studio users need debug static library for debug projects
+ IF(MSVC)
+@@ -345,17 +358,27 @@ ENDIF()
+
+ # Merge several convenience libraries into one big mysqlclient
+ # and link them together into shared library.
++IF(WITHOUT_CLIENTLIBS)
+ MERGE_LIBRARIES_SHARED(libmysql ${LIBS_TO_MERGE}
+ EXPORTS
+ ${CLIENT_API_FUNCTIONS}
+ ${CLIENT_API_FUNCTIONS_UNDOCUMENTED}
+ ${CLIENT_API_NONBLOCKING_FUNCTIONS}
+ COMPONENT SharedLibraries
++ SKIP_INSTALL )
++ELSE(WITHOUT_CLIENTLIBS)
++MERGE_LIBRARIES_SHARED(libmysql ${LIBS_TO_MERGE}
++ EXPORTS
++ ${CLIENT_API_FUNCTIONS}
++ ${CLIENT_API_FUNCTIONS_UNDOCUMENTED}
++ ${CLIENT_API_NONBLOCKING_FUNCTIONS}
++ COMPONENT SharedLibraries
+ LINK_LIBRARIES ${LIBS_TO_LINK}
+ ${UNIX_OUTPUT_NAME}
+ ${UNIX_SOVERSION}
+ ${UNIX_VERSION}
+ )
++ENDIF(WITHOUT_CLIENTLIBS)
+
+ # Downgrade warning for strncat in my_crypt_genhash.
+ IF((WITH_LTO OR CMAKE_COMPILER_FLAG_WITH_LTO) AND MY_COMPILER_IS_GNU)
diff --git a/databases/mysql81-server/files/patch-libservices_CMakeLists.txt b/databases/mysql81-server/files/patch-libservices_CMakeLists.txt
new file mode 100644
index 000000000000..95610f261f3a
--- /dev/null
+++ b/databases/mysql81-server/files/patch-libservices_CMakeLists.txt
@@ -0,0 +1,12 @@
+--- libservices/CMakeLists.txt.orig 2021-12-17 16:07:27 UTC
++++ libservices/CMakeLists.txt
+@@ -47,7 +47,9 @@ SET(MYSQLSERVICES_SOURCES
+ plugin_registry_service.c)
+
+ ADD_LIBRARY(mysqlservices STATIC ${MYSQLSERVICES_SOURCES})
++IF(FALSE)
+ IF(INSTALL_STATIC_LIBRARIES)
+ INSTALL(TARGETS mysqlservices
+ DESTINATION ${INSTALL_LIBDIR} COMPONENT Development)
++ENDIF()
+ ENDIF()
diff --git a/databases/mysql81-server/files/patch-man_CMakeLists.txt b/databases/mysql81-server/files/patch-man_CMakeLists.txt
new file mode 100644
index 000000000000..eed2755a9e5d
--- /dev/null
+++ b/databases/mysql81-server/files/patch-man_CMakeLists.txt
@@ -0,0 +1,76 @@
+--- man/CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ man/CMakeLists.txt
+@@ -23,26 +23,14 @@ SET(MAN1
+ # Copy man pages
+ SET(MAN1
+ comp_err.1
+- ibd2sdi.1
+- innochecksum.1
+ lz4_decompress.1
+- my_print_defaults.1
+- myisam_ftdump.1
+- myisamchk.1
+- myisamlog.1
+- myisampack.1
+ mysql.1
+ mysql_config.1
+ mysql_config_editor.1
+- mysql_secure_installation.1
+- mysql_ssl_rsa_setup.1
+- mysql_tzinfo_to_sql.1
+- mysql_upgrade.1
+ mysqladmin.1
+ mysqlbinlog.1
+ mysqlcheck.1
+ mysqldump.1
+- mysqldumpslow.1
+ mysqlimport.1
+ mysqlman.1
+ mysqlpump.1
+@@ -52,13 +40,23 @@ SET(MAN1
+ zlib_decompress.1
+ )
+
+-IF(NOT WITH_SYSTEMD)
+- LIST(APPEND MAN1
+- mysql.server.1
+- mysqld_multi.1
+- mysqld_safe.1
++SET(MAN1_TOOLS
++ ibd2sdi.1
++ innochecksum.1
++ my_print_defaults.1
++ myisam_ftdump.1
++ myisamchk.1
++ myisamlog.1
++ myisampack.1
++ mysql.server.1
++ mysql_secure_installation.1
++ mysql_ssl_rsa_setup.1
++ mysql_tzinfo_to_sql.1
++ mysql_upgrade.1
++ mysqldumpslow.1
++ mysqld_multi.1
++ mysqld_safe.1
+ )
+-ENDIF()
+
+ SET(MAN1_NDB
+ ndb_blob_tool.1
+@@ -105,8 +103,14 @@ SET(MAN8_NDB
+ ndbmtd.8
+ )
+
+-INSTALL(FILES ${MAN1} DESTINATION ${INSTALL_MANDIR}/man1 COMPONENT ManPages)
+-INSTALL(FILES ${MAN8} DESTINATION ${INSTALL_MANDIR}/man8 COMPONENT ManPages)
++IF(NOT WITHOUT_CLIENTLIBS)
++ INSTALL(FILES ${MAN1} DESTINATION ${INSTALL_MANDIR}/man1 COMPONENT ManPages)
++ENDIF()
++
++IF(NOT WITHOUT_SERVER)
++ INSTALL(FILES ${MAN1_TOOLS} DESTINATION ${INSTALL_MANDIR}/man1 COMPONENT ManPages)
++ INSTALL(FILES ${MAN8} DESTINATION ${INSTALL_MANDIR}/man8 COMPONENT ManPages)
++ENDIF()
+
+ IF(WITH_ROUTER)
+ INSTALL(FILES ${MAN1_ROUTER}
diff --git a/databases/mysql81-server/files/patch-mysys_my__default.cc b/databases/mysql81-server/files/patch-mysys_my__default.cc
new file mode 100644
index 000000000000..eba6ce293b1f
--- /dev/null
+++ b/databases/mysql81-server/files/patch-mysys_my__default.cc
@@ -0,0 +1,62 @@
+--- mysys/my_default.cc.orig 2023-06-21 07:52:10 UTC
++++ mysys/my_default.cc
+@@ -207,7 +207,7 @@ bool no_defaults = false;
+
+ /* Which directories are searched for options (and in which order) */
+
+-#define MAX_DEFAULT_DIRS 6
++#define MAX_DEFAULT_DIRS 7
+ #define DEFAULT_DIRS_SIZE (MAX_DEFAULT_DIRS + 1) /* Terminate with NULL */
+ static const char **default_directories = nullptr;
+
+@@ -925,6 +925,14 @@ static int search_default_file_with_ext(Process_option
+ return 1; /* Ignore wrong files */
+ }
+
++ if (strstr(name, "/etc") == name)
++ {
++ fprintf(stderr,
++ "error: Config file %s in invalid location, please move to or merge with /usr/local%s\n",
++ name,name);
++ goto err;
++ }
++
+ while (true) {
+ auto fileline = mysql_file_getline(buff, sizeof(buff), fp, is_login_file);
+ char *linebuff = fileline.get();
+@@ -1314,7 +1322,8 @@ void my_print_default_files(const char *conf_file) {
+ end[(strlen(end) - 1)] = ' ';
+ else
+ strxmov(end, conf_file, *ext, " ", NullS);
+- fputs(name, stdout);
++ if (strstr(name, "/etc") != name)
++ fputs(name, stdout);
+ }
+ }
+ }
+@@ -1655,14 +1664,9 @@ static const char **init_default_directories(MEM_ROOT
+
+ #else
+
+- errors += add_directory(alloc, "/etc/", dirs);
+- errors += add_directory(alloc, "/etc/mysql/", dirs);
++ errors += add_directory(alloc, "/usr/local/etc/", dirs);
++ errors += add_directory(alloc, "/usr/local/etc/mysql/", dirs);
+
+-#if defined(DEFAULT_SYSCONFDIR)
+- if (DEFAULT_SYSCONFDIR[0])
+- errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
+-#endif /* DEFAULT_SYSCONFDIR */
+-
+ #endif
+
+ if ((env = getenv("MYSQL_HOME"))) errors += add_directory(alloc, env, dirs);
+@@ -1727,7 +1731,7 @@ int check_file_permissions(const char *file_name, bool
+ #if !defined(_WIN32)
+ MY_STAT stat_info;
+
+- if (!my_stat(file_name, &stat_info, flags)) return 1;
++ if (!my_stat(file_name, &stat_info, flags)) return 0;
+ /*
+ Ignore .mylogin.cnf file if not exclusively readable/writable
+ by current user.
diff --git a/databases/mysql81-server/files/patch-mysys_my__kdf.cc b/databases/mysql81-server/files/patch-mysys_my__kdf.cc
new file mode 100644
index 000000000000..e4b12bfc09a0
--- /dev/null
+++ b/databases/mysql81-server/files/patch-mysys_my__kdf.cc
@@ -0,0 +1,20 @@
+--- mysys/my_kdf.cc.orig 2022-12-11 13:12:02 UTC
++++ mysys/my_kdf.cc
+@@ -56,7 +56,7 @@ int create_kdf_key(const unsigned char *key, const uns
+ std::unique_ptr<Key_derivation_function> kdf_function;
+
+ if (kdf_name == "hkdf") {
+-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
++#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
+ kdf_function = std::make_unique<Key_hkdf_function>(kdf_options);
+ #else
+ return 1;
+@@ -71,7 +71,7 @@ int create_kdf_key(const unsigned char *key, const uns
+ return kdf_function->derive_key(key, key_length, rkey, rkey_size);
+ }
+
+-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
++#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
+ Key_hkdf_function::Key_hkdf_function(vector<string> *kdf_options) {
+ kdf_options_ = {kdf_options};
+ }
diff --git a/databases/mysql81-server/files/patch-plugin_password__validation_validate__password.cc b/databases/mysql81-server/files/patch-plugin_password__validation_validate__password.cc
new file mode 100644
index 000000000000..4f1313993d21
--- /dev/null
+++ b/databases/mysql81-server/files/patch-plugin_password__validation_validate__password.cc
@@ -0,0 +1,11 @@
+--- plugin/password_validation/validate_password.cc.orig 2019-09-20 08:30:51 UTC
++++ plugin/password_validation/validate_password.cc
+@@ -25,6 +25,8 @@
+ #include <mysql/plugin_validate_password.h>
+ #include <mysql/service_my_plugin_log.h>
+ #include <mysql/service_mysql_string.h>
++/* solve clash between libc++ bitset::test() and test macro from my_global.h */
++#undef test
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
diff --git a/databases/mysql81-server/files/patch-plugin_x_CMakeLists.txt b/databases/mysql81-server/files/patch-plugin_x_CMakeLists.txt
new file mode 100644
index 000000000000..e1e9d8674c99
--- /dev/null
+++ b/databases/mysql81-server/files/patch-plugin_x_CMakeLists.txt
@@ -0,0 +1,11 @@
+--- plugin/x/CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ plugin/x/CMakeLists.txt
+@@ -81,6 +81,8 @@ INCLUDE_DIRECTORIES(
+ ${MYSQLX_GENERATE_DIR}
+ ${MYSQLX_PROTOCOL_INCLUDE_DIR}
+ ${MYSQLX_CLIENT_INCLUDE_DIR}
++ ${OPENSSL_INCLUDE_DIR}
++ ${BOOST_INCLUDE_DIR}
+ )
+
+ ADD_COMPILE_FLAGS(${XPLUGIN_SRC}
diff --git a/databases/mysql81-server/files/patch-plugin_x_client_authentication_sha256__scramble__generator.cc b/databases/mysql81-server/files/patch-plugin_x_client_authentication_sha256__scramble__generator.cc
new file mode 100644
index 000000000000..0e894219bb8d
--- /dev/null
+++ b/databases/mysql81-server/files/patch-plugin_x_client_authentication_sha256__scramble__generator.cc
@@ -0,0 +1,11 @@
+--- plugin/x/client/authentication/sha256_scramble_generator.cc.orig 2019-09-20 08:30:51 UTC
++++ plugin/x/client/authentication/sha256_scramble_generator.cc
+@@ -97,7 +97,7 @@ bool SHA256_digest::retrieve_digest(unsigned char *dig
+ return true;
+ }
+ m_ok = EVP_DigestFinal_ex(md_context, m_digest, nullptr);
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
+ EVP_MD_CTX_cleanup(md_context);
+ #else /* OPENSSL_VERSION_NUMBER < 0x10100000L */
+ EVP_MD_CTX_reset(md_context);
diff --git a/databases/mysql81-server/files/patch-plugin_x_configure.cmake b/databases/mysql81-server/files/patch-plugin_x_configure.cmake
new file mode 100644
index 000000000000..3d56059d869a
--- /dev/null
+++ b/databases/mysql81-server/files/patch-plugin_x_configure.cmake
@@ -0,0 +1,15 @@
+--- plugin/x/configure.cmake.orig 2019-09-20 08:30:51 UTC
++++ plugin/x/configure.cmake
+@@ -45,6 +45,7 @@ CONFIGURE_FILE(${MYSQLX_PROJECT_DIR}/src/config/mysqlx
+ CONFIGURE_FILE(${MYSQLX_PROJECT_DIR}/src/config/mysqlx_version.h.in
+ ${MYSQLX_GENERATE_DIR}/mysqlx_version.h )
+
++IF(FALSE)
+ INSTALL(FILES ${MYSQLX_GENERATE_DIR}/mysqlx_error.h
+ DESTINATION ${INSTALL_INCLUDEDIR}
+ COMPONENT Development)
+@@ -56,3 +57,4 @@ INSTALL(FILES ${MYSQLX_GENERATE_DIR}/mysqlx_ername.h
+ INSTALL(FILES ${MYSQLX_GENERATE_DIR}/mysqlx_version.h
+ DESTINATION ${INSTALL_INCLUDEDIR}
+ COMPONENT Development)
++ENDIF()
diff --git a/databases/mysql81-server/files/patch-router_src_harness_include_mysql_harness_net__ts_impl_kqueue__io__service.h b/databases/mysql81-server/files/patch-router_src_harness_include_mysql_harness_net__ts_impl_kqueue__io__service.h
new file mode 100644
index 000000000000..6e24f0300ecf
--- /dev/null
+++ b/databases/mysql81-server/files/patch-router_src_harness_include_mysql_harness_net__ts_impl_kqueue__io__service.h
@@ -0,0 +1,13 @@
+--- router/src/harness/include/mysql/harness/net_ts/impl/kqueue_io_service.h.orig 2023-06-21 07:52:10 UTC
++++ router/src/harness/include/mysql/harness/net_ts/impl/kqueue_io_service.h
+@@ -190,8 +190,8 @@ class kqueue_io_service : public IoServiceBase {
+ auto secs = std::chrono::duration_cast<std::chrono::seconds>(timeout);
+ timeout -= secs;
+
+- ts = {secs.count(),
+- std::chrono::duration_cast<std::chrono::nanoseconds>(timeout)
++ ts = {(time_t)secs.count(),
++ (long)std::chrono::duration_cast<std::chrono::nanoseconds>(timeout)
+ .count()};
+
+ p_ts = &ts;
diff --git a/databases/mysql81-server/files/patch-router_src_harness_include_mysql_harness_net__ts_internet.h b/databases/mysql81-server/files/patch-router_src_harness_include_mysql_harness_net__ts_internet.h
new file mode 100644
index 000000000000..015c6839ada0
--- /dev/null
+++ b/databases/mysql81-server/files/patch-router_src_harness_include_mysql_harness_net__ts_internet.h
@@ -0,0 +1,10 @@
+--- router/src/harness/include/mysql/harness/net_ts/internet.h.orig 2020-11-09 00:30:01 UTC
++++ router/src/harness/include/mysql/harness/net_ts/internet.h
+@@ -43,6 +43,7 @@
+ #include <arpa/inet.h> // inet_ntop
+ #include <netdb.h> // getaddrinfo
+ #include <netinet/in.h> // in_addr_t
++#include <sys/types.h> // u_int32_t
+ #include <netinet/ip6.h> // in6_addr_t
+ #include <netinet/tcp.h> // TCP_NODELAY
+ #include <sys/ioctl.h> // ioctl
diff --git a/databases/mysql81-server/files/patch-router_src_harness_src_CMakeLists.txt b/databases/mysql81-server/files/patch-router_src_harness_src_CMakeLists.txt
new file mode 100644
index 000000000000..1e4459495165
--- /dev/null
+++ b/databases/mysql81-server/files/patch-router_src_harness_src_CMakeLists.txt
@@ -0,0 +1,24 @@
+--- router/src/harness/src/CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ router/src/harness/src/CMakeLists.txt
+@@ -230,7 +230,6 @@ ELSE()
+ INSTALL(TARGETS harness-library
+ LIBRARY
+ DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+- NAMELINK_SKIP
+ )
+ ENDIF()
+
+@@ -262,7 +261,6 @@ INSTALL(TARGETS harness_stdx
+ RUNTIME DESTINATION ${ROUTER_INSTALL_BINDIR} COMPONENT Router
+ ARCHIVE DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+ LIBRARY DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+- NAMELINK_SKIP
+ )
+
+ ## harness_tls
+@@ -304,5 +302,4 @@ INSTALL(TARGETS harness_tls
+ RUNTIME DESTINATION ${ROUTER_INSTALL_BINDIR} COMPONENT Router
+ ARCHIVE DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+ LIBRARY DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+- NAMELINK_SKIP
+ )
diff --git a/databases/mysql81-server/files/patch-router_src_harness_src_tls__client__context.cc b/databases/mysql81-server/files/patch-router_src_harness_src_tls__client__context.cc
new file mode 100644
index 000000000000..d366ee9f7425
--- /dev/null
+++ b/databases/mysql81-server/files/patch-router_src_harness_src_tls__client__context.cc
@@ -0,0 +1,11 @@
+--- router/src/harness/src/tls_client_context.cc.orig 2023-06-21 07:52:10 UTC
++++ router/src/harness/src/tls_client_context.cc
+@@ -101,7 +101,7 @@ stdx::expected<void, std::error_code> TlsClientContext
+ stdx::expected<void, std::error_code> TlsClientContext::cipher_suites(
+ const std::string &ciphers) {
+ // TLSv1.3 ciphers are controlled via SSL_CTX_set_ciphersuites()
+-#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 1)
++#ifdef TLS1_3_VERSION
+ if (1 != SSL_CTX_set_ciphersuites(ssl_ctx_.get(), ciphers.c_str())) {
+ return stdx::make_unexpected(make_tls_error());
+ }
diff --git a/databases/mysql81-server/files/patch-router_src_harness_src_tls__context.cc b/databases/mysql81-server/files/patch-router_src_harness_src_tls__context.cc
new file mode 100644
index 000000000000..b1d818afe81a
--- /dev/null
+++ b/databases/mysql81-server/files/patch-router_src_harness_src_tls__context.cc
@@ -0,0 +1,44 @@
+--- router/src/harness/src/tls_context.cc.orig 2021-12-17 16:07:27 UTC
++++ router/src/harness/src/tls_context.cc
+@@ -241,7 +241,7 @@ static int o11x_version(TlsVersion version) {
+ return TLS1_1_VERSION;
+ case TlsVersion::TLS_1_2:
+ return TLS1_2_VERSION;
+-#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 1)
++#ifdef TLS1_3_VERSION
+ case TlsVersion::TLS_1_3:
+ return TLS1_3_VERSION;
+ #endif
+@@ -272,9 +272,11 @@ stdx::expected<void, std::error_code> TlsContext::vers
+ default:
+ // unknown, leave all disabled
+ [[fallthrough]];
++#ifdef TLS1_3_VERSION
+ case TlsVersion::TLS_1_3:
+ opts |= SSL_OP_NO_TLSv1_2;
+ [[fallthrough]];
++#endif
+ case TlsVersion::TLS_1_2:
+ opts |= SSL_OP_NO_TLSv1_1;
+ [[fallthrough]];
+@@ -322,8 +324,10 @@ TlsVersion TlsContext::min_version() const {
+ return TlsVersion::TLS_1_1;
+ case TLS1_2_VERSION:
+ return TlsVersion::TLS_1_2;
++#ifdef TLS1_3_VERSION
+ case TLS1_3_VERSION:
+ return TlsVersion::TLS_1_3;
++#endif
+ case 0:
+ return TlsVersion::AUTO;
+ default:
+@@ -382,7 +386,8 @@ TlsContext::InfoCallback TlsContext::info_callback() c
+ }
+
+ int TlsContext::security_level() const {
+-#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0)
++#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0) && \
++ !defined(LIBRESSL_VERSION_NUMBER)
+ return SSL_CTX_get_security_level(ssl_ctx_.get());
+ #else
+ return 0;
diff --git a/databases/mysql81-server/files/patch-router_src_http_src_CMakeLists.txt b/databases/mysql81-server/files/patch-router_src_http_src_CMakeLists.txt
new file mode 100644
index 000000000000..d6d71414449d
--- /dev/null
+++ b/databases/mysql81-server/files/patch-router_src_http_src_CMakeLists.txt
@@ -0,0 +1,26 @@
+--- router/src/http/src/CMakeLists.txt.orig 2021-12-17 16:07:27 UTC
++++ router/src/http/src/CMakeLists.txt
+@@ -58,7 +58,6 @@ INSTALL(TARGETS http_common
+ RUNTIME DESTINATION ${ROUTER_INSTALL_BINDIR} COMPONENT Router
+ ARCHIVE DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+ LIBRARY DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+- NAMELINK_SKIP
+ )
+
+ ## split library code from the plugin to use them _passwd and tests
+@@ -84,7 +83,6 @@ INSTALL(TARGETS http_auth_backend_lib
+ RUNTIME DESTINATION ${ROUTER_INSTALL_BINDIR} COMPONENT Router
+ ARCHIVE DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+ LIBRARY DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+- NAMELINK_SKIP
+ )
+ TARGET_INCLUDE_DIRECTORIES(http_auth_backend_lib PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}
+@@ -137,7 +135,6 @@ INSTALL(TARGETS http_auth_realm_lib
+ RUNTIME DESTINATION ${ROUTER_INSTALL_BINDIR} COMPONENT Router
+ ARCHIVE DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+ LIBRARY DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+- NAMELINK_SKIP
+ )
+ ## the rpath for the bundled openssl
+ ADD_INSTALL_RPATH_FOR_OPENSSL(http_auth_realm_lib)
diff --git a/databases/mysql81-server/files/patch-router_src_io_src_CMakeLists.txt b/databases/mysql81-server/files/patch-router_src_io_src_CMakeLists.txt
new file mode 100644
index 000000000000..474f473e1893
--- /dev/null
+++ b/databases/mysql81-server/files/patch-router_src_io_src_CMakeLists.txt
@@ -0,0 +1,10 @@
+--- router/src/io/src/CMakeLists.txt.orig 2020-09-23 12:37:48 UTC
++++ router/src/io/src/CMakeLists.txt
+@@ -47,7 +47,6 @@ INSTALL(TARGETS io_component
+ RUNTIME DESTINATION ${ROUTER_INSTALL_BINDIR} COMPONENT Router
+ ARCHIVE DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+ LIBRARY DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+- NAMELINK_SKIP
+ )
+
+ GENERATE_EXPORT_HEADER(io_component
diff --git a/databases/mysql81-server/files/patch-router_src_router_src_CMakeLists.txt b/databases/mysql81-server/files/patch-router_src_router_src_CMakeLists.txt
new file mode 100644
index 000000000000..0a26f51a8ac9
--- /dev/null
+++ b/databases/mysql81-server/files/patch-router_src_router_src_CMakeLists.txt
@@ -0,0 +1,10 @@
+--- router/src/router/src/CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ router/src/router/src/CMakeLists.txt
+@@ -149,7 +149,6 @@ INSTALL(TARGETS router_lib
+ RUNTIME DESTINATION ${ROUTER_INSTALL_BINDIR} COMPONENT Router
+ ARCHIVE DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+ LIBRARY DESTINATION ${ROUTER_INSTALL_LIBDIR} COMPONENT Router
+- NAMELINK_SKIP
+ )
+
+ MYSQL_ADD_EXECUTABLE(mysqlrouter_keyring
diff --git a/databases/mysql81-server/files/patch-scripts_CMakeLists.txt b/databases/mysql81-server/files/patch-scripts_CMakeLists.txt
new file mode 100644
index 000000000000..4f2f5afb57d4
--- /dev/null
+++ b/databases/mysql81-server/files/patch-scripts_CMakeLists.txt
@@ -0,0 +1,52 @@
+--- scripts/CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ scripts/CMakeLists.txt
+@@ -336,6 +336,8 @@ MACRO(EXTRACT_LINK_LIBRARIES target var)
+ SET(${var} "${${var}}-L${dir} " )
+ ENDIF()
+ SET(${var} "${${var}}-l${lib} " )
++ ELSEIF(lib STREQUAL "-pthread")
++ SET(${var} "${${var}}-pthread " )
+ ELSE()
+ SET(${var} "${${var}}-l${lib} " )
+ ENDIF()
+@@ -409,7 +411,7 @@ ELSE()
+ ${CMAKE_CURRENT_BINARY_DIR}/${PKGCONFIG_FILE}
+ ESCAPE_QUOTES @ONLY)
+
+- IF(INSTALL_PKGCONFIGDIR)
++ IF(INSTALL_PKGCONFIGDIR AND NOT WITHOUT_CLIENTLIBS)
+ MESSAGE(STATUS "INSTALL ${PKGCONFIG_FILE} ${INSTALL_PKGCONFIGDIR}")
+ INSTALL(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/${PKGCONFIG_FILE}
+@@ -422,23 +424,28 @@ ELSE()
+ # mysqld_safe used in mtr even for systemd platforms
+ IF(WITH_SYSTEMD)
+ SET(BIN_SCRIPTS
+- mysql_config
+ mysqldumpslow
+ mysqld_safe
+ )
+ ELSE()
+ SET(BIN_SCRIPTS
+- mysql_config
+ mysqldumpslow
+ mysqld_multi
+ mysqld_safe
+ )
+ ENDIF()
+
++ IF(NOT WITHOUT_CLIENTLIBS)
++ SET(BIN_SCRIPTS
++ ${BIN_SCRIPTS}
++ mysql_config
++ )
++ ENDIF(NOT WITHOUT_CLIENTLIBS)
++
+ FOREACH(file ${BIN_SCRIPTS})
+ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh
+- ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY
++ ${CMAKE_CURRENT_BINARY_DIR}/${file} @ONLY
+ )
+ ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.pl.in)
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.pl.in
diff --git a/databases/mysql81-server/files/patch-scripts_mysqld__safe.sh b/databases/mysql81-server/files/patch-scripts_mysqld__safe.sh
new file mode 100644
index 000000000000..47bc81e3963b
--- /dev/null
+++ b/databases/mysql81-server/files/patch-scripts_mysqld__safe.sh
@@ -0,0 +1,19 @@
+--- scripts/mysqld_safe.sh.orig 2022-01-23 11:48:36 UTC
++++ scripts/mysqld_safe.sh
+@@ -360,7 +360,7 @@ mysqld_ld_preload_text() {
+ # running mysqld. See ld.so for details.
+ set_malloc_lib() {
+ # This list is kept intentionally simple.
+- malloc_dirs="/usr/lib /usr/lib64 /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu"
++ malloc_dirs="/usr/lib /usr/lib64 /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu /usr/local/lib"
+ malloc_lib="$1"
+
+ # Allow --malloc-lib='' to override other settings
+@@ -379,6 +379,7 @@ set_malloc_lib() {
+ /usr/lib64) ;;
+ /usr/lib/i386-linux-gnu) ;;
+ /usr/lib/x86_64-linux-gnu) ;;
++ /usr/local/lib) ;;
+ *)
+ log_error "--malloc-lib must be located in one of the directories: $malloc_dirs"
+ exit 1
diff --git a/databases/mysql81-server/files/patch-sql_auth_sha2__password__common.cc b/databases/mysql81-server/files/patch-sql_auth_sha2__password__common.cc
new file mode 100644
index 000000000000..56f6dfb3fbb7
--- /dev/null
+++ b/databases/mysql81-server/files/patch-sql_auth_sha2__password__common.cc
@@ -0,0 +1,11 @@
+--- sql/auth/sha2_password_common.cc.orig 2019-09-20 08:30:51 UTC
++++ sql/auth/sha2_password_common.cc
+@@ -101,7 +101,7 @@ bool SHA256_digest::retrieve_digest(unsigned char *dig
+ return true;
+ }
+ m_ok = EVP_DigestFinal_ex(md_context, m_digest, nullptr);
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
+ EVP_MD_CTX_cleanup(md_context);
+ #else /* OPENSSL_VERSION_NUMBER < 0x10100000L */
+ EVP_MD_CTX_reset(md_context);
diff --git a/databases/mysql81-server/files/patch-sql_auth_sql__authorization.cc b/databases/mysql81-server/files/patch-sql_auth_sql__authorization.cc
new file mode 100644
index 000000000000..e9282f545a1c
--- /dev/null
+++ b/databases/mysql81-server/files/patch-sql_auth_sql__authorization.cc
@@ -0,0 +1,13 @@
+--- sql/auth/sql_authorization.cc.orig 2023-06-21 07:52:10 UTC
++++ sql/auth/sql_authorization.cc
+@@ -7437,6 +7437,10 @@ bool operator==(const Role_id &a, const std::string &b
+ return tmp == b;
+ }
+
++bool operator==(const Role_id &a, const LEX_CSTRING &b) {
++ return a == to_string(b);
++}
++
+ bool operator==(const std::pair<Role_id, bool> &a, const std::string &b) {
+ return a.first == b;
+ }
diff --git a/databases/mysql81-server/files/patch-sql_conn__handler_socket__connection.cc b/databases/mysql81-server/files/patch-sql_conn__handler_socket__connection.cc
new file mode 100644
index 000000000000..6aa01f9e3e3a
--- /dev/null
+++ b/databases/mysql81-server/files/patch-sql_conn__handler_socket__connection.cc
@@ -0,0 +1,32 @@
+--- sql/conn_handler/socket_connection.cc.orig 2023-06-21 07:52:10 UTC
++++ sql/conn_handler/socket_connection.cc
+@@ -960,9 +960,11 @@ bool check_connection_refused_by_tcp_wrapper(MYSQL_SOC
+ signal(SIGCHLD, SIG_DFL);
+ request_init(&req, RQ_DAEMON, libwrap_name, RQ_FILE,
+ mysql_socket_getfd(connect_sock), NULL);
+- fromhost(&req);
++ void (*my_fromhost) (void *) = (void (*)(void *)) fromhost;
++ my_fromhost(&req);
+
+- if (!hosts_access(&req)) {
++ int (*my_hosts_access) (void *) = (int (*) (void *)) hosts_access;
++ if (!my_hosts_access(&req)) {
+ /*
+ This may be stupid but refuse() includes an exit(0)
+ which we surely don't want...
+@@ -974,12 +976,13 @@ bool check_connection_refused_by_tcp_wrapper(MYSQL_SOC
+ This is unproblematic as TCP-wrapper is unix specific,
+ anyway.
+ */
++ char *(*my_eval_client) (void *) = (char *(*) (void *)) eval_client;
+ syslog(LOG_AUTH | LOG_WARNING, "refused connect from %s",
+- eval_client(&req));
++ my_eval_client(&req));
+
+ #ifdef HAVE_LIBWRAP_PROTOTYPES
+ // Some distros have patched tcpd.h to have proper prototypes
+- if (req.sink) (req.sink)(req.fd);
++ if (req.sink) ((void (*)(int)) (req.sink))(req.fd);
+ #else
+ // Some distros have not patched tcpd.h
+ if (req.sink) ((void (*)(int))req.sink)(req.fd);
diff --git a/databases/mysql81-server/files/patch-sql_mysqld.cc b/databases/mysql81-server/files/patch-sql_mysqld.cc
new file mode 100644
index 000000000000..6f0533832abb
--- /dev/null
+++ b/databases/mysql81-server/files/patch-sql_mysqld.cc
@@ -0,0 +1,11 @@
+--- sql/mysqld.cc.orig 2023-06-21 07:52:10 UTC
++++ sql/mysqld.cc
+@@ -5428,7 +5428,7 @@ static PSI_memory_key key_memory_openssl = PSI_NOT_INS
+
+ static PSI_memory_key key_memory_openssl = PSI_NOT_INSTRUMENTED;
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ #define FILE_LINE_ARGS
+ #else
+ #define FILE_LINE_ARGS , const char *, int
diff --git a/databases/mysql81-server/files/patch-sql_ssl__init__callback.cc b/databases/mysql81-server/files/patch-sql_ssl__init__callback.cc
new file mode 100644
index 000000000000..96bd029197e9
--- /dev/null
+++ b/databases/mysql81-server/files/patch-sql_ssl__init__callback.cc
@@ -0,0 +1,36 @@
+--- sql/ssl_init_callback.cc.orig 2023-06-21 07:52:10 UTC
++++ sql/ssl_init_callback.cc
+@@ -110,14 +110,14 @@ static Sys_var_charptr Sys_tls_version(
+
+ static Sys_var_charptr Sys_tls_version(
+ "tls_version",
+-#ifdef HAVE_TLSv13
++#if defined(HAVE_TLSv13) && !defined(LIBRESSL_VERSION_NUMBER)
+ "TLS version, permitted values are TLSv1.2, TLSv1.3",
+ #else
+ "TLS version, permitted values are TLSv1.2",
+ #endif
+ PERSIST_AS_READONLY GLOBAL_VAR(opt_tls_version),
+ CMD_LINE(REQUIRED_ARG, OPT_TLS_VERSION), IN_FS_CHARSET,
+-#ifdef HAVE_TLSv13
++#if defined(HAVE_TLSv13) && !defined(LIBRESSL_VERSION_NUMBER)
+ "TLSv1.2,TLSv1.3",
+ #else
+ "TLSv1.2",
+@@ -197,14 +197,14 @@ static Sys_var_charptr Sys_admin_tls_version(
+
+ static Sys_var_charptr Sys_admin_tls_version(
+ "admin_tls_version",
+-#ifdef HAVE_TLSv13
++#if defined(HAVE_TLSv13) && !defined(LIBRESSL_VERSION_NUMBER)
+ "TLS version for --admin-port, permitted values are TLSv1.2, TLSv1.3",
+ #else
+ "TLS version for --admin-port, permitted values are TLSv1.2",
+ #endif
+ PERSIST_AS_READONLY GLOBAL_VAR(opt_admin_tls_version),
+ CMD_LINE(REQUIRED_ARG, OPT_TLS_VERSION), IN_FS_CHARSET,
+-#ifdef HAVE_TLSv13
++#if defined(HAVE_TLSv13) && !defined(LIBRESSL_VERSION_NUMBER)
+ "TLSv1.2,TLSv1.3",
+ #else
+ "TLSv1.2",
diff --git a/databases/mysql81-server/files/patch-sql_sys__vars.cc b/databases/mysql81-server/files/patch-sql_sys__vars.cc
new file mode 100644
index 000000000000..cfff31af4057
--- /dev/null
+++ b/databases/mysql81-server/files/patch-sql_sys__vars.cc
@@ -0,0 +1,29 @@
+--- sql/sys_vars.cc.orig 2023-06-21 07:52:10 UTC
++++ sql/sys_vars.cc
+@@ -2045,7 +2045,7 @@ static Sys_var_ulong Sys_connect_timeout(
+ "The number of seconds the mysqld server is waiting for a connect "
+ "packet before responding with 'Bad handshake'",
+ GLOBAL_VAR(connect_timeout), CMD_LINE(REQUIRED_ARG),
+- VALID_RANGE(2, LONG_TIMEOUT), DEFAULT(CONNECT_TIMEOUT), BLOCK_SIZE(1));
++ VALID_RANGE(2, INT_MAX32 / 1000), DEFAULT(CONNECT_TIMEOUT), BLOCK_SIZE(1));
+
+ static Sys_var_ulong Sys_information_schema_stats_expiry(
+ "information_schema_stats_expiry",
+@@ -3201,7 +3201,7 @@ static Sys_var_ulong Sys_net_read_timeout(
+ "Number of seconds to wait for more data from a connection before "
+ "aborting the read",
+ SESSION_VAR(net_read_timeout), CMD_LINE(REQUIRED_ARG),
+- VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(NET_READ_TIMEOUT), BLOCK_SIZE(1),
++ VALID_RANGE(1, INT_MAX32 / 1000), DEFAULT(NET_READ_TIMEOUT), BLOCK_SIZE(1),
+ NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(nullptr),
+ ON_UPDATE(fix_net_read_timeout));
+
+@@ -3222,7 +3222,7 @@ static Sys_var_ulong Sys_net_write_timeout(
+ "Number of seconds to wait for a block to be written to a connection "
+ "before aborting the write",
+ SESSION_VAR(net_write_timeout), CMD_LINE(REQUIRED_ARG),
+- VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(NET_WRITE_TIMEOUT), BLOCK_SIZE(1),
++ VALID_RANGE(1, INT_MAX32 / 1000), DEFAULT(NET_WRITE_TIMEOUT), BLOCK_SIZE(1),
+ NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(nullptr),
+ ON_UPDATE(fix_net_write_timeout));
+
diff --git a/databases/mysql81-server/files/patch-storage_innobase_include_srv0mon.h b/databases/mysql81-server/files/patch-storage_innobase_include_srv0mon.h
new file mode 100644
index 000000000000..ee591adb8697
--- /dev/null
+++ b/databases/mysql81-server/files/patch-storage_innobase_include_srv0mon.h
@@ -0,0 +1,13 @@
+--- storage/innobase/include/srv0mon.h.orig 2019-09-20 08:30:51 UTC
++++ storage/innobase/include/srv0mon.h
+@@ -40,6 +40,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ /* Required for FreeBSD so that INT64_MAX is defined. */
+ #define __STDC_LIMIT_MACROS
+ #endif /* __STDC_LIMIT_MACROS */
++#ifdef __DragonFly__
++/* The hack above doen't work for dragonfly, stdint.h already imported */
++#include <machine/int_limits.h>
++#endif
+
+ #include <stdint.h>
+
diff --git a/databases/mysql81-server/files/patch-storage_innobase_include_ut0crc32.h b/databases/mysql81-server/files/patch-storage_innobase_include_ut0crc32.h
new file mode 100644
index 000000000000..45695dfc36ad
--- /dev/null
+++ b/databases/mysql81-server/files/patch-storage_innobase_include_ut0crc32.h
@@ -0,0 +1,12 @@
+--- storage/innobase/include/ut0crc32.h.orig 2023-06-21 07:52:10 UTC
++++ storage/innobase/include/ut0crc32.h
+@@ -132,7 +132,9 @@ CRC32_DEFAULT
+ #endif /* CRC32_ARM64 */
+
+ #ifdef CRC32_ARM64_DEFAULT
++#ifndef __FreeBSD__
+ #include <asm/hwcap.h>
++#endif /* __FreeBSD__ */
+ #include <sys/auxv.h>
+ #endif /* CRC32_ARM64_DEFAULT */
+
diff --git a/databases/mysql81-server/files/patch-storage_innobase_ut_crc32.cc b/databases/mysql81-server/files/patch-storage_innobase_ut_crc32.cc
new file mode 100644
index 000000000000..d8662b03ba53
--- /dev/null
+++ b/databases/mysql81-server/files/patch-storage_innobase_ut_crc32.cc
@@ -0,0 +1,104 @@
+--- storage/innobase/ut/crc32.cc.orig 2023-06-21 07:52:10 UTC
++++ storage/innobase/ut/crc32.cc
+@@ -332,8 +332,25 @@ bool can_use_poly_mul() { return true; }
+ #endif /* CRC32_ARM64_APPLE */
+
+ #ifdef CRC32_ARM64_DEFAULT
++#ifdef __FreeBSD__
++bool can_use_crc32() {
++ unsigned long capabilities;
++
++ if (elf_aux_info(AT_HWCAP, &capabilities, sizeof(unsigned long)))
++ return false;
++ return capabilities & HWCAP_CRC32;
++}
++bool can_use_poly_mul() {
++ unsigned long capabilities;
++
++ if (elf_aux_info(AT_HWCAP, &capabilities, sizeof(unsigned long)))
++ return false;
++ return capabilities & HWCAP_CRC32;
++}
++#else
+ bool can_use_crc32() { return getauxval(AT_HWCAP) & HWCAP_CRC32; }
+ bool can_use_poly_mul() { return getauxval(AT_HWCAP) & HWCAP_PMULL; }
++#endif
+ #endif /* CRC32_ARM64_DEFAULT */
+
+ /** A helper template to statically unroll a loop with a fixed number of
+@@ -442,25 +459,39 @@ uint64_t crc32_impl::update(uint64_t crc, uint64_t dat
+
+ #ifdef CRC32_ARM64
+ #ifdef CRC32_ARM64_DEFAULT
++#ifndef __clang__
+ MY_ATTRIBUTE((target("+crc")))
++#else
++MY_ATTRIBUTE((target("crc")))
++#endif
+ #endif /* CRC32_ARM64_DEFAULT */
+ uint32_t crc32_impl::update(uint32_t crc, unsigned char data) {
+ return __crc32cb(crc, data);
+ }
+ #ifdef CRC32_ARM64_DEFAULT
++#ifndef __clang__
+ MY_ATTRIBUTE((target("+crc")))
++#endif
+ #endif /* CRC32_ARM64_DEFAULT */
+ uint32_t crc32_impl::update(uint32_t crc, uint16_t data) {
+ return __crc32ch(crc, data);
+ }
+ #ifdef CRC32_ARM64_DEFAULT
++#ifndef __clang__
+ MY_ATTRIBUTE((target("+crc")))
++#else
++MY_ATTRIBUTE((target("crc")))
++#endif
+ #endif /* CRC32_ARM64_DEFAULT */
+ uint32_t crc32_impl::update(uint32_t crc, uint32_t data) {
+ return __crc32cw(crc, data);
+ }
+ #ifdef CRC32_ARM64_DEFAULT
++#ifndef __clang__
+ MY_ATTRIBUTE((target("+crc")))
++#else
++MY_ATTRIBUTE((target("crc")))
++#endif
+ #endif /* CRC32_ARM64_DEFAULT */
+ uint64_t crc32_impl::update(uint64_t crc, uint64_t data) {
+ return (uint64_t)__crc32cd((uint32_t)crc, data);
+@@ -506,7 +537,11 @@ template <uint32_t w>
+ }
+ template <uint32_t w>
+ #ifdef CRC32_ARM64_DEFAULT
++#ifndef __clang__
+ MY_ATTRIBUTE((target("+crypto")))
++#else
++MY_ATTRIBUTE((target("crypto")))
++#endif
+ #endif /* CRC32_ARM64_DEFAULT */
+ uint64_t use_pclmul::polynomial_mul_rev(uint32_t rev_u) {
+ constexpr uint64_t flipped_w = flip_at_32(w);
+@@ -749,7 +784,11 @@ MY_ATTRIBUTE((flatten))
+ MY_ATTRIBUTE((flatten))
+ #endif /* CRC32_ARM64_APPLE */
+ #ifdef CRC32_ARM64_DEFAULT
++#ifndef __clang__
+ MY_ATTRIBUTE((target("+crc+crypto"), flatten))
++#else
++MY_ATTRIBUTE((target("crc,crypto")))
++#endif
+ #endif /* CRC32_ARM64_DEFAULT */
+ uint32_t crc32_using_pclmul(const byte *data, size_t len) {
+ return crc32<use_pclmul>(0, data, len);
+@@ -769,7 +808,11 @@ MY_ATTRIBUTE((flatten))
+ MY_ATTRIBUTE((flatten))
+ #endif /* CRC32_ARM64_APPLE */
+ #ifdef CRC32_ARM64_DEFAULT
++#ifndef __clang__
+ MY_ATTRIBUTE((target("+crc"), flatten))
++#else
++MY_ATTRIBUTE((target("crc")))
++#endif
+ #endif /* CRC32_ARM64_DEFAULT */
+ uint32_t crc32_using_unrolled_loop_poly_mul(const byte *data, size_t len) {
+ return crc32<use_unrolled_loop_poly_mul>(0, data, len);
diff --git a/databases/mysql81-server/files/patch-storage_myisam_mi__dynrec.cc b/databases/mysql81-server/files/patch-storage_myisam_mi__dynrec.cc
new file mode 100644
index 000000000000..4daceefef132
--- /dev/null
+++ b/databases/mysql81-server/files/patch-storage_myisam_mi__dynrec.cc
@@ -0,0 +1,22 @@
+--- storage/myisam/mi_dynrec.cc.orig 2019-09-20 08:30:51 UTC
++++ storage/myisam/mi_dynrec.cc
+@@ -85,17 +85,12 @@ bool mi_dynmap_file(MI_INFO *info, my_off_t size) {
+ return true;
+ }
+ /*
+- I wonder if it is good to use MAP_NORESERVE. From the Linux man page:
+- MAP_NORESERVE
+- Do not reserve swap space for this mapping. When swap space is
+- reserved, one has the guarantee that it is possible to modify the
+- mapping. When swap space is not reserved one might get SIGSEGV
+- upon a write if no physical memory is available.
++ MAP_NORESERVE is unimplemented in FreeBSD
+ */
+ info->s->file_map = (uchar *)my_mmap(
+ nullptr, (size_t)size,
+ info->s->mode == O_RDONLY ? PROT_READ : PROT_READ | PROT_WRITE,
+- MAP_SHARED | MAP_NORESERVE, info->dfile, 0L);
++ MAP_SHARED, info->dfile, 0L);
+ if (info->s->file_map == (uchar *)MAP_FAILED) {
+ info->s->file_map = nullptr;
+ return true;
diff --git a/databases/mysql81-server/files/patch-storage_temptable_include_temptable_lock__free__type.h b/databases/mysql81-server/files/patch-storage_temptable_include_temptable_lock__free__type.h
new file mode 100644
index 000000000000..f0891fb365e2
--- /dev/null
+++ b/databases/mysql81-server/files/patch-storage_temptable_include_temptable_lock__free__type.h
@@ -0,0 +1,17 @@
+--- storage/temptable/include/temptable/lock_free_type.h.orig 2023-06-21 07:52:10 UTC
++++ storage/temptable/include/temptable/lock_free_type.h
+@@ -32,6 +32,14 @@ Lock-free type (selection) implementation. */
+ #include "my_config.h"
+ #include "storage/temptable/include/temptable/constants.h"
+
++#if defined(__i386__) //&& defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)
++/* Fix for clang setting __GCC_ATOMIC_LLONG_LOCK_FREE incorrectly for x86
++ * https://llvm.org/bugs/show_bug.cgi?id=19355
++ */
++#undef ATOMIC_LLONG_LOCK_FREE
++#define ATOMIC_LLONG_LOCK_FREE 2
++#endif
++
+ namespace temptable {
+
+ /** Clang has a bug which causes ATOMIC_LLONG_LOCK_FREE to be defined as 1
diff --git a/databases/mysql81-server/files/patch-support-files_CMakeLists.txt b/databases/mysql81-server/files/patch-support-files_CMakeLists.txt
new file mode 100644
index 000000000000..88a193db5fdc
--- /dev/null
+++ b/databases/mysql81-server/files/patch-support-files_CMakeLists.txt
@@ -0,0 +1,39 @@
+--- support-files/CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ support-files/CMakeLists.txt
+@@ -24,8 +24,9 @@ ENDIF()
+ RETURN()
+ ENDIF()
+
+-INSTALL(FILES mysql.m4
+- DESTINATION ${INSTALL_SHAREDIR}/aclocal COMPONENT Development)
++IF(NOT WITHOUT_CLIENTLIBS)
++ INSTALL(FILES mysql.m4 DESTINATION ${INSTALL_SHAREDIR}/aclocal COMPONENT Development)
++ENDIF(NOT WITHOUT_CLIENTLIBS)
+
+ SET(localstatedir "${MYSQL_DATADIR}")
+
+@@ -43,7 +44,7 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql-log-r
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql-log-rotate.in
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate @ONLY)
+
+-IF(NOT WITH_SYSTEMD)
++IF(NOT WITHOUT_SERVER)
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql.server.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql.server @ONLY
+ )
+@@ -59,6 +60,7 @@ ENDIF()
+ )
+ ENDIF()
+
++IF(NOT WITHOUT_SERVER)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate
+ COMPONENT Server_Scripts
+ DESTINATION ${INSTALL_SUPPORTFILESDIR}
+@@ -66,6 +68,7 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-ro
+ OWNER_READ OWNER_WRITE
+ GROUP_READ WORLD_READ
+ )
++ENDIF()
+
+ IF(WITH_ROUTER)
+ IF(NOT WITH_SYSTEMD)
diff --git a/databases/mysql81-server/files/patch-utilities_CMakeLists.txt b/databases/mysql81-server/files/patch-utilities_CMakeLists.txt
new file mode 100644
index 000000000000..61f984d763b5
--- /dev/null
+++ b/databases/mysql81-server/files/patch-utilities_CMakeLists.txt
@@ -0,0 +1,79 @@
+--- utilities/CMakeLists.txt.orig 2023-06-21 07:52:10 UTC
++++ utilities/CMakeLists.txt
+@@ -24,13 +24,19 @@ MSVC_CPPCHECK_DISABLE()
+ DISABLE_MISSING_PROFILE_WARNING()
+ MSVC_CPPCHECK_DISABLE()
+
+-IF(NOT CMAKE_CROSSCOMPILING)
++IF(WITHOUT_CLIENTLIBS)
+ MYSQL_ADD_EXECUTABLE(comp_err
+ comp_err.cc
+ COMPONENT Test
+ LINK_LIBRARIES mysys
++ SKIP_INSTALL)
++ELSE(WITHOUT_CLIENTLIBS)
++ MYSQL_ADD_EXECUTABLE(comp_err
++ comp_err.cc
++ COMPONENT Test
++ LINK_LIBRARIES mysys
+ )
+-ENDIF()
++ENDIF(WITHOUT_CLIENTLIBS)
+
+ MYSQL_ADD_EXECUTABLE(comp_client_err
+ comp_client_err.cc
+@@ -113,10 +119,30 @@ MYSQL_ADD_EXECUTABLE(static_thread_local_test
+ EXCLUDE_FROM_ALL
+ )
+
++IF(WITHOUT_CLIENTLIBS)
+ MYSQL_ADD_EXECUTABLE(my_print_defaults
+ my_print_defaults.cc
+ COMPONENT Server
+ LINK_LIBRARIES mysys
++ SKIP_INSTALL )
++MYSQL_ADD_EXECUTABLE(perror
++ perror.cc
++ COMPONENT Server
++ DEPENDENCIES GenError
++ LINK_LIBRARIES mysys
++ SKIP_INSTALL )
++IF(BUILD_BUNDLED_LZ4)
++ MYSQL_ADD_EXECUTABLE(lz4_decompress
++ lz4_decompress.cc
++ COMPONENT Server
++ LINK_LIBRARIES ${LZ4_LIBRARY} mysys
++ SKIP_INSTALL )
++ENDIF()
++ELSE(WITHOUT_CLIENTLIBS)
++MYSQL_ADD_EXECUTABLE(my_print_defaults
++ my_print_defaults.cc
++ COMPONENT Server
++ LINK_LIBRARIES mysys
+ )
+ MYSQL_ADD_EXECUTABLE(perror
+ perror.cc
+@@ -131,12 +157,23 @@ ENDIF()
+ LINK_LIBRARIES ext::lz4 mysys
+ )
+ ENDIF()
++ENDIF(WITHOUT_CLIENTLIBS)
+
++IF(WITHOUT_CLIENTLIBS)
+ MYSQL_ADD_EXECUTABLE(zlib_decompress
+ zlib_decompress.cc
+ COMPONENT Server
+ LINK_LIBRARIES ext::zlib mysys
++ SKIP_INSTALL )
++ELSE(WITHOUT_CLIENTLIBS)
++IF(BUILD_BUNDLED_ZLIB OR NOT OPENSSL_EXECUTABLE_HAS_ZLIB)
++ MYSQL_ADD_EXECUTABLE(zlib_decompress
++ zlib_decompress.cc
++ COMPONENT Server
++ LINK_LIBRARIES ${ZLIB_LIBRARY} mysys
+ )
++ENDIF()
++ENDIF(WITHOUT_CLIENTLIBS)
+
+ # All targets below belong to COMPONENT Server and depend on InnoDB.
+ IF(WITHOUT_SERVER)
diff --git a/databases/mysql81-server/files/patch-vio_viossl.cc b/databases/mysql81-server/files/patch-vio_viossl.cc
new file mode 100644
index 000000000000..4a993d1fe051
--- /dev/null
+++ b/databases/mysql81-server/files/patch-vio_viossl.cc
@@ -0,0 +1,30 @@
+--- vio/viossl.cc.orig 2023-06-21 07:52:10 UTC
++++ vio/viossl.cc
+@@ -45,7 +45,8 @@
+ BIO_set_callback_ex was added in openSSL 1.1.1
+ For older openSSL, use the deprecated BIO_set_callback.
+ */
+-#if OPENSSL_VERSION_NUMBER >= 0x10101000L
++#if OPENSSL_VERSION_NUMBER >= 0x10101000L && \
++ !defined(LIBRESSL_VERSION_NUMBER)
+ #define HAVE_BIO_SET_CALLBACK_EX
+ #endif
+
+@@ -698,7 +699,7 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, l
+ #if !defined(NDEBUG)
+ {
+ STACK_OF(SSL_COMP) *ssl_comp_methods = nullptr;
+- ssl_comp_methods = SSL_COMP_get_compression_methods();
++ ssl_comp_methods = (STACK_OF(SSL_COMP) *)SSL_COMP_get_compression_methods();
+ n = sk_SSL_COMP_num(ssl_comp_methods);
+ DBUG_PRINT("info", ("Available compression methods:\n"));
+ if (n == 0)
+@@ -706,7 +707,7 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, l
+ else
+ for (j = 0; j < n; j++) {
+ SSL_COMP *c = sk_SSL_COMP_value(ssl_comp_methods, j);
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ DBUG_PRINT("info", (" %d: %s\n", c->id, c->name));
+ #else /* OPENSSL_VERSION_NUMBER < 0x10100000L */
+ DBUG_PRINT("info",
diff --git a/databases/mysql81-server/files/patch-vio_viosslfactories.cc b/databases/mysql81-server/files/patch-vio_viosslfactories.cc
new file mode 100644
index 000000000000..80e10a9495ad
--- /dev/null
+++ b/databases/mysql81-server/files/patch-vio_viosslfactories.cc
@@ -0,0 +1,46 @@
+--- vio/viosslfactories.cc.orig 2023-06-21 07:52:10 UTC
++++ vio/viosslfactories.cc
+@@ -45,6 +45,7 @@
+ #include <dh_ecdh_config.h>
+
+ #include "my_openssl_fips.h"
++#include "openssl/crypto.h"
+ #define TLS_VERSION_OPTION_SIZE 256
+
+ /*
+@@ -422,7 +423,7 @@ long process_tls_version(const char *tls_version) {
+ const char *separator = ",";
+ char *token, *lasts = nullptr;
+
+-#ifdef HAVE_TLSv13
++#if defined(HAVE_TLSv13) && !defined(LIBRESSL_VERSION_NUMBER)
+ const char *tls_version_name_list[] = {"TLSv1.2", "TLSv1.3"};
+ const char ctx_flag_default[] = "TLSv1.2,TLSv1.3";
+ const long tls_ctx_list[] = {SSL_OP_NO_TLSv1_2, SSL_OP_NO_TLSv1_3};
+@@ -494,7 +495,7 @@ static struct st_VioSSLFd *new_VioSSLFd(
+ ssl_ctx_options = (ssl_ctx_options | ssl_ctx_flags) &
+ (SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 |
+ SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2
+-#ifdef HAVE_TLSv13
++#if defined(HAVE_TLSv13) && !defined(LIBRESSL_VERSION_NUMBER)
+ | SSL_OP_NO_TLSv1_3
+ #endif /* HAVE_TLSv13 */
+ | SSL_OP_NO_TICKET);
+@@ -503,7 +504,7 @@ static struct st_VioSSLFd *new_VioSSLFd(
+ return nullptr;
+
+ if (!(ssl_fd->ssl_context = SSL_CTX_new(is_client ?
+-#ifdef HAVE_TLSv13
++#if defined(HAVE_TLSv13) && !defined(LIBRESSL_VERSION_NUMBER)
+ TLS_client_method()
+ : TLS_server_method()
+ #else /* HAVE_TLSv13 */
+@@ -518,7 +519,7 @@ static struct st_VioSSLFd *new_VioSSLFd(
+ return nullptr;
+ }
+
+-#ifdef HAVE_TLSv13
++#if defined(HAVE_TLSv13) && !defined(LIBRESSL_VERSION_NUMBER)
+ /*
+ Set OpenSSL TLS v1.3 ciphersuites.
+ Note that an empty list is permissible.
diff --git a/databases/mysql81-server/files/pkg-message.in b/databases/mysql81-server/files/pkg-message.in
new file mode 100644
index 000000000000..efe29e7bc126
--- /dev/null
+++ b/databases/mysql81-server/files/pkg-message.in
@@ -0,0 +1,21 @@
+[
+{ type: install
+ message: <<EOM
+There is no initial password for first time use of MySQL.
+Keep in mind to reset it to a secure password.
+
+MySQL80 has a default %%ETCDIR%%/my.cnf,
+remember to replace it with your own
+or set `mysql_optfile="$YOUR_CNF_FILE` in rc.conf.
+EOM
+}
+{ type: upgrade
+ message: <<EOM
+As of MySQL 8.0.16, the MySQL server performs the upgrade tasks previously
+handled by mysql_upgrade. Consequently, mysql_upgrade is unneeded and is
+deprecated as of that version, and will be removed in a future MySQL version.
+Because mysql_upgrade no longer performs upgrade tasks,
+it exits with status 0 unconditionally.
+EOM
+}
+]
diff --git a/databases/mysql81-server/pkg-descr b/databases/mysql81-server/pkg-descr
new file mode 100644
index 000000000000..4893ba6f2444
--- /dev/null
+++ b/databases/mysql81-server/pkg-descr
@@ -0,0 +1,12 @@
+MySQL is a very fast, multi-threaded, multi-user and robust SQL
+(Structured Query Language) database server.
+The new features in MySQL 8.0. In addition to Data Dictionnary and CTEs are:
+ Move to utf8(mb4) as MySQL's default character set
+ Language specific case insensitive collation for 21 languages (utf8)
+ Invisible index
+ Descending indexes
+ Improve usability of UUID and IPV6 manipulations
+ SQL roles - SET PERSIST for global variable values
+ Performance Schema, instrumenting data locks
+ Performance Schema, instrumenting error messages
+ Improved cost model with histograms
diff --git a/databases/mysql81-server/pkg-plist b/databases/mysql81-server/pkg-plist
new file mode 100644
index 000000000000..eef9b2f59c0e
--- /dev/null
+++ b/databases/mysql81-server/pkg-plist
@@ -0,0 +1,253 @@
+LICENSE.router
+README.router
+bin/ibd2sdi
+bin/innochecksum
+bin/myisam_ftdump
+bin/myisamchk
+bin/myisamlog
+bin/myisampack
+bin/mysql_client_test
+bin/mysql_keyring_encryption_test
+bin/mysql_secure_installation
+bin/mysql_ssl_rsa_setup
+bin/mysql_test_event_tracking
+bin/mysql_tzinfo_to_sql
+bin/mysql_upgrade
+bin/mysqld_multi
+bin/mysqld_safe
+bin/mysqldumpslow
+bin/mysqlrouter
+bin/mysqlrouter_keyring
+bin/mysqlrouter_passwd
+bin/mysqlrouter_plugin_info
+bin/mysqltest
+bin/mysqltest_safe_process
+bin/mysqlxtest
+etc/logrotate.d/mysqlrouter
+%%ETCDIR%%/my.cnf.sample
+lib/mysql/libmysqlharness.so
+lib/mysql/libmysqlharness.so.1
+lib/mysql/libmysqlharness_stdx.so
+lib/mysql/libmysqlharness_stdx.so.1
+lib/mysql/libmysqlharness_tls.so
+lib/mysql/libmysqlharness_tls.so.1
+lib/mysql/libmysqlrouter.so
+lib/mysql/libmysqlrouter.so.1
+lib/mysql/libmysqlrouter_connection_pool.so.1
+lib/mysql/libmysqlrouter_destination_status.so.1
+lib/mysql/libmysqlrouter_http.so
+lib/mysql/libmysqlrouter_http.so.1
+lib/mysql/libmysqlrouter_http_auth_backend.so
+lib/mysql/libmysqlrouter_http_auth_backend.so.1
+lib/mysql/libmysqlrouter_http_auth_realm.so
+lib/mysql/libmysqlrouter_http_auth_realm.so.1
+lib/mysql/libmysqlrouter_io_component.so
+lib/mysql/libmysqlrouter_io_component.so.1
+lib/mysql/libmysqlrouter_metadata_cache.so.1
+lib/mysql/libmysqlrouter_mysqlxmessages.so.1
+lib/mysql/libmysqlrouter_routing.so.1
+lib/mysql/libprotobuf-lite.so.3.19.4
+lib/mysql/mysqlrouter/connection_pool.so
+lib/mysql/mysqlrouter/destination_status.so
+lib/mysql/mysqlrouter/http_auth_backend.so
+lib/mysql/mysqlrouter/http_auth_realm.so
+lib/mysql/mysqlrouter/http_server.so
+lib/mysql/mysqlrouter/io.so
+lib/mysql/mysqlrouter/keepalive.so
+lib/mysql/mysqlrouter/metadata_cache.so
+lib/mysql/mysqlrouter/rest_api.so
+lib/mysql/mysqlrouter/rest_connection_pool.so
+lib/mysql/mysqlrouter/rest_metadata_cache.so
+lib/mysql/mysqlrouter/rest_router.so
+lib/mysql/mysqlrouter/rest_routing.so
+lib/mysql/mysqlrouter/router_openssl.so
+lib/mysql/mysqlrouter/router_protobuf.so
+lib/mysql/mysqlrouter/routing.so
+lib/mysql/plugin/adt_null.so
+lib/mysql/plugin/auth.so
+lib/mysql/plugin/auth_test_plugin.so
+lib/mysql/plugin/component_audit_api_message_emit.so
+lib/mysql/plugin/component_example_component1.so
+lib/mysql/plugin/component_example_component2.so
+lib/mysql/plugin/component_example_component3.so
+lib/mysql/plugin/component_keyring_file.so
+lib/mysql/plugin/component_log_filter_dragnet.so
+lib/mysql/plugin/component_log_sink_json.so
+lib/mysql/plugin/component_log_sink_syseventlog.so
+lib/mysql/plugin/component_log_sink_test.so
+lib/mysql/plugin/component_mysqlbackup.so
+lib/mysql/plugin/component_mysqlx_global_reset.so
+lib/mysql/plugin/component_pfs_example.so
+lib/mysql/plugin/component_pfs_example_component_population.so
+lib/mysql/plugin/component_query_attributes.so
+lib/mysql/plugin/component_reference_cache.so
+lib/mysql/plugin/component_test_audit_api_message.so
+lib/mysql/plugin/component_test_backup_lock_service.so
+lib/mysql/plugin/component_test_component_deinit.so
+lib/mysql/plugin/component_test_event_tracking_consumer.so
+lib/mysql/plugin/component_test_event_tracking_consumer_a.so
+lib/mysql/plugin/component_test_event_tracking_consumer_b.so
+lib/mysql/plugin/component_test_event_tracking_consumer_c.so
+lib/mysql/plugin/component_test_event_tracking_producer_a.so
+lib/mysql/plugin/component_test_event_tracking_producer_b.so
+lib/mysql/plugin/component_test_host_application_signal.so
+lib/mysql/plugin/component_test_mysql_command_services.so
+lib/mysql/plugin/component_test_mysql_current_thread_reader.so
+lib/mysql/plugin/component_test_mysql_runtime_error.so
+lib/mysql/plugin/component_test_mysql_system_variable_set.so
+lib/mysql/plugin/component_test_mysql_thd_store_service.so
+lib/mysql/plugin/component_test_pfs_notification.so
+lib/mysql/plugin/component_test_pfs_resource_group.so
+lib/mysql/plugin/component_test_sensitive_system_variables.so
+lib/mysql/plugin/component_test_server_telemetry_traces.so
+lib/mysql/plugin/component_test_status_var_reader.so
+lib/mysql/plugin/component_test_status_var_service.so
+lib/mysql/plugin/component_test_status_var_service_int.so
+lib/mysql/plugin/component_test_status_var_service_reg_only.so
+lib/mysql/plugin/component_test_status_var_service_str.so
+lib/mysql/plugin/component_test_status_var_service_unreg_only.so
+lib/mysql/plugin/component_test_string_service.so
+lib/mysql/plugin/component_test_string_service_charset.so
+lib/mysql/plugin/component_test_string_service_long.so
+lib/mysql/plugin/component_test_sys_var_service.so
+lib/mysql/plugin/component_test_sys_var_service_int.so
+lib/mysql/plugin/component_test_sys_var_service_same.so
+lib/mysql/plugin/component_test_sys_var_service_str.so
+lib/mysql/plugin/component_test_system_variable_source.so
+lib/mysql/plugin/component_test_table_access.so
+lib/mysql/plugin/component_test_udf_registration.so
+lib/mysql/plugin/component_test_udf_services.so
+lib/mysql/plugin/component_udf_reg_3_func.so
+lib/mysql/plugin/component_udf_reg_avg_func.so
+lib/mysql/plugin/component_udf_reg_int_func.so
+lib/mysql/plugin/component_udf_reg_int_same_func.so
+lib/mysql/plugin/component_udf_reg_only_3_func.so
+lib/mysql/plugin/component_udf_reg_real_func.so
+lib/mysql/plugin/component_udf_unreg_3_func.so
+lib/mysql/plugin/component_udf_unreg_int_func.so
+lib/mysql/plugin/component_udf_unreg_real_func.so
+lib/mysql/plugin/component_validate_password.so
+lib/mysql/plugin/conflicting_variables.so
+lib/mysql/plugin/connection_control.so
+lib/mysql/plugin/daemon_example.ini
+lib/mysql/plugin/ddl_rewriter.so
+lib/mysql/plugin/group_replication.so
+lib/mysql/plugin/ha_example.so
+lib/mysql/plugin/ha_mock.so
+lib/mysql/plugin/keyring_file.so
+lib/mysql/plugin/keyring_udf.so
+lib/mysql/plugin/libdaemon_example.so
+lib/mysql/plugin/libtest_framework.so
+lib/mysql/plugin/libtest_services.so
+lib/mysql/plugin/libtest_services_threaded.so
+lib/mysql/plugin/libtest_session_attach.so
+lib/mysql/plugin/libtest_session_detach.so
+lib/mysql/plugin/libtest_session_in_thd.so
+lib/mysql/plugin/libtest_session_info.so
+lib/mysql/plugin/libtest_sql_2_sessions.so
+lib/mysql/plugin/libtest_sql_all_col_types.so
+lib/mysql/plugin/libtest_sql_cmds_1.so
+lib/mysql/plugin/libtest_sql_commit.so
+lib/mysql/plugin/libtest_sql_complex.so
+lib/mysql/plugin/libtest_sql_errors.so
+lib/mysql/plugin/libtest_sql_lock.so
+lib/mysql/plugin/libtest_sql_processlist.so
+lib/mysql/plugin/libtest_sql_replication.so
+lib/mysql/plugin/libtest_sql_reset_connection.so
+lib/mysql/plugin/libtest_sql_shutdown.so
+lib/mysql/plugin/libtest_sql_sleep_is_connected.so
+lib/mysql/plugin/libtest_sql_sqlmode.so
+lib/mysql/plugin/libtest_sql_stmt.so
+lib/mysql/plugin/libtest_sql_stored_procedures_functions.so
+lib/mysql/plugin/libtest_sql_views_triggers.so
+lib/mysql/plugin/libtest_x_sessions_deinit.so
+lib/mysql/plugin/libtest_x_sessions_init.so
+lib/mysql/plugin/locking_service.so
+lib/mysql/plugin/mypluglib.so
+lib/mysql/plugin/mysql_clone.so
+lib/mysql/plugin/mysql_no_login.so
+lib/mysql/plugin/pfs_example_plugin_employee.so
+lib/mysql/plugin/qa_auth_client.so
+lib/mysql/plugin/qa_auth_interface.so
+lib/mysql/plugin/qa_auth_server.so
+lib/mysql/plugin/replication_observers_example_plugin.so
+lib/mysql/plugin/rewrite_example.so
+lib/mysql/plugin/rewriter.so
+lib/mysql/plugin/semisync_master.so
+lib/mysql/plugin/semisync_replica.so
+lib/mysql/plugin/semisync_slave.so
+lib/mysql/plugin/semisync_source.so
+lib/mysql/plugin/test_security_context.so
+lib/mysql/plugin/test_services_command_services.so
+lib/mysql/plugin/test_services_host_application_signal.so
+lib/mysql/plugin/test_services_plugin_registry.so
+lib/mysql/plugin/test_udf_services.so
+lib/mysql/plugin/udf_example.so
+lib/mysql/plugin/validate_password.so
+lib/mysql/plugin/version_token.so
+lib/mysql/private/libprotobuf-lite.so.3.19.4
+lib/mysql/private/libprotobuf.so.3.19.4
+libexec/mysqld
+%%DATADIR%%/bulgarian/errmsg.sys
+%%DATADIR%%/charsets/Index.xml
+%%DATADIR%%/charsets/README
+%%DATADIR%%/charsets/armscii8.xml
+%%DATADIR%%/charsets/ascii.xml
+%%DATADIR%%/charsets/cp1250.xml
+%%DATADIR%%/charsets/cp1251.xml
+%%DATADIR%%/charsets/cp1256.xml
+%%DATADIR%%/charsets/cp1257.xml
+%%DATADIR%%/charsets/cp850.xml
+%%DATADIR%%/charsets/cp852.xml
+%%DATADIR%%/charsets/cp866.xml
+%%DATADIR%%/charsets/dec8.xml
+%%DATADIR%%/charsets/geostd8.xml
+%%DATADIR%%/charsets/greek.xml
+%%DATADIR%%/charsets/hebrew.xml
+%%DATADIR%%/charsets/hp8.xml
+%%DATADIR%%/charsets/keybcs2.xml
+%%DATADIR%%/charsets/koi8r.xml
+%%DATADIR%%/charsets/koi8u.xml
+%%DATADIR%%/charsets/latin1.xml
+%%DATADIR%%/charsets/latin2.xml
+%%DATADIR%%/charsets/latin5.xml
+%%DATADIR%%/charsets/latin7.xml
+%%DATADIR%%/charsets/macce.xml
+%%DATADIR%%/charsets/macroman.xml
+%%DATADIR%%/charsets/swe7.xml
+%%DATADIR%%/czech/errmsg.sys
+%%DATADIR%%/danish/errmsg.sys
+%%DATADIR%%/dictionary.txt
+%%DATADIR%%/dutch/errmsg.sys
+%%DATADIR%%/english/errmsg.sys
+%%DATADIR%%/estonian/errmsg.sys
+%%DATADIR%%/french/errmsg.sys
+%%DATADIR%%/german/errmsg.sys
+%%DATADIR%%/greek/errmsg.sys
+%%DATADIR%%/hungarian/errmsg.sys
+%%DATADIR%%/install_rewriter.sql
+%%DATADIR%%/italian/errmsg.sys
+%%DATADIR%%/japanese/errmsg.sys
+%%DATADIR%%/korean/errmsg.sys
+%%DATADIR%%/messages_to_clients.txt
+%%DATADIR%%/messages_to_error_log.txt
+%%DATADIR%%/mysql-log-rotate
+%%DATADIR%%/mysql.server
+%%DATADIR%%/mysqld_multi.server
+%%DATADIR%%/norwegian-ny/errmsg.sys
+%%DATADIR%%/norwegian/errmsg.sys
+%%DATADIR%%/polish/errmsg.sys
+%%DATADIR%%/portuguese/errmsg.sys
+%%DATADIR%%/romanian/errmsg.sys
+%%DATADIR%%/russian/errmsg.sys
+%%DATADIR%%/serbian/errmsg.sys
+%%DATADIR%%/slovak/errmsg.sys
+%%DATADIR%%/spanish/errmsg.sys
+%%DATADIR%%/swedish/errmsg.sys
+%%DATADIR%%/ukrainian/errmsg.sys
+%%DATADIR%%/uninstall_rewriter.sql
+%%DATADIR%%router/docs/sample_mysqlrouter.conf
+@dir %%ETCDIR%%/keyring
+@dir lib/mysql/plugin/debug
+@dir %%MY_SECDIR%%
+@dir %%MY_TMPDIR%%