mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
simplified mariadb-connector-c compilation and fixed caching_sha2_password plugin
This commit is contained in:
parent
abc7fbf6c8
commit
84cfbb8e69
12
contrib/CMakeLists.txt
vendored
12
contrib/CMakeLists.txt
vendored
@ -138,11 +138,13 @@ if (USE_INTERNAL_SSL_LIBRARY)
|
||||
endif ()
|
||||
|
||||
if (ENABLE_MYSQL AND USE_INTERNAL_MYSQL_LIBRARY)
|
||||
add_subdirectory (mariadb-connector-c-cmake)
|
||||
target_include_directories(mysqlclient BEFORE PRIVATE ${ZLIB_INCLUDE_DIR})
|
||||
if(OPENSSL_INCLUDE_DIR)
|
||||
target_include_directories(mysqlclient BEFORE PRIVATE ${OPENSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
set(CLIENT_PLUGIN_CACHING_SHA2_PASSWORD STATIC)
|
||||
set(CLIENT_PLUGIN_SHA256_PASSWORD STATIC)
|
||||
set(CLIENT_PLUGIN_REMOTE_IO OFF)
|
||||
set(CLIENT_PLUGIN_DIALOG OFF)
|
||||
set(CLIENT_PLUGIN_CLIENT_ED25519 OFF)
|
||||
set(CLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD OFF)
|
||||
add_subdirectory (mariadb-connector-c)
|
||||
endif ()
|
||||
|
||||
if (USE_INTERNAL_RDKAFKA_LIBRARY)
|
||||
|
2
contrib/mariadb-connector-c
vendored
2
contrib/mariadb-connector-c
vendored
@ -1 +1 @@
|
||||
Subproject commit c6503d3acc85ca1a7f5e7e38b605d7c9410aac1e
|
||||
Subproject commit 9bbf08c2a0fb7b34671291fce13e6af62c5343a2
|
@ -1,74 +0,0 @@
|
||||
set(MARIADB_CLIENT_SOURCE_DIR ${ClickHouse_SOURCE_DIR}/contrib/mariadb-connector-c)
|
||||
set(MARIADB_CLIENT_BINARY_DIR ${ClickHouse_BINARY_DIR}/contrib/mariadb-connector-c)
|
||||
|
||||
set(SRCS
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/bmove_upp.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/get_password.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_alloc.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_array.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_charset.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_compress.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_context.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_default.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_dtoa.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_errmsg.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_hash.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_init.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_io.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_list.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_ll2str.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_loaddata.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_net.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_password.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_pvio.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/mariadb_async.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/mariadb_charset.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/mariadb_dyncol.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/mariadb_lib.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/mariadb_stmt.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_sha1.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_stmt_codec.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_string.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_time.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/ma_tls.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/secure/openssl_crypt.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/secure/gnutls.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/secure/ma_schannel.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/secure/schannel.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/auth_gssapi_client.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/dialog.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/gssapi_client.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/gssapi_errmsg.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/mariadb_cleartext.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/my_auth.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/old_password.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/sha256_pw.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/caching_sha2_pw.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/sspi_client.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/auth/sspi_errmsg.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/plugins/connection/aurora.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/plugins/connection/replication.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/io/remote_io.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/pvio/pvio_npipe.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/pvio/pvio_shmem.c
|
||||
${MARIADB_CLIENT_SOURCE_DIR}/plugins/pvio/pvio_socket.c
|
||||
#${MARIADB_CLIENT_SOURCE_DIR}/plugins/trace/trace_example.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux_x86_64/libmariadb/ma_client_plugin.c
|
||||
)
|
||||
|
||||
if(OPENSSL_LIBRARIES)
|
||||
list(APPEND SRCS ${MARIADB_CLIENT_SOURCE_DIR}/libmariadb/secure/openssl.c)
|
||||
endif()
|
||||
|
||||
add_library(mysqlclient ${SRCS})
|
||||
|
||||
if(OPENSSL_LIBRARIES)
|
||||
target_link_libraries(mysqlclient PRIVATE ${OPENSSL_LIBRARIES})
|
||||
target_compile_definitions(mysqlclient PRIVATE -D HAVE_OPENSSL -D HAVE_TLS)
|
||||
endif()
|
||||
|
||||
target_include_directories(mysqlclient PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/linux_x86_64/include)
|
||||
target_include_directories(mysqlclient PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/common/include)
|
||||
target_include_directories(mysqlclient PUBLIC ${MARIADB_CLIENT_SOURCE_DIR}/include)
|
||||
|
||||
target_compile_definitions(mysqlclient PRIVATE -D THREAD)
|
@ -1,269 +0,0 @@
|
||||
|
||||
/*
|
||||
* Include file constants (processed in LibmysqlIncludeFiles.txt 1
|
||||
*/
|
||||
#define HAVE_ALLOCA_H 1
|
||||
/* #undef HAVE_BIGENDIAN */
|
||||
#define HAVE_SETLOCALE 1
|
||||
#define HAVE_NL_LANGINFO 1
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
#define HAVE_CRYPT_H 1
|
||||
#define HAVE_DIRENT_H 1
|
||||
#define HAVE_DLFCN_H 1
|
||||
#define HAVE_EXECINFO_H 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_FENV_H 1
|
||||
#define HAVE_FLOAT_H 1
|
||||
/* #undef HAVE_FPU_CONTROL_H */
|
||||
#define HAVE_GRP_H 1
|
||||
/* #undef HAVE_IEEEFP_H */
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_MALLOC_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
#define HAVE_PATHS_H 1
|
||||
#define HAVE_PWD_H 1
|
||||
#define HAVE_SCHED_H 1
|
||||
/* #undef HAVE_SELECT_H */
|
||||
#define HAVE_STDDEF_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
/* #undef HAVE_SYNCH_H */
|
||||
/* #undef HAVE_SYS_FPU_H */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
#define HAVE_SYS_IPC_H 1
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
#define HAVE_SYS_PRCTL_H 1
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
#define HAVE_SYS_SHM_H 1
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
/* #undef HAVE_SYS_STREAM_H */
|
||||
#define HAVE_SYS_TIMEB_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_SYS_UN_H 1
|
||||
/* #undef HAVE_SYSENT_H */
|
||||
#define HAVE_TERMIO_H 1
|
||||
#define HAVE_TERMIOS_H 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_UTIME_H 1
|
||||
#define HAVE_UCONTEXT_H 1
|
||||
|
||||
/*
|
||||
* function definitions - processed in LibmysqlFunctions.txt
|
||||
*/
|
||||
#define HAVE_ACCESS 1
|
||||
/* #undef HAVE_AIOWAIT */
|
||||
#define HAVE_ALARM 1
|
||||
/* #undef HAVE_ALLOCA */
|
||||
#define HAVE_BCMP 1
|
||||
/* #undef HAVE_BFILL */
|
||||
/* #undef HAVE_BMOVE */
|
||||
#define HAVE_BZERO 1
|
||||
#define HAVE_CLOCK_GETTIME 1
|
||||
/* #undef HAVE_COMPRESS */
|
||||
/* #undef HAVE_CRYPT */
|
||||
#define HAVE_DLERROR 1
|
||||
#define HAVE_DLOPEN 1
|
||||
#define HAVE_FCHMOD 1
|
||||
#define HAVE_FCNTL 1
|
||||
/* #undef HAVE_FCONVERT */
|
||||
#define HAVE_FDATASYNC 1
|
||||
#define HAVE_FESETROUND 1
|
||||
#define HAVE_FINITE 1
|
||||
#define HAVE_FSEEKO 1
|
||||
#define HAVE_FSYNC 1
|
||||
#define HAVE_GETADDRINFO 1
|
||||
#define HAVE_GETCWD 1
|
||||
#define HAVE_GETHOSTBYADDR_R 1
|
||||
#define HAVE_GETHOSTBYNAME_R 1
|
||||
/* #undef HAVE_GETHRTIME */
|
||||
#define HAVE_GETNAMEINFO 1
|
||||
#define HAVE_GETPAGESIZE 1
|
||||
#define HAVE_GETPASS 1
|
||||
/* #undef HAVE_GETPASSPHRASE */
|
||||
#define HAVE_GETPWNAM 1
|
||||
#define HAVE_GETPWUID 1
|
||||
#define HAVE_GETRLIMIT 1
|
||||
#define HAVE_GETRUSAGE 1
|
||||
#define HAVE_GETWD 1
|
||||
#define HAVE_GMTIME_R 1
|
||||
#define HAVE_INITGROUPS 1
|
||||
#define HAVE_LDIV 1
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define HAVE_LOG2 1
|
||||
#define HAVE_LONGJMP 1
|
||||
#define HAVE_LSTAT 1
|
||||
#define HAVE_MADVISE 1
|
||||
#define HAVE_MALLINFO 1
|
||||
#define HAVE_MEMALIGN 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MKSTEMP 1
|
||||
#define HAVE_MLOCK 1
|
||||
#define HAVE_MLOCKALL 1
|
||||
#define HAVE_MMAP 1
|
||||
#define HAVE_MMAP64 1
|
||||
#define HAVE_PERROR 1
|
||||
#define HAVE_POLL 1
|
||||
#define HAVE_PREAD 1
|
||||
/* #undef HAVE_PTHREAD_ATTR_CREATE */
|
||||
#define HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
|
||||
/* #undef HAVE_PTHREAD_ATTR_SETPRIO */
|
||||
#define HAVE_PTHREAD_ATTR_SETSCHEDPARAM 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSCOPE 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
|
||||
/* #undef HAVE_PTHREAD_CONDATTR_CREATE */
|
||||
/* #undef HAVE_PTHREAD_INIT */
|
||||
#define HAVE_PTHREAD_KEY_DELETE 1
|
||||
#define HAVE_PTHREAD_KILL 1
|
||||
#define HAVE_PTHREAD_RWLOCK_RDLOCK 1
|
||||
/* #undef HAVE_PTHREAD_SETPRIO_NP */
|
||||
#define HAVE_PTHREAD_SETSCHEDPARAM 1
|
||||
#define HAVE_PTHREAD_SIGMASK 1
|
||||
/* #undef HAVE_PTHREAD_THREADMASK */
|
||||
/* #undef HAVE_PTHREAD_YIELD_NP */
|
||||
#define HAVE_READDIR_R 1
|
||||
#define HAVE_READLINK 1
|
||||
#define HAVE_REALPATH 1
|
||||
#define HAVE_RENAME 1
|
||||
#define HAVE_SCHED_YIELD 1
|
||||
#define HAVE_SELECT 1
|
||||
/* #undef HAVE_SETFD */
|
||||
/* #undef HAVE_SETFILEPOINTER */
|
||||
#define HAVE_SIGNAL 1
|
||||
#define HAVE_SIGACTION 1
|
||||
/* #undef HAVE_SIGTHREADMASK */
|
||||
#define HAVE_SIGWAIT 1
|
||||
#define HAVE_SLEEP 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
/* #undef HAVE_SQLITE */
|
||||
#define HAVE_STPCPY 1
|
||||
#define HAVE_STRERROR 1
|
||||
/* #undef HAVE_STRLCPY */
|
||||
#define HAVE_STRNLEN 1
|
||||
#define HAVE_STRPBRK 1
|
||||
#define HAVE_STRSEP 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOK_R 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
/* #undef HAVE_TELL */
|
||||
/* #undef HAVE_THR_SETCONCURRENCY */
|
||||
/* #undef HAVE_THR_YIELD */
|
||||
#define HAVE_VASPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/*
|
||||
* types and sizes
|
||||
*/
|
||||
/* Types we may use */
|
||||
#define SIZEOF_CHAR 1
|
||||
#if defined(SIZEOF_CHAR)
|
||||
# define HAVE_CHAR 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_CHARP 8
|
||||
#if defined(SIZEOF_CHARP)
|
||||
# define HAVE_CHARP 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_SHORT 2
|
||||
#if defined(SIZEOF_SHORT)
|
||||
# define HAVE_SHORT 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_INT 4
|
||||
#if defined(SIZEOF_INT)
|
||||
# define HAVE_INT 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_LONG 8
|
||||
#if defined(SIZEOF_LONG)
|
||||
# define HAVE_LONG 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#if defined(SIZEOF_LONG_LONG)
|
||||
# define HAVE_LONG_LONG 1
|
||||
#endif
|
||||
|
||||
|
||||
#define SIZEOF_SIGSET_T 128
|
||||
#if defined(SIZEOF_SIGSET_T)
|
||||
# define HAVE_SIGSET_T 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_SIZE_T 8
|
||||
#if defined(SIZEOF_SIZE_T)
|
||||
# define HAVE_SIZE_T 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_UCHAR */
|
||||
#if defined(SIZEOF_UCHAR)
|
||||
# define HAVE_UCHAR 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_UINT 4
|
||||
#if defined(SIZEOF_UINT)
|
||||
# define HAVE_UINT 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_ULONG 8
|
||||
#if defined(SIZEOF_ULONG)
|
||||
# define HAVE_ULONG 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT8 */
|
||||
#if defined(SIZEOF_INT8)
|
||||
# define HAVE_INT8 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT8 */
|
||||
#if defined(SIZEOF_UINT8)
|
||||
# define HAVE_UINT8 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT16 */
|
||||
#if defined(SIZEOF_INT16)
|
||||
# define HAVE_INT16 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT16 */
|
||||
#if defined(SIZEOF_UINT16)
|
||||
# define HAVE_UINT16 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT32 */
|
||||
#if defined(SIZEOF_INT32)
|
||||
# define HAVE_INT32 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT32 */
|
||||
#if defined(SIZEOF_UINT32)
|
||||
# define HAVE_UINT32 1
|
||||
#endif
|
||||
/* #undef SIZEOF_U_INT32_T */
|
||||
#if defined(SIZEOF_U_INT32_T)
|
||||
# define HAVE_U_INT32_T 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT64 */
|
||||
#if defined(SIZEOF_INT64)
|
||||
# define HAVE_INT64 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT64 */
|
||||
#if defined(SIZEOF_UINT64)
|
||||
# define HAVE_UINT64 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_SOCKLEN_T */
|
||||
#if defined(SIZEOF_SOCKLEN_T)
|
||||
# define HAVE_SOCKLEN_T 1
|
||||
#endif
|
||||
|
||||
#define SOCKET_SIZE_TYPE socklen_t
|
||||
|
||||
#define MARIADB_DEFAULT_CHARSET "latin1"
|
||||
|
@ -1,269 +0,0 @@
|
||||
|
||||
/*
|
||||
* Include file constants (processed in LibmysqlIncludeFiles.txt 1
|
||||
*/
|
||||
#define HAVE_ALLOCA_H 1
|
||||
/* #undef HAVE_BIGENDIAN */
|
||||
#define HAVE_SETLOCALE 1
|
||||
#define HAVE_NL_LANGINFO 1
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
#define HAVE_CRYPT_H 1
|
||||
#define HAVE_DIRENT_H 1
|
||||
#define HAVE_DLFCN_H 1
|
||||
#define HAVE_EXECINFO_H 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_FENV_H 1
|
||||
#define HAVE_FLOAT_H 1
|
||||
/* #undef HAVE_FPU_CONTROL_H */
|
||||
#define HAVE_GRP_H 1
|
||||
/* #undef HAVE_IEEEFP_H */
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_MALLOC_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
#define HAVE_PATHS_H 1
|
||||
#define HAVE_PWD_H 1
|
||||
#define HAVE_SCHED_H 1
|
||||
/* #undef HAVE_SELECT_H */
|
||||
#define HAVE_STDDEF_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
/* #undef HAVE_SYNCH_H */
|
||||
/* #undef HAVE_SYS_FPU_H */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
#define HAVE_SYS_IPC_H 1
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
#define HAVE_SYS_PRCTL_H 1
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
#define HAVE_SYS_SHM_H 1
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
/* #undef HAVE_SYS_STREAM_H */
|
||||
#define HAVE_SYS_TIMEB_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_SYS_UN_H 1
|
||||
/* #undef HAVE_SYSENT_H */
|
||||
#define HAVE_TERMIO_H 1
|
||||
#define HAVE_TERMIOS_H 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_UTIME_H 1
|
||||
#define HAVE_UCONTEXT_H 1
|
||||
|
||||
/*
|
||||
* function definitions - processed in LibmysqlFunctions.txt
|
||||
*/
|
||||
#define HAVE_ACCESS 1
|
||||
/* #undef HAVE_AIOWAIT */
|
||||
#define HAVE_ALARM 1
|
||||
/* #undef HAVE_ALLOCA */
|
||||
#define HAVE_BCMP 1
|
||||
/* #undef HAVE_BFILL */
|
||||
/* #undef HAVE_BMOVE */
|
||||
#define HAVE_BZERO 1
|
||||
#define HAVE_CLOCK_GETTIME 1
|
||||
/* #undef HAVE_COMPRESS */
|
||||
/* #undef HAVE_CRYPT */
|
||||
#define HAVE_DLERROR 1
|
||||
#define HAVE_DLOPEN 1
|
||||
#define HAVE_FCHMOD 1
|
||||
#define HAVE_FCNTL 1
|
||||
/* #undef HAVE_FCONVERT */
|
||||
#define HAVE_FDATASYNC 1
|
||||
#define HAVE_FESETROUND 1
|
||||
#define HAVE_FINITE 1
|
||||
#define HAVE_FSEEKO 1
|
||||
#define HAVE_FSYNC 1
|
||||
#define HAVE_GETADDRINFO 1
|
||||
#define HAVE_GETCWD 1
|
||||
#define HAVE_GETHOSTBYADDR_R 1
|
||||
#define HAVE_GETHOSTBYNAME_R 1
|
||||
/* #undef HAVE_GETHRTIME */
|
||||
#define HAVE_GETNAMEINFO 1
|
||||
#define HAVE_GETPAGESIZE 1
|
||||
#define HAVE_GETPASS 1
|
||||
/* #undef HAVE_GETPASSPHRASE */
|
||||
#define HAVE_GETPWNAM 1
|
||||
#define HAVE_GETPWUID 1
|
||||
#define HAVE_GETRLIMIT 1
|
||||
#define HAVE_GETRUSAGE 1
|
||||
#define HAVE_GETWD 1
|
||||
#define HAVE_GMTIME_R 1
|
||||
#define HAVE_INITGROUPS 1
|
||||
#define HAVE_LDIV 1
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define HAVE_LOG2 1
|
||||
#define HAVE_LONGJMP 1
|
||||
#define HAVE_LSTAT 1
|
||||
#define HAVE_MADVISE 1
|
||||
#define HAVE_MALLINFO 1
|
||||
#define HAVE_MEMALIGN 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MKSTEMP 1
|
||||
#define HAVE_MLOCK 1
|
||||
#define HAVE_MLOCKALL 1
|
||||
#define HAVE_MMAP 1
|
||||
#define HAVE_MMAP64 1
|
||||
#define HAVE_PERROR 1
|
||||
#define HAVE_POLL 1
|
||||
#define HAVE_PREAD 1
|
||||
/* #undef HAVE_PTHREAD_ATTR_CREATE */
|
||||
#define HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
|
||||
/* #undef HAVE_PTHREAD_ATTR_SETPRIO */
|
||||
#define HAVE_PTHREAD_ATTR_SETSCHEDPARAM 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSCOPE 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
|
||||
/* #undef HAVE_PTHREAD_CONDATTR_CREATE */
|
||||
/* #undef HAVE_PTHREAD_INIT */
|
||||
#define HAVE_PTHREAD_KEY_DELETE 1
|
||||
#define HAVE_PTHREAD_KILL 1
|
||||
#define HAVE_PTHREAD_RWLOCK_RDLOCK 1
|
||||
/* #undef HAVE_PTHREAD_SETPRIO_NP */
|
||||
#define HAVE_PTHREAD_SETSCHEDPARAM 1
|
||||
#define HAVE_PTHREAD_SIGMASK 1
|
||||
/* #undef HAVE_PTHREAD_THREADMASK */
|
||||
/* #undef HAVE_PTHREAD_YIELD_NP */
|
||||
#define HAVE_READDIR_R 1
|
||||
#define HAVE_READLINK 1
|
||||
#define HAVE_REALPATH 1
|
||||
#define HAVE_RENAME 1
|
||||
#define HAVE_SCHED_YIELD 1
|
||||
#define HAVE_SELECT 1
|
||||
/* #undef HAVE_SETFD */
|
||||
/* #undef HAVE_SETFILEPOINTER */
|
||||
#define HAVE_SIGNAL 1
|
||||
#define HAVE_SIGACTION 1
|
||||
/* #undef HAVE_SIGTHREADMASK */
|
||||
#define HAVE_SIGWAIT 1
|
||||
#define HAVE_SLEEP 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
/* #undef HAVE_SQLITE */
|
||||
#define HAVE_STPCPY 1
|
||||
#define HAVE_STRERROR 1
|
||||
/* #undef HAVE_STRLCPY */
|
||||
#define HAVE_STRNLEN 1
|
||||
#define HAVE_STRPBRK 1
|
||||
#define HAVE_STRSEP 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOK_R 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRTOULL 1
|
||||
/* #undef HAVE_TELL */
|
||||
/* #undef HAVE_THR_SETCONCURRENCY */
|
||||
/* #undef HAVE_THR_YIELD */
|
||||
#define HAVE_VASPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/*
|
||||
* types and sizes
|
||||
*/
|
||||
/* Types we may use */
|
||||
#define SIZEOF_CHAR 1
|
||||
#if defined(SIZEOF_CHAR)
|
||||
# define HAVE_CHAR 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_CHARP 8
|
||||
#if defined(SIZEOF_CHARP)
|
||||
# define HAVE_CHARP 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_SHORT 2
|
||||
#if defined(SIZEOF_SHORT)
|
||||
# define HAVE_SHORT 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_INT 4
|
||||
#if defined(SIZEOF_INT)
|
||||
# define HAVE_INT 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_LONG 8
|
||||
#if defined(SIZEOF_LONG)
|
||||
# define HAVE_LONG 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#if defined(SIZEOF_LONG_LONG)
|
||||
# define HAVE_LONG_LONG 1
|
||||
#endif
|
||||
|
||||
|
||||
#define SIZEOF_SIGSET_T 128
|
||||
#if defined(SIZEOF_SIGSET_T)
|
||||
# define HAVE_SIGSET_T 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_SIZE_T 8
|
||||
#if defined(SIZEOF_SIZE_T)
|
||||
# define HAVE_SIZE_T 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_UCHAR */
|
||||
#if defined(SIZEOF_UCHAR)
|
||||
# define HAVE_UCHAR 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_UINT 4
|
||||
#if defined(SIZEOF_UINT)
|
||||
# define HAVE_UINT 1
|
||||
#endif
|
||||
|
||||
#define SIZEOF_ULONG 8
|
||||
#if defined(SIZEOF_ULONG)
|
||||
# define HAVE_ULONG 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT8 */
|
||||
#if defined(SIZEOF_INT8)
|
||||
# define HAVE_INT8 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT8 */
|
||||
#if defined(SIZEOF_UINT8)
|
||||
# define HAVE_UINT8 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT16 */
|
||||
#if defined(SIZEOF_INT16)
|
||||
# define HAVE_INT16 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT16 */
|
||||
#if defined(SIZEOF_UINT16)
|
||||
# define HAVE_UINT16 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT32 */
|
||||
#if defined(SIZEOF_INT32)
|
||||
# define HAVE_INT32 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT32 */
|
||||
#if defined(SIZEOF_UINT32)
|
||||
# define HAVE_UINT32 1
|
||||
#endif
|
||||
/* #undef SIZEOF_U_INT32_T */
|
||||
#if defined(SIZEOF_U_INT32_T)
|
||||
# define HAVE_U_INT32_T 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_INT64 */
|
||||
#if defined(SIZEOF_INT64)
|
||||
# define HAVE_INT64 1
|
||||
#endif
|
||||
/* #undef SIZEOF_UINT64 */
|
||||
#if defined(SIZEOF_UINT64)
|
||||
# define HAVE_UINT64 1
|
||||
#endif
|
||||
|
||||
/* #undef SIZEOF_SOCKLEN_T */
|
||||
#if defined(SIZEOF_SOCKLEN_T)
|
||||
# define HAVE_SOCKLEN_T 1
|
||||
#endif
|
||||
|
||||
#define SOCKET_SIZE_TYPE socklen_t
|
||||
|
||||
#define MARIADB_DEFAULT_CHARSET "latin1"
|
||||
|
@ -1,36 +0,0 @@
|
||||
/* Copyright Abandoned 1996, 1999, 2001 MySQL AB
|
||||
This file is public domain and comes with NO WARRANTY of any kind */
|
||||
|
||||
/* Version numbers for protocol & mysqld */
|
||||
|
||||
#ifndef _mariadb_version_h_
|
||||
#define _mariadb_version_h_
|
||||
|
||||
#ifdef _CUSTOMCONFIG_
|
||||
#include <custom_conf.h>
|
||||
#else
|
||||
#define PROTOCOL_VERSION 10
|
||||
#define MARIADB_CLIENT_VERSION_STR "10.3.6"
|
||||
#define MARIADB_BASE_VERSION "mariadb-10.3"
|
||||
#define MARIADB_VERSION_ID 100306
|
||||
#define MYSQL_VERSION_ID 100306
|
||||
#define MARIADB_PORT 3306
|
||||
#define MARIADB_UNIX_ADDR "/var/run/mysqld/mysqld.sock"
|
||||
#define MYSQL_CONFIG_NAME "my"
|
||||
|
||||
#define MARIADB_PACKAGE_VERSION "3.0.6"
|
||||
#define MARIADB_PACKAGE_VERSION_ID 30006
|
||||
#define MARIADB_SYSTEM_TYPE "Linux"
|
||||
#define MARIADB_MACHINE_TYPE "x86_64"
|
||||
#define MARIADB_PLUGINDIR "lib/mariadb/plugin"
|
||||
|
||||
/* mysqld compile time options */
|
||||
#ifndef MYSQL_CHARSET
|
||||
#define MYSQL_CHARSET ""
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Source information */
|
||||
#define CC_SOURCE_REVISION "a0fd36cc5a5313414a5a2ebe9322577a29b4782a"
|
||||
|
||||
#endif /* _mariadb_version_h_ */
|
@ -1,502 +0,0 @@
|
||||
/* Copyright (C) 2010 - 2012 Sergei Golubchik and Monty Program Ab
|
||||
2015-2016 MariaDB Corporation AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not see <http://www.gnu.org/licenses>
|
||||
or write to the Free Software Foundation, Inc.,
|
||||
51 Franklin St., Fifth Floor, Boston, MA 02110, USA */
|
||||
|
||||
/**
|
||||
@file
|
||||
|
||||
Support code for the client side (libmariadb) plugins
|
||||
|
||||
Client plugins are somewhat different from server plugins, they are simpler.
|
||||
|
||||
They do not need to be installed or in any way explicitly loaded on the
|
||||
client, they are loaded automatically on demand.
|
||||
One client plugin per shared object, soname *must* match the plugin name.
|
||||
|
||||
There is no reference counting and no unloading either.
|
||||
*/
|
||||
|
||||
#if _MSC_VER
|
||||
/* Silence warnings about variable 'unused' being used. */
|
||||
#define FORCE_INIT_OF_VARS 1
|
||||
#endif
|
||||
|
||||
#include <ma_global.h>
|
||||
#include <ma_sys.h>
|
||||
#include <ma_common.h>
|
||||
#include <ma_string.h>
|
||||
#include <ma_pthread.h>
|
||||
|
||||
#include "errmsg.h"
|
||||
#include <mysql/client_plugin.h>
|
||||
|
||||
struct st_client_plugin_int {
|
||||
struct st_client_plugin_int *next;
|
||||
void *dlhandle;
|
||||
struct st_mysql_client_plugin *plugin;
|
||||
};
|
||||
|
||||
static my_bool initialized= 0;
|
||||
static MA_MEM_ROOT mem_root;
|
||||
|
||||
static uint valid_plugins[][2]= {
|
||||
{MYSQL_CLIENT_AUTHENTICATION_PLUGIN, MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION},
|
||||
{MARIADB_CLIENT_PVIO_PLUGIN, MARIADB_CLIENT_PVIO_PLUGIN_INTERFACE_VERSION},
|
||||
{MARIADB_CLIENT_TRACE_PLUGIN, MARIADB_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION},
|
||||
{MARIADB_CLIENT_CONNECTION_PLUGIN, MARIADB_CLIENT_CONNECTION_PLUGIN_INTERFACE_VERSION},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
/*
|
||||
Loaded plugins are stored in a linked list.
|
||||
The list is append-only, the elements are added to the head (like in a stack).
|
||||
The elements are added under a mutex, but the list can be read and traversed
|
||||
without any mutex because once an element is added to the list, it stays
|
||||
there. The main purpose of a mutex is to prevent two threads from
|
||||
loading the same plugin twice in parallel.
|
||||
*/
|
||||
|
||||
|
||||
struct st_client_plugin_int *plugin_list[MYSQL_CLIENT_MAX_PLUGINS + MARIADB_CLIENT_MAX_PLUGINS];
|
||||
#ifdef THREAD
|
||||
static pthread_mutex_t LOCK_load_client_plugin;
|
||||
#endif
|
||||
|
||||
extern struct st_mysql_client_plugin mysql_native_password_client_plugin;
|
||||
extern struct st_mysql_client_plugin mysql_old_password_client_plugin;
|
||||
extern struct st_mysql_client_plugin pvio_socket_client_plugin;
|
||||
extern struct st_mysql_client_plugin sha256_password_client_plugin;
|
||||
extern struct st_mysql_client_plugin caching_sha2_password_client_plugin;
|
||||
|
||||
|
||||
struct st_mysql_client_plugin *mysql_client_builtins[]=
|
||||
{
|
||||
(struct st_mysql_client_plugin *)&mysql_native_password_client_plugin,
|
||||
(struct st_mysql_client_plugin *)&mysql_old_password_client_plugin,
|
||||
(struct st_mysql_client_plugin *)&pvio_socket_client_plugin,
|
||||
(struct st_mysql_client_plugin *)&sha256_password_client_plugin,
|
||||
(struct st_mysql_client_plugin *)&caching_sha2_password_client_plugin,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
static int is_not_initialized(MYSQL *mysql, const char *name)
|
||||
{
|
||||
if (initialized)
|
||||
return 0;
|
||||
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD,
|
||||
SQLSTATE_UNKNOWN, ER(CR_AUTH_PLUGIN_CANNOT_LOAD),
|
||||
name, "not initialized");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int get_plugin_nr(uint type)
|
||||
{
|
||||
uint i= 0;
|
||||
for(; valid_plugins[i][1]; i++)
|
||||
if (valid_plugins[i][0] == type)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const char *check_plugin_version(struct st_mysql_client_plugin *plugin, unsigned int version)
|
||||
{
|
||||
if (plugin->interface_version < version ||
|
||||
(plugin->interface_version >> 8) > (version >> 8))
|
||||
return "Incompatible client plugin interface";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
finds a plugin in the list
|
||||
|
||||
@param name plugin name to search for
|
||||
@param type plugin type
|
||||
|
||||
@note this does NOT necessarily need a mutex, take care!
|
||||
|
||||
@retval a pointer to a found plugin or 0
|
||||
*/
|
||||
static struct st_mysql_client_plugin *find_plugin(const char *name, int type)
|
||||
{
|
||||
struct st_client_plugin_int *p;
|
||||
int plugin_nr= get_plugin_nr(type);
|
||||
|
||||
DBUG_ASSERT(initialized);
|
||||
if (plugin_nr == -1)
|
||||
return 0;
|
||||
|
||||
if (!name)
|
||||
return plugin_list[plugin_nr]->plugin;
|
||||
|
||||
for (p= plugin_list[plugin_nr]; p; p= p->next)
|
||||
{
|
||||
if (strcmp(p->plugin->name, name) == 0)
|
||||
return p->plugin;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
verifies the plugin and adds it to the list
|
||||
|
||||
@param mysql MYSQL structure (for error reporting)
|
||||
@param plugin plugin to install
|
||||
@param dlhandle a handle to the shared object (returned by dlopen)
|
||||
or 0 if the plugin was not dynamically loaded
|
||||
@param argc number of arguments in the 'va_list args'
|
||||
@param args arguments passed to the plugin initialization function
|
||||
|
||||
@retval a pointer to an installed plugin or 0
|
||||
*/
|
||||
|
||||
static struct st_mysql_client_plugin *
|
||||
add_plugin(MYSQL *mysql, struct st_mysql_client_plugin *plugin, void *dlhandle,
|
||||
int argc, va_list args)
|
||||
{
|
||||
const char *errmsg;
|
||||
struct st_client_plugin_int plugin_int, *p;
|
||||
char errbuf[1024];
|
||||
int plugin_nr;
|
||||
|
||||
DBUG_ASSERT(initialized);
|
||||
|
||||
plugin_int.plugin= plugin;
|
||||
plugin_int.dlhandle= dlhandle;
|
||||
|
||||
if ((plugin_nr= get_plugin_nr(plugin->type)) == -1)
|
||||
{
|
||||
errmsg= "Unknown client plugin type";
|
||||
goto err1;
|
||||
}
|
||||
if ((errmsg= check_plugin_version(plugin, valid_plugins[plugin_nr][1])))
|
||||
goto err1;
|
||||
|
||||
/* Call the plugin initialization function, if any */
|
||||
if (plugin->init && plugin->init(errbuf, sizeof(errbuf), argc, args))
|
||||
{
|
||||
errmsg= errbuf;
|
||||
goto err1;
|
||||
}
|
||||
|
||||
p= (struct st_client_plugin_int *)
|
||||
ma_memdup_root(&mem_root, (char *)&plugin_int, sizeof(plugin_int));
|
||||
|
||||
if (!p)
|
||||
{
|
||||
errmsg= "Out of memory";
|
||||
goto err2;
|
||||
}
|
||||
|
||||
#ifdef THREAD
|
||||
safe_mutex_assert_owner(&LOCK_load_client_plugin);
|
||||
#endif
|
||||
|
||||
p->next= plugin_list[plugin_nr];
|
||||
plugin_list[plugin_nr]= p;
|
||||
|
||||
return plugin;
|
||||
|
||||
err2:
|
||||
if (plugin->deinit)
|
||||
plugin->deinit();
|
||||
err1:
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD, SQLSTATE_UNKNOWN,
|
||||
ER(CR_AUTH_PLUGIN_CANNOT_LOAD), plugin->name, errmsg);
|
||||
if (dlhandle)
|
||||
(void)dlclose(dlhandle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Loads plugins which are specified in the environment variable
|
||||
LIBMYSQL_PLUGINS.
|
||||
|
||||
Multiple plugins must be separated by semicolon. This function doesn't
|
||||
return or log an error.
|
||||
|
||||
The function is be called by mysql_client_plugin_init
|
||||
|
||||
@todo
|
||||
Support extended syntax, passing parameters to plugins, for example
|
||||
LIBMYSQL_PLUGINS="plugin1(param1,param2);plugin2;..."
|
||||
or
|
||||
LIBMYSQL_PLUGINS="plugin1=int:param1,str:param2;plugin2;..."
|
||||
*/
|
||||
|
||||
static void load_env_plugins(MYSQL *mysql)
|
||||
{
|
||||
char *plugs, *free_env, *s= getenv("LIBMYSQL_PLUGINS");
|
||||
|
||||
if (ma_check_env_str(s))
|
||||
return;
|
||||
|
||||
free_env= strdup(s);
|
||||
plugs= s= free_env;
|
||||
|
||||
do {
|
||||
if ((s= strchr(plugs, ';')))
|
||||
*s= '\0';
|
||||
mysql_load_plugin(mysql, plugs, -1, 0);
|
||||
plugs= s + 1;
|
||||
} while (s);
|
||||
|
||||
free(free_env);
|
||||
}
|
||||
|
||||
/********** extern functions to be used by libmariadb *********************/
|
||||
|
||||
/**
|
||||
Initializes the client plugin layer.
|
||||
|
||||
This function must be called before any other client plugin function.
|
||||
|
||||
@retval 0 successful
|
||||
@retval != 0 error occurred
|
||||
*/
|
||||
|
||||
int mysql_client_plugin_init()
|
||||
{
|
||||
MYSQL mysql;
|
||||
struct st_mysql_client_plugin **builtin;
|
||||
va_list unused;
|
||||
LINT_INIT_STRUCT(unused);
|
||||
|
||||
if (initialized)
|
||||
return 0;
|
||||
|
||||
memset(&mysql, 0, sizeof(mysql)); /* dummy mysql for set_mysql_extended_error */
|
||||
|
||||
pthread_mutex_init(&LOCK_load_client_plugin, MY_MUTEX_INIT_SLOW);
|
||||
ma_init_alloc_root(&mem_root, 128, 128);
|
||||
|
||||
memset(&plugin_list, 0, sizeof(plugin_list));
|
||||
|
||||
initialized= 1;
|
||||
|
||||
pthread_mutex_lock(&LOCK_load_client_plugin);
|
||||
for (builtin= mysql_client_builtins; *builtin; builtin++)
|
||||
add_plugin(&mysql, *builtin, 0, 0, unused);
|
||||
|
||||
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
||||
|
||||
load_env_plugins(&mysql);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Deinitializes the client plugin layer.
|
||||
|
||||
Unloades all client plugins and frees any associated resources.
|
||||
*/
|
||||
|
||||
void mysql_client_plugin_deinit()
|
||||
{
|
||||
int i;
|
||||
struct st_client_plugin_int *p;
|
||||
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
for (i=0; i < MYSQL_CLIENT_MAX_PLUGINS; i++)
|
||||
for (p= plugin_list[i]; p; p= p->next)
|
||||
{
|
||||
if (p->plugin->deinit)
|
||||
p->plugin->deinit();
|
||||
if (p->dlhandle)
|
||||
(void)dlclose(p->dlhandle);
|
||||
}
|
||||
|
||||
memset(&plugin_list, 0, sizeof(plugin_list));
|
||||
initialized= 0;
|
||||
ma_free_root(&mem_root, MYF(0));
|
||||
pthread_mutex_destroy(&LOCK_load_client_plugin);
|
||||
}
|
||||
|
||||
/************* public facing functions, for client consumption *********/
|
||||
|
||||
/* see <mysql/client_plugin.h> for a full description */
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
mysql_client_register_plugin(MYSQL *mysql,
|
||||
struct st_mysql_client_plugin *plugin)
|
||||
{
|
||||
va_list unused;
|
||||
LINT_INIT_STRUCT(unused);
|
||||
|
||||
if (is_not_initialized(mysql, plugin->name))
|
||||
return NULL;
|
||||
|
||||
pthread_mutex_lock(&LOCK_load_client_plugin);
|
||||
|
||||
/* make sure the plugin wasn't loaded meanwhile */
|
||||
if (find_plugin(plugin->name, plugin->type))
|
||||
{
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD,
|
||||
SQLSTATE_UNKNOWN, ER(CR_AUTH_PLUGIN_CANNOT_LOAD),
|
||||
plugin->name, "it is already loaded");
|
||||
plugin= NULL;
|
||||
}
|
||||
else
|
||||
plugin= add_plugin(mysql, plugin, 0, 0, unused);
|
||||
|
||||
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
||||
/* see <mysql/client_plugin.h> for a full description */
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
|
||||
int argc, va_list args)
|
||||
{
|
||||
const char *errmsg;
|
||||
#ifdef _WIN32
|
||||
char errbuf[1024];
|
||||
#endif
|
||||
char dlpath[FN_REFLEN+1];
|
||||
void *sym, *dlhandle = NULL;
|
||||
struct st_mysql_client_plugin *plugin;
|
||||
char *env_plugin_dir= getenv("MARIADB_PLUGIN_DIR");
|
||||
|
||||
CLEAR_CLIENT_ERROR(mysql);
|
||||
if (is_not_initialized(mysql, name))
|
||||
return NULL;
|
||||
|
||||
pthread_mutex_lock(&LOCK_load_client_plugin);
|
||||
|
||||
/* make sure the plugin wasn't loaded meanwhile */
|
||||
if (type >= 0 && find_plugin(name, type))
|
||||
{
|
||||
errmsg= "it is already loaded";
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Compile dll path */
|
||||
snprintf(dlpath, sizeof(dlpath) - 1, "%s/%s%s",
|
||||
mysql->options.extension && mysql->options.extension->plugin_dir ?
|
||||
mysql->options.extension->plugin_dir : (env_plugin_dir) ? env_plugin_dir :
|
||||
MARIADB_PLUGINDIR, name, SO_EXT);
|
||||
|
||||
/* Open new dll handle */
|
||||
if (!(dlhandle= dlopen((const char *)dlpath, RTLD_NOW)))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char winmsg[255];
|
||||
size_t len;
|
||||
winmsg[0] = 0;
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
winmsg, 255, NULL);
|
||||
len= strlen(winmsg);
|
||||
while (len > 0 && (winmsg[len - 1] == '\n' || winmsg[len - 1] == '\r'))
|
||||
len--;
|
||||
if (len)
|
||||
winmsg[len] = 0;
|
||||
snprintf(errbuf, sizeof(errbuf), "%s Library path is '%s'", winmsg, dlpath);
|
||||
errmsg= errbuf;
|
||||
#else
|
||||
errmsg= dlerror();
|
||||
#endif
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
if (!(sym= dlsym(dlhandle, plugin_declarations_sym)))
|
||||
{
|
||||
errmsg= "not a plugin";
|
||||
(void)dlclose(dlhandle);
|
||||
goto err;
|
||||
}
|
||||
|
||||
plugin= (struct st_mysql_client_plugin*)sym;
|
||||
|
||||
if (type >=0 && type != plugin->type)
|
||||
{
|
||||
errmsg= "type mismatch";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (strcmp(name, plugin->name))
|
||||
{
|
||||
errmsg= "name mismatch";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (type < 0 && find_plugin(name, plugin->type))
|
||||
{
|
||||
errmsg= "it is already loaded";
|
||||
goto err;
|
||||
}
|
||||
|
||||
plugin= add_plugin(mysql, plugin, dlhandle, argc, args);
|
||||
|
||||
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
||||
|
||||
return plugin;
|
||||
|
||||
err:
|
||||
if (dlhandle)
|
||||
dlclose(dlhandle);
|
||||
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD, SQLSTATE_UNKNOWN,
|
||||
ER(CR_AUTH_PLUGIN_CANNOT_LOAD), name, errmsg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* see <mysql/client_plugin.h> for a full description */
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
mysql_load_plugin(MYSQL *mysql, const char *name, int type, int argc, ...)
|
||||
{
|
||||
struct st_mysql_client_plugin *p;
|
||||
va_list args;
|
||||
va_start(args, argc);
|
||||
p= mysql_load_plugin_v(mysql, name, type, argc, args);
|
||||
va_end(args);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* see <mysql/client_plugin.h> for a full description */
|
||||
struct st_mysql_client_plugin * STDCALL
|
||||
mysql_client_find_plugin(MYSQL *mysql, const char *name, int type)
|
||||
{
|
||||
struct st_mysql_client_plugin *p;
|
||||
int plugin_nr= get_plugin_nr(type);
|
||||
|
||||
if (is_not_initialized(mysql, name))
|
||||
return NULL;
|
||||
|
||||
if (plugin_nr == -1)
|
||||
{
|
||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD, SQLSTATE_UNKNOWN,
|
||||
ER(CR_AUTH_PLUGIN_CANNOT_LOAD), name, "invalid type");
|
||||
}
|
||||
|
||||
if ((p= find_plugin(name, type)))
|
||||
return p;
|
||||
|
||||
/* not found, load it */
|
||||
return mysql_load_plugin(mysql, name, type, 0);
|
||||
}
|
||||
|
@ -29,7 +29,9 @@ add_library (mysqlxx
|
||||
target_include_directories (mysqlxx PUBLIC include)
|
||||
|
||||
if (USE_INTERNAL_MYSQL_LIBRARY)
|
||||
|
||||
target_include_directories (mysqlxx PUBLIC ${ClickHouse_SOURCE_DIR}/contrib/mariadb-connector-c/include)
|
||||
target_include_directories (mysqlxx PUBLIC ${ClickHouse_BINARY_DIR}/contrib/mariadb-connector-c/include)
|
||||
target_include_directories (mysqlxx PUBLIC ${ClickHouse_SOURCE_DIR}/contrib/mariadb-connector-c-cmake/common/include)
|
||||
else ()
|
||||
set(PLATFORM_LIBRARIES ${CMAKE_DL_LIBS})
|
||||
|
||||
|
@ -6,14 +6,14 @@ if(ENABLE_MYSQL)
|
||||
option(USE_INTERNAL_MYSQL_LIBRARY "Set to FALSE to use system mysqlclient library instead of bundled" OFF)
|
||||
endif()
|
||||
|
||||
if(USE_INTERNAL_MYSQL_LIBRARY AND NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/mariadb-connector-c/README.md")
|
||||
if(USE_INTERNAL_MYSQL_LIBRARY AND NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/mariadb-connector-c/README")
|
||||
message(WARNING "submodule contrib/mariadb-connector-c is missing. to fix try run: \n git submodule update --init --recursive")
|
||||
set(USE_INTERNAL_MYSQL_LIBRARY 0)
|
||||
endif()
|
||||
|
||||
|
||||
if (USE_INTERNAL_MYSQL_LIBRARY)
|
||||
set (MYSQLCLIENT_LIBRARIES mysqlclient)
|
||||
set (MYSQLCLIENT_LIBRARIES mariadbclient)
|
||||
set (USE_MYSQL 1)
|
||||
set (MYSQLXX_LIBRARY mysqlxx)
|
||||
else ()
|
||||
|
Loading…
Reference in New Issue
Block a user