diff options
Diffstat (limited to 'include')
40 files changed, 321 insertions, 745 deletions
diff --git a/include/decimal.h b/include/decimal.h index cab18f99348..02725fe0567 100644 --- a/include/decimal.h +++ b/include/decimal.h @@ -43,7 +43,8 @@ typedef struct st_decimal_t { int internal_str2dec(const char *from, decimal_t *to, char **end, my_bool fixed); int decimal2string(const decimal_t *from, char *to, int *to_len, - int fixed_precision, int fixed_decimals, + decimal_digits_t fixed_precision, + decimal_digits_t fixed_decimals, char filler); int decimal2ulonglong(const decimal_t *from, ulonglong *to); int ulonglong2decimal(ulonglong from, decimal_t *to); @@ -51,16 +52,18 @@ int decimal2longlong(const decimal_t *from, longlong *to); int longlong2decimal(longlong from, decimal_t *to); int decimal2double(const decimal_t *from, double *to); int double2decimal(double from, decimal_t *to); -int decimal_actual_fraction(const decimal_t *from); -int decimal2bin(const decimal_t *from, uchar *to, int precision, int scale); -int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale); - -int decimal_size(int precision, int scale); -int decimal_bin_size(int precision, int scale); -int decimal_result_size(decimal_t *from1, decimal_t *from2, char op, - int param); - -int decimal_intg(const decimal_t *from); +decimal_digits_t decimal_actual_fraction(const decimal_t *from); +int decimal2bin(const decimal_t *from, uchar *to, decimal_digits_t precision, + decimal_digits_t scale); +int bin2decimal(const uchar *from, decimal_t *to, decimal_digits_t precision, + decimal_digits_t scale); + +uint decimal_size(decimal_digits_t precision, decimal_digits_t scale); +uint decimal_bin_size(decimal_digits_t precision, decimal_digits_t scale); +uint decimal_result_size(decimal_t *from1, decimal_t *from2, char op, + int param); + +decimal_digits_t decimal_intg(const decimal_t *from); int decimal_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to); int decimal_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to); int decimal_cmp(const decimal_t *from1, const decimal_t *from2); @@ -71,7 +74,8 @@ int decimal_mod(const decimal_t *from1, const decimal_t *from2, decimal_t *to); int decimal_round(const decimal_t *from, decimal_t *to, int new_scale, decimal_round_mode mode); int decimal_is_zero(const decimal_t *from); -void max_decimal(int precision, int frac, decimal_t *to); +void max_decimal(decimal_digits_t precision, decimal_digits_t frac, + decimal_t *to); #define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0) #define string2decimal_fixed(A,B,C) internal_str2dec((A), (B), (C), 1) diff --git a/include/handler_ername.h b/include/handler_ername.h index c9d09717a14..026d7c8bb8c 100644 --- a/include/handler_ername.h +++ b/include/handler_ername.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013 SkySQL Ab +/* Copyright (c) 2013, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -74,7 +74,6 @@ { "HA_ERR_INDEX_COL_TOO_LONG", HA_ERR_INDEX_COL_TOO_LONG, "" }, { "HA_ERR_INDEX_CORRUPT", HA_ERR_INDEX_CORRUPT, "" }, { "HA_ERR_UNDO_REC_TOO_BIG", HA_ERR_UNDO_REC_TOO_BIG, "" }, -{ "HA_ERR_TABLE_IN_FK_CHECK", HA_ERR_TABLE_IN_FK_CHECK, "" }, { "HA_ERR_ROW_NOT_VISIBLE", HA_ERR_ROW_NOT_VISIBLE, "" }, { "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" }, { "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" }, diff --git a/include/ilist.h b/include/ilist.h index 92812ba8f5d..45c0bbf7d2c 100644 --- a/include/ilist.h +++ b/include/ilist.h @@ -75,8 +75,10 @@ public: typedef T *pointer; typedef T &reference; - Iterator(ListNode *node) noexcept : node_(node) - { DBUG_ASSERT(node_ != nullptr); } + explicit Iterator(ListNode *node) noexcept : node_(node) + { + DBUG_ASSERT(node_ != nullptr); + } Iterator &operator++() noexcept { @@ -193,7 +195,7 @@ public: curr->next= nullptr; #endif - return next; + return Iterator(next); } void push_back(reference value) noexcept { insert(end(), value); } diff --git a/include/json_lib.h b/include/json_lib.h index bb649928eaa..e570e2a9d17 100644 --- a/include/json_lib.h +++ b/include/json_lib.h @@ -222,6 +222,7 @@ typedef struct st_json_engine_t int stack[JSON_DEPTH_LIMIT]; /* Keeps the stack of nested JSON structures. */ int stack_p; /* The 'stack' pointer. */ + volatile uchar *killed_ptr; } json_engine_t; diff --git a/include/m_ctype.h b/include/m_ctype.h index 32cede0baaf..4a231caeda9 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -22,6 +22,7 @@ #define _m_ctype_h #include <my_attribute.h> +#include <m_string.h> enum loglevel { ERROR_LEVEL= 0, @@ -79,6 +80,7 @@ typedef const struct my_collation_handler_st MY_COLLATION_HANDLER; typedef const struct unicase_info_st MY_UNICASE_INFO; typedef const struct uni_ctype_st MY_UNI_CTYPE; typedef const struct my_uni_idx_st MY_UNI_IDX; +typedef uint16 decimal_digits_t; typedef struct unicase_info_char_st { @@ -429,6 +431,12 @@ struct my_collation_handler_st void (*hash_sort)(CHARSET_INFO *cs, const uchar *key, size_t len, ulong *nr1, ulong *nr2); my_bool (*propagate)(CHARSET_INFO *cs, const uchar *str, size_t len); + /* + Make minimum and maximum strings for the collation. + Put not more than "nchars" characters. + */ + size_t (*min_str)(CHARSET_INFO *cs, uchar *dst, size_t dstlen, size_t nchars); + size_t (*max_str)(CHARSET_INFO *cs, uchar *dst, size_t dstlen, size_t nchars); }; extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler; @@ -622,8 +630,8 @@ struct charset_info_st uint primary_number; uint binary_number; uint state; - const char *csname; - const char *name; + LEX_CSTRING cs_name; + LEX_CSTRING coll_name; const char *comment; const char *tailoring; const uchar *m_ctype; @@ -641,8 +649,23 @@ struct charset_info_st uchar casedn_multiply; uint mbminlen; uint mbmaxlen; + /* + min_sort_char and max_sort_char represent the minimum + and the maximum character in the collation respectively. + + For Unicode collations, these numbers are Unicode code points. + For non-Unicode collations these numbers are native character codes. + For example, in all 8bit collations these numbers are + in the range 0x00..0xFF. + + min_sort_char and max_sort_char normally should not be used directly. + They are used internally in the following virtual functions: + - MY_COLLATION_HANDLER::like_range() + - MY_COLLATION_HANDLER::min_str() + - MY_COLLATION_HANDLER::max_str() + */ my_wc_t min_sort_char; - my_wc_t max_sort_char; /* For LIKE optimization */ + my_wc_t max_sort_char; uchar pad_char; my_bool escape_with_backslash_is_dangerous; uchar levels_for_order; @@ -904,6 +927,16 @@ struct charset_info_st return (coll->propagate)(this, str, len); } + size_t min_str(uchar *dst, size_t dstlen, size_t nchars) const + { + return (coll->min_str)(this, dst, dstlen, nchars); + } + + size_t max_str(uchar *dst, size_t dstlen, size_t nchars) const + { + return (coll->max_str)(this, dst, dstlen, nchars); + } + #endif /* __cplusplus */ }; @@ -1162,7 +1195,7 @@ extern struct charset_info_st my_charset_big5_bin; extern struct charset_info_st my_charset_big5_chinese_ci; extern struct charset_info_st my_charset_big5_nopad_bin; extern struct charset_info_st my_charset_big5_chinese_nopad_ci; -extern struct charset_info_st my_charset_cp1250_czech_ci; +extern struct charset_info_st my_charset_cp1250_czech_cs; extern struct charset_info_st my_charset_cp932_bin; extern struct charset_info_st my_charset_cp932_japanese_ci; extern struct charset_info_st my_charset_cp932_nopad_bin; @@ -1186,7 +1219,7 @@ extern struct charset_info_st my_charset_gbk_chinese_nopad_ci; extern struct charset_info_st my_charset_latin1_bin; extern struct charset_info_st my_charset_latin1_nopad_bin; extern struct charset_info_st my_charset_latin1_german2_ci; -extern struct charset_info_st my_charset_latin2_czech_ci; +extern struct charset_info_st my_charset_latin2_czech_cs; extern struct charset_info_st my_charset_sjis_bin; extern struct charset_info_st my_charset_sjis_japanese_ci; extern struct charset_info_st my_charset_sjis_nopad_bin; @@ -1236,7 +1269,7 @@ extern struct charset_info_st my_charset_utf8mb4_general_nopad_ci; extern struct charset_info_st my_charset_utf8mb4_unicode_ci; extern struct charset_info_st my_charset_utf8mb4_unicode_nopad_ci; -#define MY_UTF8MB3 "utf8" +#define MY_UTF8MB3 "utf8mb3" #define MY_UTF8MB4 "utf8mb4" my_bool my_cs_have_contractions(CHARSET_INFO *cs); diff --git a/include/m_string.h b/include/m_string.h index e4c11d24c0b..7130a41438f 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2019, MariaDB Corporation. + Copyright (c) 2019, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -66,7 +66,7 @@ extern "C" { #endif #ifdef DBUG_OFF -#if defined(HAVE_STPCPY) && MY_GNUC_PREREQ(3, 4) && !defined(__INTEL_COMPILER) +#if defined(HAVE_STPCPY) && defined(__GNUC__) && !defined(__INTEL_COMPILER) #define strmov(A,B) __builtin_stpcpy((A),(B)) #elif defined(HAVE_STPCPY) #define strmov(A,B) stpcpy((A),(B)) diff --git a/include/my_atomic_wrapper.h b/include/my_atomic_wrapper.h index c5820b4f5b6..e45aba9d22b 100644 --- a/include/my_atomic_wrapper.h +++ b/include/my_atomic_wrapper.h @@ -48,6 +48,7 @@ public: operator Type() const { return m.load(); } Type operator=(const Type i) { store(i); return i; } Type operator=(const Atomic_relaxed<Type> &rhs) { return *this= Type{rhs}; } + Type operator+=(const Type i) { return fetch_add(i); } Type fetch_add(const Type i, std::memory_order o= std::memory_order_relaxed) { return m.fetch_add(i, o); } Type fetch_sub(const Type i, std::memory_order o= std::memory_order_relaxed) diff --git a/include/my_base.h b/include/my_base.h index c29e9de6e0d..f96e569cae4 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -217,7 +217,9 @@ enum ha_extra_function { /** Start writing rows during ALTER TABLE...ALGORITHM=COPY. */ HA_EXTRA_BEGIN_ALTER_COPY, /** Finish writing rows during ALTER TABLE...ALGORITHM=COPY. */ - HA_EXTRA_END_ALTER_COPY + HA_EXTRA_END_ALTER_COPY, + /** IGNORE is being used for the insert statement */ + HA_EXTRA_IGNORE_INSERT }; /* Compatible option, to be deleted in 6.0 */ @@ -511,7 +513,7 @@ enum ha_base_keytype { #define HA_ERR_INDEX_CORRUPT 180 /* Index corrupted */ #define HA_ERR_UNDO_REC_TOO_BIG 181 /* Undo log record too big */ #define HA_FTS_INVALID_DOCID 182 /* Invalid InnoDB Doc ID */ -#define HA_ERR_TABLE_IN_FK_CHECK 183 /* Table being used in foreign key check */ +/* #define HA_ERR_TABLE_IN_FK_CHECK 183 */ /* Table being used in foreign key check */ #define HA_ERR_TABLESPACE_EXISTS 184 /* The tablespace existed in storage engine */ #define HA_ERR_TOO_MANY_FIELDS 185 /* Table has too many columns */ #define HA_ERR_ROW_IN_WRONG_PARTITION 186 /* Row in wrong partition */ diff --git a/include/my_byteorder.h b/include/my_byteorder.h index abdf19a3632..a70330ca47c 100644 --- a/include/my_byteorder.h +++ b/include/my_byteorder.h @@ -31,10 +31,10 @@ format (low byte first). There are 'korr' (assume 'corrector') variants for integer types, but 'get' (assume 'getter') for floating point types. */ -#if (defined(__i386__) || defined(_WIN32)) && !defined(WITH_UBSAN) +#if (defined(__i386__) || defined(_M_IX86)) && !defined(WITH_UBSAN) #define MY_BYTE_ORDER_ARCH_OPTIMIZED #include "byte_order_generic_x86.h" -#elif defined(__x86_64__) && !defined(WITH_UBSAN) +#elif (defined(__x86_64__) || defined (_M_X64)) && !defined(WITH_UBSAN) #include "byte_order_generic_x86_64.h" #else #include "byte_order_generic.h" diff --git a/include/my_context.h b/include/my_context.h deleted file mode 100644 index 45d2a7d7ffa..00000000000 --- a/include/my_context.h +++ /dev/null @@ -1,235 +0,0 @@ -/* - Copyright 2011 Kristian Nielsen and Monty Program Ab - - This file is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Simple API for spawning a co-routine, to be used for async libmysqlclient. - - Idea is that by implementing this interface using whatever facilities are - available for given platform, we can use the same code for the generic - libmysqlclient-async code. - - (This particular implementation uses Posix ucontext swapcontext().) -*/ - -#ifdef __WIN__ -#define MY_CONTEXT_USE_WIN32_FIBERS 1 -#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__x86_64__) && !defined(__ILP32__) -#define MY_CONTEXT_USE_X86_64_GCC_ASM -#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__) -#define MY_CONTEXT_USE_I386_GCC_ASM -#elif defined(HAVE_UCONTEXT_H) -#define MY_CONTEXT_USE_UCONTEXT -#else -#define MY_CONTEXT_DISABLE -#endif - -#ifdef MY_CONTEXT_USE_WIN32_FIBERS -struct my_context { - void (*user_func)(void *); - void *user_arg; - void *app_fiber; - void *lib_fiber; - int return_value; -#ifndef DBUG_OFF - void *dbug_state; -#endif -}; -#endif - - -#ifdef MY_CONTEXT_USE_UCONTEXT -#if defined(__APPLE__) && !defined(_XOPEN_SOURCE) -#define _XOPEN_SOURCE -#endif -#include <ucontext.h> - -struct my_context { - void (*user_func)(void *); - void *user_data; - void *stack; - size_t stack_size; - ucontext_t base_context; - ucontext_t spawned_context; - int active; -#ifdef HAVE_VALGRIND_MEMCHECK_H - unsigned int valgrind_stack_id; -#endif -#ifndef DBUG_OFF - void *dbug_state; -#endif -}; -#endif - - -#ifdef MY_CONTEXT_USE_X86_64_GCC_ASM -#include <stdint.h> - -struct my_context { - uint64_t save[9]; - void *stack_top; - void *stack_bot; -#ifdef HAVE_VALGRIND_MEMCHECK_H - unsigned int valgrind_stack_id; -#endif -#ifndef DBUG_OFF - void *dbug_state; -#endif -}; -#endif - - -#ifdef MY_CONTEXT_USE_I386_GCC_ASM -#include <stdint.h> - -struct my_context { - uint64_t save[7]; - void *stack_top; - void *stack_bot; -#ifdef HAVE_VALGRIND_MEMCHECK_H - unsigned int valgrind_stack_id; -#endif -#ifndef DBUG_OFF - void *dbug_state; -#endif -}; -#endif - - -#ifdef MY_CONTEXT_DISABLE -struct my_context { - int dummy; -}; -#endif - - -/* - Initialize an asynchroneous context object. - Returns 0 on success, non-zero on failure. -*/ -extern int my_context_init(struct my_context *c, size_t stack_size); - -/* Free an asynchroneous context object, deallocating any resources used. */ -extern void my_context_destroy(struct my_context *c); - -/* - Spawn an asynchroneous context. The context will run the supplied user - function, passing the supplied user data pointer. - - The context must have been initialised with my_context_init() prior to - this call. - - The user function may call my_context_yield(), which will cause this - function to return 1. Then later my_context_continue() may be called, which - will resume the asynchroneous context by returning from the previous - my_context_yield() call. - - When the user function returns, this function returns 0. - - In case of error, -1 is returned. -*/ -extern int my_context_spawn(struct my_context *c, void (*f)(void *), void *d); - -/* - Suspend an asynchroneous context started with my_context_spawn. - - When my_context_yield() is called, execution immediately returns from the - last my_context_spawn() or my_context_continue() call. Then when later - my_context_continue() is called, execution resumes by returning from this - my_context_yield() call. - - Returns 0 if ok, -1 in case of error. -*/ -extern int my_context_yield(struct my_context *c); - -/* - Resume an asynchroneous context. The context was spawned by - my_context_spawn(), and later suspended inside my_context_yield(). - - The asynchroneous context may be repeatedly suspended with - my_context_yield() and resumed with my_context_continue(). - - Each time it is suspended, this function returns 1. When the originally - spawned user function returns, this function returns 0. - - In case of error, -1 is returned. -*/ -extern int my_context_continue(struct my_context *c); - - -struct mysql_async_context { - /* - This is set to the value that should be returned from foo_start() or - foo_cont() when a call is suspended. - */ - unsigned int events_to_wait_for; - /* - It is also set to the event(s) that triggered when a suspended call is - resumed, eg. whether we woke up due to connection completed or timeout - in mysql_real_connect_cont(). - */ - unsigned int events_occurred; - /* - This is set to the result of the whole asynchronous operation when it - completes. It uses a union, as different calls have different return - types. - */ - union { - void *r_ptr; - const void *r_const_ptr; - int r_int; - my_bool r_my_bool; - } ret_result; - /* - The timeout value (in millisecods), for suspended calls that need to wake - up on a timeout (eg. mysql_real_connect_start(). - */ - unsigned int timeout_value; - /* - This flag is set when we are executing inside some asynchronous call - foo_start() or foo_cont(). It is used to decide whether to use the - synchronous or asynchronous version of calls that may block such as - recv(). - - Note that this flag is not set when a call is suspended, eg. after - returning from foo_start() and before re-entering foo_cont(). - */ - my_bool active; - /* - This flag is set when an asynchronous operation is in progress, but - suspended. Ie. it is set when foo_start() or foo_cont() returns because - the operation needs to block, suspending the operation. - - It is used to give an error (rather than crash) if the application - attempts to call some foo_cont() method when no suspended operation foo is - in progress. - */ - my_bool suspended; - /* - If non-NULL, this is a pointer to a callback hook that will be invoked with - the user data argument just before the context is suspended, and just after - it is resumed. - */ - void (*suspend_resume_hook)(my_bool suspend, void *user_data); - void *suspend_resume_hook_user_data; - /* - This is used to save the execution contexts so that we can suspend an - operation and switch back to the application context, to resume the - suspended context later when the application re-invokes us with - foo_cont(). - */ - struct my_context async_context; -}; diff --git a/include/my_cpu.h b/include/my_cpu.h index 05fa937c98d..e536ff285f9 100644 --- a/include/my_cpu.h +++ b/include/my_cpu.h @@ -84,15 +84,7 @@ static inline void MY_RELAX_CPU(void) __ppc_get_timebase(); #elif defined __GNUC__ && (defined __arm__ || defined __aarch64__) /* Mainly, prevent the compiler from optimizing away delay loops */ -#ifdef _aarch64_ - __asm__ __volatile__ ("isb":::"memory"); -#else - /* - some older 32 bits processor doesn't support isb but as per - arm-v8 reference manual all armv8 processor should support isb. - */ __asm__ __volatile__ ("":::"memory"); -#endif #else int32 var, oldval = 0; my_atomic_cas32_strong_explicit(&var, &oldval, 1, MY_MEMORY_ORDER_RELAXED, diff --git a/include/my_dbug.h b/include/my_dbug.h index fa5b4c126d1..e25bfcf28a7 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -17,9 +17,9 @@ #ifndef _my_dbug_h #define _my_dbug_h -#ifndef __WIN__ +#ifndef _WIN32 #include <signal.h> -#endif /* not __WIN__ */ +#endif #ifdef __cplusplus extern "C" { @@ -134,7 +134,7 @@ extern int (*dbug_sanity)(void); #define DBUG_FREE_CODE_STATE(arg) dbug_free_code_state(arg) #undef DBUG_ASSERT_AS_PRINTF -#ifndef __WIN__ +#ifndef _WIN32 #define DBUG_ABORT() (_db_flush_(), abort()) #else /* @@ -156,12 +156,12 @@ extern int (*dbug_sanity)(void); An alternative would be to use _exit(EXIT_FAILURE), but then valgrind would report lots of memory leaks. */ -#ifdef __WIN__ +#ifdef _WIN32 #define DBUG_SUICIDE() DBUG_ABORT() #else extern void _db_suicide_(void); #define DBUG_SUICIDE() (_db_flush_(), _db_suicide_()) -#endif /* __WIN__ */ +#endif /* _WIN32 */ #else /* No debugger */ diff --git a/include/my_global.h b/include/my_global.h index 1d7c91f37b8..224909116dd 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -20,9 +20,13 @@ #ifndef MY_GLOBAL_INCLUDED #define MY_GLOBAL_INCLUDED -/* Client library users on Windows need this macro defined here. */ -#if !defined(__WIN__) && defined(_WIN32) -#define __WIN__ +/* + MDEV-25602 Deprecate __WIN__ symbol. +*/ +#if defined (_MSC_VER) && !defined(__clang__) +#pragma deprecated("__WIN__") +#elif defined (__GNUC__) +#pragma GCC poison __WIN__ #endif /* @@ -43,7 +47,7 @@ #undef _WIN #undef _WIN32 #undef _WIN64 -#undef __WIN__ +#undef _WIN32 #undef __WIN32__ #define HAVE_ERRNO_AS_DEFINE #define _POSIX_MONOTONIC_CLOCK @@ -79,7 +83,7 @@ #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ /* Make it easier to add conditional code in _expressions_ */ -#ifdef __WIN__ +#ifdef _WIN32 #define IF_WIN(A,B) A #else #define IF_WIN(A,B) B @@ -240,7 +244,7 @@ #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #ifndef _POSIX_PTHREAD_SEMANTICS #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ #endif @@ -261,7 +265,7 @@ C_MODE_END #if !defined(SCO) && !defined(_REENTRANT) #define _REENTRANT 1 /* Threads requires reentrant code */ #endif -#endif /* !defined(__WIN__) */ +#endif /* !defined(_WIN32) */ /* gcc/egcs issues */ @@ -588,12 +592,12 @@ typedef SOCKET_SIZE_TYPE size_socket; #endif /* additional file share flags for win32 */ -#ifdef __WIN__ +#ifdef _WIN32 #define _SH_DENYRWD 0x110 /* deny read/write mode & delete */ #define _SH_DENYWRD 0x120 /* deny write mode & delete */ #define _SH_DENYRDD 0x130 /* deny read mode & delete */ #define _SH_DENYDEL 0x140 /* deny delete only */ -#endif /* __WIN__ */ +#endif /* _WIN32 */ /* General constants */ @@ -693,7 +697,7 @@ typedef SOCKET_SIZE_TYPE size_socket; /* Some defines of functions for portability */ #undef remove /* Crashes MySQL on SCO 5.0.0 */ -#ifndef __WIN__ +#ifndef _WIN32 #define closesocket(A) close(A) #endif @@ -915,7 +919,7 @@ typedef ulonglong uint64; #if defined(NO_CLIENT_LONG_LONG) typedef unsigned long my_ulonglong; -#elif defined (__WIN__) +#elif defined (_WIN32) typedef unsigned __int64 my_ulonglong; #else typedef unsigned long long my_ulonglong; @@ -955,7 +959,7 @@ typedef ulonglong table_map; /* Used for table bits in join */ typedef const struct charset_info_st CHARSET_INFO; typedef struct st_mysql_lex_string LEX_STRING; -#if defined(__WIN__) +#if defined(_WIN32) #define socket_errno WSAGetLastError() #define SOCKET_EINTR WSAEINTR #define SOCKET_ETIMEDOUT WSAETIMEDOUT @@ -1049,7 +1053,9 @@ typedef ulong myf; /* Type of MyFlags in my_funcs */ static inline char *dlerror(void) { static char win_errormsg[2048]; - FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, + FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM + | FORMAT_MESSAGE_IGNORE_INSERTS + | FORMAT_MESSAGE_MAX_WIDTH_MASK, 0, GetLastError(), 0, win_errormsg, 2048, NULL); return win_errormsg; } diff --git a/include/my_net.h b/include/my_net.h index 9a4f2f44b49..f56ae09ad8c 100644 --- a/include/my_net.h +++ b/include/my_net.h @@ -43,7 +43,7 @@ C_MODE_START #include <sys/ioctl.h> #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #include <netinet/in_systm.h> #include <netinet/in.h> #include <netinet/ip.h> @@ -52,7 +52,7 @@ C_MODE_START #endif #endif -#if defined(__WIN__) +#if defined(_WIN32) #define O_NONBLOCK 1 /* For emulation of fcntl() */ /* diff --git a/include/my_pthread.h b/include/my_pthread.h index f5bfda49a28..c81f3ec7d40 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -30,7 +30,7 @@ extern "C" { #define EXTERNC #endif /* __cplusplus */ -#if defined(__WIN__) +#if defined(_WIN32) typedef CRITICAL_SECTION pthread_mutex_t; typedef DWORD pthread_t; typedef struct thread_attr { @@ -104,7 +104,6 @@ int pthread_cancel(pthread_t thread); #define ETIMEDOUT 145 /* Win32 doesn't have this */ #endif -#define getpid() GetCurrentThreadId() #define HAVE_LOCALTIME_R 1 #define _REENTRANT 1 #define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 @@ -278,7 +277,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res); #define HAVE_PTHREAD_KILL 1 #endif -#endif /* defined(__WIN__) */ +#endif /* defined(_WIN32) */ #if defined(HPUX10) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) #undef pthread_cond_timedwait diff --git a/include/my_rdtsc.h b/include/my_rdtsc.h index 33d722764d4..5a6f4a87012 100644 --- a/include/my_rdtsc.h +++ b/include/my_rdtsc.h @@ -130,8 +130,10 @@ static inline ulonglong my_timer_cycles(void) { # if __has_builtin(__builtin_readcyclecounter) && !defined (__aarch64__) return __builtin_readcyclecounter(); -# elif defined _WIN32 || defined __i386__ || defined __x86_64__ +# elif defined _M_IX86 || defined _M_X64 || defined __i386__ || defined __x86_64__ return __rdtsc(); +#elif defined _M_ARM64 + return _ReadStatusReg(ARM64_CNTVCT); # elif defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H) return (ulonglong) __getReg(_IA64_REG_AR_ITC); /* (3116) */ #elif defined(__GNUC__) && defined(__ia64__) diff --git a/include/my_service_manager.h b/include/my_service_manager.h index 95b5235e755..3eff1253f20 100644 --- a/include/my_service_manager.h +++ b/include/my_service_manager.h @@ -31,8 +31,16 @@ /** INTERVAL in seconds followed by printf style status */ #define service_manager_extend_timeout(INTERVAL, FMTSTR, ...) \ sd_notifyf(0, "STATUS=" FMTSTR "\nEXTEND_TIMEOUT_USEC=%u\n", ##__VA_ARGS__, INTERVAL * 1000000) +/* sd_listen_fds_with_names added v227 however RHEL/Centos7 has v219, fallback to sd_listen_fds */ +#ifndef HAVE_SYSTEMD_SD_LISTEN_FDS_WITH_NAMES +#define sd_listen_fds_with_names(FD, NAMES) sd_listen_fds(FD) +#endif #else +#define sd_listen_fds_with_names(FD, NAMES) (0) +#define sd_is_socket_unix(FD, TYPE, LISTENING, PATH, SIZE) (0) +#define sd_is_socket_inet(FD, FAMILY, TYPE, LISTENING, PORT) (0) +#define SD_LISTEN_FDS_START (0) #define sd_notify(X, Y) #define sd_notifyf(E, F, ...) #define service_manager_extend_timeout(I, FMTSTR, ...) diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h index 20b86f45232..7cfee0f7a4f 100644 --- a/include/my_stacktrace.h +++ b/include/my_stacktrace.h @@ -23,7 +23,7 @@ (defined(__alpha__) && defined(__GNUC__)) #define HAVE_STACKTRACE 1 #endif -#elif defined(__WIN__) || defined(HAVE_PRINTSTACK) +#elif defined(_WIN32) || defined(HAVE_PRINTSTACK) #define HAVE_STACKTRACE 1 #endif @@ -49,12 +49,12 @@ void my_write_core(int sig); # if BACKTRACE_DEMANGLE char *my_demangle(const char *mangled_name, int *status); # endif /* BACKTRACE_DEMANGLE */ -# ifdef __WIN__ +# ifdef _WIN32 # define my_setup_stacktrace() void my_set_exception_pointers(EXCEPTION_POINTERS *ep); # else void my_setup_stacktrace(void); -# endif /* __WIN__ */ +# endif /* _WIN32 */ #else # define my_setup_stacktrace() #endif /* ! (defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)) */ diff --git a/include/my_sys.h b/include/my_sys.h index e2517736131..7eda45b6cc2 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -74,6 +74,12 @@ C_MODE_START #define MY_SHORT_WAIT 64U /* my_lock() don't wait if can't lock */ #define MY_FORCE_LOCK 128U /* use my_lock() even if disable_locking */ #define MY_NO_WAIT 256U /* my_lock() don't wait at all */ +#define MY_NO_REGISTER 8196U /* my_open(), no malloc for file name */ +/* + If old_mode is UTF8_IS_UTF8MB3, then pass this flag. It mean utf8 is + alias for utf8mb3. Otherwise utf8 is alias for utf8mb4. +*/ +#define MY_UTF8_IS_UTF8MB3 1024U /* init_dynamic_array() has init buffer; Internal flag, not to be used by caller. @@ -179,8 +185,10 @@ extern BOOL my_obtain_privilege(LPCSTR lpPrivilege); void my_init_atomic_write(void); #ifdef __linux__ my_bool my_test_if_atomic_write(File handle, int pagesize); +my_bool my_test_if_thinly_provisioned(File handle); #else -#define my_test_if_atomic_write(A, B) 0 +# define my_test_if_atomic_write(A, B) 0 +# define my_test_if_thinly_provisioned(A) 0 #endif /* __linux__ */ extern my_bool my_may_have_atomic_write; @@ -263,6 +271,10 @@ extern int my_umask_dir, my_recived_signals, /* Signals we have got */ my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ my_dont_interrupt; /* call remember_intr when set */ +#ifdef _WIN32 +extern SECURITY_ATTRIBUTES my_dir_security_attributes; +LPSECURITY_ATTRIBUTES my_win_file_secattr(); +#endif extern MYSQL_PLUGIN_IMPORT my_bool my_use_symdir; extern ulong my_default_record_cache_size; @@ -1009,18 +1021,20 @@ int my_msync(int, void *, size_t, int); #define MY_UUID_SIZE 16 #define MY_UUID_STRING_LENGTH (8+1+4+1+4+1+4+1+12) +#define MY_UUID_ORACLE_STRING_LENGTH (8+4+4+4+12) void my_uuid_init(ulong seed1, ulong seed2); void my_uuid(uchar *guid); void my_uuid2str(const uchar *guid, char *s); +void my_uuid2str_oracle(const uchar *guid, char *s); void my_uuid_end(void); const char *my_dlerror(const char *dlpath); /* character sets */ extern void my_charset_loader_init_mysys(MY_CHARSET_LOADER *loader); -extern uint get_charset_number(const char *cs_name, uint cs_flags); -extern uint get_collation_number(const char *name); +extern uint get_charset_number(const char *cs_name, uint cs_flags, myf flags); +extern uint get_collation_number(const char *name,myf flags); extern const char *get_charset_name(uint cs_number); extern CHARSET_INFO *get_charset(uint cs_number, myf flags); @@ -1034,22 +1048,25 @@ extern CHARSET_INFO *my_charset_get_by_name(MY_CHARSET_LOADER *loader, uint cs_flags, myf my_flags); extern my_bool resolve_charset(const char *cs_name, CHARSET_INFO *default_cs, - CHARSET_INFO **cs); + CHARSET_INFO **cs, + myf flags); extern my_bool resolve_collation(const char *cl_name, CHARSET_INFO *default_cl, - CHARSET_INFO **cl); + CHARSET_INFO **cl, + myf my_flags); extern void free_charsets(void); extern char *get_charsets_dir(char *buf); static inline my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2) { - return (cs1->csname == cs2->csname); + return (cs1->cs_name.str == cs2->cs_name.str); } extern my_bool init_compiled_charsets(myf flags); extern void add_compiled_collation(struct charset_info_st *cs); extern void add_compiled_extra_collation(struct charset_info_st *cs); extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info, char *to, size_t to_length, - const char *from, size_t length); + const char *from, size_t length, + my_bool *overflow); extern char *get_tty_password(const char *opt_message); #ifdef _WIN32 #define BACKSLASH_MBTAIL @@ -1059,7 +1076,8 @@ extern CHARSET_INFO *fs_character_set(void); extern const char *my_default_csname(void); extern size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info, char *to, size_t to_length, - const char *from, size_t length); + const char *from, size_t length, + my_bool *overflow); extern void thd_increment_bytes_sent(void *thd, size_t length); extern void thd_increment_bytes_received(void *thd, size_t length); diff --git a/include/mysql.h b/include/mysql.h index 6ff4c6d3fad..87def05dc7e 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -32,13 +32,6 @@ #include <standards.h> #endif -#ifdef __CYGWIN__ /* CYGWIN implements a UNIX API */ -#undef WIN -#undef _WIN -#undef _WIN32 -#undef _WIN64 -#undef __WIN__ -#endif #ifdef __cplusplus extern "C" { @@ -53,10 +46,7 @@ extern "C" { typedef char my_bool; #endif -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__) -#define __WIN__ -#endif -#if !defined(__WIN__) +#if !defined(_WIN32) #define STDCALL #else #define STDCALL __stdcall @@ -130,7 +120,7 @@ typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */ #ifndef MY_GLOBAL_INCLUDED #if defined(NO_CLIENT_LONG_LONG) typedef unsigned long my_ulonglong; -#elif defined (__WIN__) +#elif defined (_WIN32) typedef unsigned __int64 my_ulonglong; #else typedef unsigned long long my_ulonglong; diff --git a/include/mysql.h.pp b/include/mysql.h.pp index d3ee7c3996f..584276a7a08 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -18,7 +18,7 @@ enum enum_server_command COM_SLAVE_WORKER=251, COM_SLAVE_IO=252, COM_SLAVE_SQL=253, - COM_MULTI=254, + COM_RESERVED_1=254, COM_END=255 }; enum enum_indicator_type diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index e1cc53564ab..cc0943e4382 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -662,6 +662,8 @@ int thd_in_lock_tables(const MYSQL_THD thd); int thd_tablespace_op(const MYSQL_THD thd); long long thd_test_options(const MYSQL_THD thd, long long test_options); int thd_sql_command(const MYSQL_THD thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const MYSQL_THD thd); void thd_storage_lock_wait(MYSQL_THD thd, long long value); int thd_tx_isolation(const MYSQL_THD thd); int thd_tx_is_read_only(const MYSQL_THD thd); diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 07fe16ea92f..2e0cdff4b50 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 18eebd5e04a..464c5514acb 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_data_type.h.pp b/include/mysql/plugin_data_type.h.pp index 3db2fdd0251..cb256e00cd7 100644 --- a/include/mysql/plugin_data_type.h.pp +++ b/include/mysql/plugin_data_type.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index ff436bb24c4..11cd622861c 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index daefd6b2838..9a798627518 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -560,6 +560,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_function.h.pp b/include/mysql/plugin_function.h.pp index 0f915c8413f..4b2a0fc7082 100644 --- a/include/mysql/plugin_function.h.pp +++ b/include/mysql/plugin_function.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index fc8c3848f8c..eae776a753b 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h index 143c382c912..4f1b48aa9a4 100644 --- a/include/mysql/psi/mysql_socket.h +++ b/include/mysql/psi/mysql_socket.h @@ -75,6 +75,15 @@ struct st_mysql_socket /** The real socket descriptor. */ my_socket fd; + /** Is this a Unix-domain socket? */ + char is_unix_domain_socket; + + /** Is this a socket opened for the extra port? */ + char is_extra_port; + + /** Address family of the socket. (See sa_family from struct sockaddr). */ + unsigned short address_family; + /** The instrumentation hook. Note that this hook is not conditionally defined, @@ -105,7 +114,7 @@ typedef struct st_mysql_socket MYSQL_SOCKET; static inline MYSQL_SOCKET mysql_socket_invalid() { - MYSQL_SOCKET mysql_socket= {INVALID_SOCKET, NULL}; + MYSQL_SOCKET mysql_socket= {INVALID_SOCKET, 0, 0, 0, NULL}; return mysql_socket; } @@ -296,6 +305,22 @@ inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state) #endif /* HAVE_PSI_SOCKET_INTERFACE */ /** + @def mysql_socket_fd(K, F) + Create a socket. + @c mysql_socket_fd is a replacement for @c socket. + @param K PSI_socket_key for this instrumented socket + @param F File descriptor +*/ + +#ifdef HAVE_PSI_SOCKET_INTERFACE + #define mysql_socket_fd(K, F) \ + inline_mysql_socket_fd(K, F) +#else + #define mysql_socket_fd(K, F) \ + inline_mysql_socket_fd(F) +#endif + +/** @def mysql_socket_socket(K, D, T, P) Create a socket. @c mysql_socket_socket is a replacement for @c socket. @@ -569,6 +594,39 @@ static inline void inline_mysql_socket_register( } #endif +/** mysql_socket_fd */ + +static inline MYSQL_SOCKET +inline_mysql_socket_fd +( +#ifdef HAVE_PSI_SOCKET_INTERFACE + PSI_socket_key key, +#endif + int fd) +{ + MYSQL_SOCKET mysql_socket= MYSQL_INVALID_SOCKET; + mysql_socket.fd= fd; + + DBUG_ASSERT(mysql_socket.fd != INVALID_SOCKET); +#ifdef HAVE_PSI_SOCKET_INTERFACE + mysql_socket.m_psi= PSI_SOCKET_CALL(init_socket) + (key, (const my_socket*)&mysql_socket.fd, NULL, 0); +#endif + /** + Currently systemd socket activation is the user of this + function. Its API (man sd_listen_fds) says FD_CLOSE_EXEC + is already called. If there becomes another user, we + can call it again without detriment. + + If needed later: + #if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) + (void) fcntl(mysql_socket.fd, F_SETFD, FD_CLOEXEC); + #endif + */ + + return mysql_socket; +} + /** mysql_socket_socket */ static inline MYSQL_SOCKET diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index f380f2f02ac..a301adcad18 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -1,5 +1,5 @@ /* Copyright (c) 2008, 2021, Oracle and/or its affiliates. - Copyright (c) 2020, MariaDB Corporation. + Copyright (c) 2020, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -727,6 +727,13 @@ static inline int inline_mysql_mutex_destroy( #endif } +#ifdef HAVE_PSI_MUTEX_INTERFACE +ATTRIBUTE_COLD int psi_mutex_lock(mysql_mutex_t *that, + const char *file, uint line); +ATTRIBUTE_COLD int psi_mutex_trylock(mysql_mutex_t *that, + const char *file, uint line); +#endif + static inline int inline_mysql_mutex_lock( mysql_mutex_t *that #if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE) @@ -734,40 +741,16 @@ static inline int inline_mysql_mutex_lock( #endif ) { - int result; - #ifdef HAVE_PSI_MUTEX_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_mutex_locker *locker; - PSI_mutex_locker_state state; - locker= PSI_MUTEX_CALL(start_mutex_wait)(&state, that->m_psi, - PSI_MUTEX_LOCK, src_file, src_line); - - /* Instrumented code */ -#ifdef SAFE_MUTEX - result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line); -#else - result= pthread_mutex_lock(&that->m_mutex); -#endif - - /* Instrumentation end */ - if (locker != NULL) - PSI_MUTEX_CALL(end_mutex_wait)(locker, result); - - return result; - } + return psi_mutex_lock(that, src_file, src_line); #endif - /* Non instrumented code */ #ifdef SAFE_MUTEX - result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line); + return safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line); #else - result= pthread_mutex_lock(&that->m_mutex); + return pthread_mutex_lock(&that->m_mutex); #endif - - return result; } static inline int inline_mysql_mutex_trylock( @@ -777,40 +760,16 @@ static inline int inline_mysql_mutex_trylock( #endif ) { - int result; - #ifdef HAVE_PSI_MUTEX_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_mutex_locker *locker; - PSI_mutex_locker_state state; - locker= PSI_MUTEX_CALL(start_mutex_wait)(&state, that->m_psi, - PSI_MUTEX_TRYLOCK, src_file, src_line); - - /* Instrumented code */ -#ifdef SAFE_MUTEX - result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line); -#else - result= pthread_mutex_trylock(&that->m_mutex); + return psi_mutex_trylock(that, src_file, src_line); #endif - - /* Instrumentation end */ - if (locker != NULL) - PSI_MUTEX_CALL(end_mutex_wait)(locker, result); - - return result; - } -#endif - /* Non instrumented code */ #ifdef SAFE_MUTEX - result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line); + return safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line); #else - result= pthread_mutex_trylock(&that->m_mutex); + return pthread_mutex_trylock(&that->m_mutex); #endif - - return result; } static inline int inline_mysql_mutex_unlock( @@ -914,6 +873,23 @@ static inline int inline_mysql_prlock_destroy( } #endif +#ifdef HAVE_PSI_RWLOCK_INTERFACE +ATTRIBUTE_COLD +int psi_rwlock_rdlock(mysql_rwlock_t *that, const char *file, uint line); +ATTRIBUTE_COLD +int psi_rwlock_tryrdlock(mysql_rwlock_t *that, const char *file, uint line); +ATTRIBUTE_COLD +int psi_rwlock_wrlock(mysql_rwlock_t *that, const char *file, uint line); +ATTRIBUTE_COLD +int psi_rwlock_trywrlock(mysql_rwlock_t *that, const char *file, uint line); +# ifndef DISABLE_MYSQL_PRLOCK_H +ATTRIBUTE_COLD +int psi_prlock_rdlock(mysql_prlock_t *that, const char *file, uint line); +ATTRIBUTE_COLD +int psi_prlock_wrlock(mysql_prlock_t *that, const char *file, uint line); +# endif +#endif + static inline int inline_mysql_rwlock_rdlock( mysql_rwlock_t *that #ifdef HAVE_PSI_RWLOCK_INTERFACE @@ -921,32 +897,11 @@ static inline int inline_mysql_rwlock_rdlock( #endif ) { - int result; - #ifdef HAVE_PSI_RWLOCK_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_rwlock_locker *locker; - PSI_rwlock_locker_state state; - locker= PSI_RWLOCK_CALL(start_rwlock_rdwait)(&state, that->m_psi, - PSI_RWLOCK_READLOCK, src_file, src_line); - - /* Instrumented code */ - result= rw_rdlock(&that->m_rwlock); - - /* Instrumentation end */ - if (locker != NULL) - PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, result); - - return result; - } + return psi_rwlock_rdlock(that, src_file, src_line); #endif - - /* Non instrumented code */ - result= rw_rdlock(&that->m_rwlock); - - return result; + return rw_rdlock(&that->m_rwlock); } #ifndef DISABLE_MYSQL_PRLOCK_H @@ -957,32 +912,11 @@ static inline int inline_mysql_prlock_rdlock( #endif ) { - int result; - #ifdef HAVE_PSI_RWLOCK_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_rwlock_locker *locker; - PSI_rwlock_locker_state state; - locker= PSI_RWLOCK_CALL(start_rwlock_rdwait)(&state, that->m_psi, - PSI_RWLOCK_READLOCK, src_file, src_line); - - /* Instrumented code */ - result= rw_pr_rdlock(&that->m_prlock); - - /* Instrumentation end */ - if (locker != NULL) - PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, result); - - return result; - } + return psi_prlock_rdlock(that, src_file, src_line); #endif - - /* Non instrumented code */ - result= rw_pr_rdlock(&that->m_prlock); - - return result; + return rw_pr_rdlock(&that->m_prlock); } #endif @@ -993,32 +927,11 @@ static inline int inline_mysql_rwlock_wrlock( #endif ) { - int result; - #ifdef HAVE_PSI_RWLOCK_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_rwlock_locker *locker; - PSI_rwlock_locker_state state; - locker= PSI_RWLOCK_CALL(start_rwlock_wrwait)(&state, that->m_psi, - PSI_RWLOCK_WRITELOCK, src_file, src_line); - - /* Instrumented code */ - result= rw_wrlock(&that->m_rwlock); - - /* Instrumentation end */ - if (locker != NULL) - PSI_RWLOCK_CALL(end_rwlock_wrwait)(locker, result); - - return result; - } + return psi_rwlock_wrlock(that, src_file, src_line); #endif - - /* Non instrumented code */ - result= rw_wrlock(&that->m_rwlock); - - return result; + return rw_wrlock(&that->m_rwlock); } #ifndef DISABLE_MYSQL_PRLOCK_H @@ -1029,32 +942,11 @@ static inline int inline_mysql_prlock_wrlock( #endif ) { - int result; - #ifdef HAVE_PSI_RWLOCK_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_rwlock_locker *locker; - PSI_rwlock_locker_state state; - locker= PSI_RWLOCK_CALL(start_rwlock_wrwait)(&state, that->m_psi, - PSI_RWLOCK_WRITELOCK, src_file, src_line); - - /* Instrumented code */ - result= rw_pr_wrlock(&that->m_prlock); - - /* Instrumentation end */ - if (locker != NULL) - PSI_RWLOCK_CALL(end_rwlock_wrwait)(locker, result); - - return result; - } + return psi_prlock_wrlock(that, src_file, src_line); #endif - - /* Non instrumented code */ - result= rw_pr_wrlock(&that->m_prlock); - - return result; + return rw_pr_wrlock(&that->m_prlock); } #endif @@ -1065,32 +957,11 @@ static inline int inline_mysql_rwlock_tryrdlock( #endif ) { - int result; - #ifdef HAVE_PSI_RWLOCK_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_rwlock_locker *locker; - PSI_rwlock_locker_state state; - locker= PSI_RWLOCK_CALL(start_rwlock_rdwait)(&state, that->m_psi, - PSI_RWLOCK_TRYREADLOCK, src_file, src_line); - - /* Instrumented code */ - result= rw_tryrdlock(&that->m_rwlock); - - /* Instrumentation end */ - if (locker != NULL) - PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, result); - - return result; - } + return psi_rwlock_tryrdlock(that, src_file, src_line); #endif - - /* Non instrumented code */ - result= rw_tryrdlock(&that->m_rwlock); - - return result; + return rw_tryrdlock(&that->m_rwlock); } static inline int inline_mysql_rwlock_trywrlock( @@ -1100,32 +971,11 @@ static inline int inline_mysql_rwlock_trywrlock( #endif ) { - int result; - #ifdef HAVE_PSI_RWLOCK_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_rwlock_locker *locker; - PSI_rwlock_locker_state state; - locker= PSI_RWLOCK_CALL(start_rwlock_wrwait)(&state, that->m_psi, - PSI_RWLOCK_TRYWRITELOCK, src_file, src_line); - - /* Instrumented code */ - result= rw_trywrlock(&that->m_rwlock); - - /* Instrumentation end */ - if (locker != NULL) - PSI_RWLOCK_CALL(end_rwlock_wrwait)(locker, result); - - return result; - } + return psi_rwlock_trywrlock(that, src_file, src_line); #endif - - /* Non instrumented code */ - result= rw_trywrlock(&that->m_rwlock); - - return result; + return rw_trywrlock(&that->m_rwlock); } static inline int inline_mysql_rwlock_unlock( @@ -1199,6 +1049,14 @@ static inline int inline_mysql_cond_destroy( return pthread_cond_destroy(&that->m_cond); } +#ifdef HAVE_PSI_COND_INTERFACE +ATTRIBUTE_COLD int psi_cond_wait(mysql_cond_t *that, mysql_mutex_t *mutex, + const char *file, uint line); +ATTRIBUTE_COLD int psi_cond_timedwait(mysql_cond_t *that, mysql_mutex_t *mutex, + const struct timespec *abstime, + const char *file, uint line); +#endif + static inline int inline_mysql_cond_wait( mysql_cond_t *that, mysql_mutex_t *mutex @@ -1207,32 +1065,11 @@ static inline int inline_mysql_cond_wait( #endif ) { - int result; - #ifdef HAVE_PSI_COND_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_cond_locker *locker; - PSI_cond_locker_state state; - locker= PSI_COND_CALL(start_cond_wait)(&state, that->m_psi, mutex->m_psi, - PSI_COND_WAIT, src_file, src_line); - - /* Instrumented code */ - result= my_cond_wait(&that->m_cond, &mutex->m_mutex); - - /* Instrumentation end */ - if (locker != NULL) - PSI_COND_CALL(end_cond_wait)(locker, result); - - return result; - } + return psi_cond_wait(that, mutex, src_file, src_line); #endif - - /* Non instrumented code */ - result= my_cond_wait(&that->m_cond, &mutex->m_mutex); - - return result; + return my_cond_wait(&that->m_cond, &mutex->m_mutex); } static inline int inline_mysql_cond_timedwait( @@ -1244,32 +1081,11 @@ static inline int inline_mysql_cond_timedwait( #endif ) { - int result; - #ifdef HAVE_PSI_COND_INTERFACE if (psi_likely(that->m_psi != NULL)) - { - /* Instrumentation start */ - PSI_cond_locker *locker; - PSI_cond_locker_state state; - locker= PSI_COND_CALL(start_cond_wait)(&state, that->m_psi, mutex->m_psi, - PSI_COND_TIMEDWAIT, src_file, src_line); - - /* Instrumented code */ - result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime); - - /* Instrumentation end */ - if (psi_likely(locker != NULL)) - PSI_COND_CALL(end_cond_wait)(locker, result); - - return result; - } + return psi_cond_timedwait(that, mutex, abstime, src_file, src_line); #endif - - /* Non instrumented code */ - result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime); - - return result; + return my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime); } static inline int inline_mysql_cond_signal( diff --git a/include/mysql_async.h b/include/mysql_async.h deleted file mode 100644 index 3e4cb351bb5..00000000000 --- a/include/mysql_async.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2012 MariaDB Services and Kristian Nielsen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ - -/* Common definitions for MariaDB non-blocking client library. */ - -#ifndef MYSQL_ASYNC_H -#define MYSQL_ASYNC_H - -extern int my_connect_async(struct mysql_async_context *b, my_socket fd, - const struct sockaddr *name, uint namelen, - int vio_timeout); -extern ssize_t my_recv_async(struct mysql_async_context *b, my_socket fd, - unsigned char *buf, size_t size, int timeout); -extern ssize_t my_send_async(struct mysql_async_context *b, my_socket fd, - const unsigned char *buf, size_t size, - int timeout); -extern my_bool my_io_wait_async(struct mysql_async_context *b, - enum enum_vio_io_event event, int timeout); -#ifdef HAVE_OPENSSL -extern int my_ssl_read_async(struct mysql_async_context *b, SSL *ssl, - void *buf, int size); -extern int my_ssl_write_async(struct mysql_async_context *b, SSL *ssl, - const void *buf, int size); -#endif - -#endif /* MYSQL_ASYNC_H */ diff --git a/include/mysql_com.h b/include/mysql_com.h index eb2ee7410d8..b0d5b026dd8 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -23,7 +23,7 @@ #include "my_decimal_limits.h" -#define HOSTNAME_LENGTH 60 +#define HOSTNAME_LENGTH 255 #define HOSTNAME_LENGTH_STR STRINGIFY_ARG(HOSTNAME_LENGTH) #define SYSTEM_CHARSET_MBMAXLEN 3 #define NAME_CHAR_LEN 64 /* Field/table name length */ @@ -96,10 +96,10 @@ #define LOCAL_HOST_NAMEDPIPE "." -#if defined(__WIN__) && !defined( _CUSTOMCONFIG_) +#if defined(_WIN32) && !defined( _CUSTOMCONFIG_) #define MYSQL_NAMEDPIPE "MySQL" #define MYSQL_SERVICENAME "MySQL" -#endif /* __WIN__ */ +#endif /* You should add new commands to the end of this list, otherwise old @@ -124,7 +124,7 @@ enum enum_server_command COM_SLAVE_WORKER=251, COM_SLAVE_IO=252, COM_SLAVE_SQL=253, - COM_MULTI=254, + COM_RESERVED_1=254, /* Old COM_MULTI, now removed */ /* Must be last */ COM_END=255 }; @@ -297,13 +297,18 @@ enum enum_indicator_type #define MARIADB_CLIENT_FLAGS_MASK 0xffffffff00000000ULL /* Client support progress indicator */ #define MARIADB_CLIENT_PROGRESS (1ULL << 32) -/* support COM_MULTI */ -#define MARIADB_CLIENT_COM_MULTI (1ULL << 33) + +/* Old COM_MULTI experiment (functionality removed).*/ +#define MARIADB_CLIENT_RESERVED_1 (1ULL << 33) + /* support of array binding */ #define MARIADB_CLIENT_STMT_BULK_OPERATIONS (1ULL << 34) /* support of extended metadata (e.g. type/format information) */ #define MARIADB_CLIENT_EXTENDED_METADATA (1ULL << 35) +/* Do not resend metadata for prepared statements, since 10.6*/ +#define MARIADB_CLIENT_CACHE_METADATA (1ULL << 36) + #ifdef HAVE_COMPRESS #define CAN_CLIENT_COMPRESS CLIENT_COMPRESS #else @@ -342,11 +347,10 @@ enum enum_indicator_type CLIENT_SESSION_TRACK |\ CLIENT_DEPRECATE_EOF |\ CLIENT_CONNECT_ATTRS |\ - MARIADB_CLIENT_COM_MULTI |\ MARIADB_CLIENT_STMT_BULK_OPERATIONS |\ MARIADB_CLIENT_EXTENDED_METADATA|\ + MARIADB_CLIENT_CACHE_METADATA |\ CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS) - /* Switch off the flags that are optional and depending on build flags If any of the optional flags is supported by the build it will be switched diff --git a/include/sql_common.h b/include/sql_common.h index 9836d0c1cdc..9fc983616a0 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -28,8 +28,6 @@ extern const char *cant_connect_sqlstate; extern const char *not_error_sqlstate; -struct mysql_async_context; - struct st_mysql_options_extention { char *plugin_dir; char *default_auth; @@ -41,7 +39,6 @@ struct st_mysql_options_extention { double progress, const char *proc_info, uint proc_info_length); - struct mysql_async_context *async_context; HASH connection_attributes; size_t connection_attributes_length; }; @@ -125,10 +122,6 @@ struct st_mysql_client_plugin; extern struct st_mysql_client_plugin *mysql_client_builtins[]; uchar * send_client_connect_attrs(MYSQL *mysql, uchar *buf); -/* Non-blocking client API. */ -void my_context_install_suspend_resume_hook(struct mysql_async_context *b, - void (*)(my_bool, void *), void *); - #ifdef __cplusplus } #endif diff --git a/include/sslopt-case.h b/include/sslopt-case.h index 72881a266ab..11351247cd7 100644 --- a/include/sslopt-case.h +++ b/include/sslopt-case.h @@ -29,11 +29,16 @@ One can disable SSL later by using --skip-ssl or --ssl=0 */ opt_use_ssl= 1; -#if defined (HAVE_WOLFSSL) && (!defined (_WIN32) || defined (MYSQL_SERVER)) - /* CRL does not work with WolfSSL */ +#if defined (HAVE_WOLFSSL) +#if defined(MYSQL_SERVER) + /* CRL does not work with WolfSSL (server) */ opt_ssl_crl= NULL; +#endif +#if !defined(_WIN32) || !defined(LIBMARIADB) + /* CRL_PATH does not work with WolfSSL (server) and GnuTLS (client) */ opt_ssl_crlpath= NULL; #endif +#endif break; #endif #endif /* SSLOPT_CASE_INCLUDED */ diff --git a/include/thr_alarm.h b/include/thr_alarm.h index 250590a0e2f..e0f3fdd1c25 100644 --- a/include/thr_alarm.h +++ b/include/thr_alarm.h @@ -65,7 +65,7 @@ typedef my_bool ALARM; #define end_thr_alarm(A) #else -#if defined(__WIN__) +#if defined(_WIN32) typedef struct st_thr_alarm_entry { UINT_PTR crono; @@ -77,7 +77,7 @@ typedef int thr_alarm_entry; #define thr_got_alarm(thr_alarm) (**(thr_alarm)) -#endif /* __WIN__ */ +#endif /* _WIN32 */ typedef thr_alarm_entry* thr_alarm_t; diff --git a/include/thr_lock.h b/include/thr_lock.h index 1ea24132d90..d918d6d74f4 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -47,6 +47,8 @@ enum thr_lock_type { TL_IGNORE=-1, TL_READ_HIGH_PRIORITY, /* READ, Don't allow concurrent insert */ TL_READ_NO_INSERT, + /* READ, but skip locks if found */ + TL_READ_SKIP_LOCKED, /* Write lock, but allow other threads to read / write. Used by BDB tables in MySQL to mark that someone is @@ -67,11 +69,22 @@ enum thr_lock_type { TL_IGNORE=-1, TL_WRITE_DEFAULT, /* WRITE lock that has lower priority than TL_READ */ TL_WRITE_LOW_PRIORITY, + /* WRITE, but skip locks if found */ + TL_WRITE_SKIP_LOCKED, /* Normal WRITE lock */ TL_WRITE, /* Abort new lock request with an error */ TL_WRITE_ONLY}; +/* + TL_FIRST_WRITE is here to impose some consistency in the sql + layer on determining read/write transactions and to + provide some API compatibility if additional transactions + are added. Above or equal to TL_FIRST_WRITE is a write transaction + while < TL_FIRST_WRITE is a read transaction. +*/ +#define TL_FIRST_WRITE TL_WRITE_ALLOW_WRITE + enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1, THR_LOCK_WAIT_TIMEOUT= 2, THR_LOCK_DEADLOCK= 3 }; diff --git a/include/thread_pool_priv.h b/include/thread_pool_priv.h deleted file mode 100644 index 769c4a7d97d..00000000000 --- a/include/thread_pool_priv.h +++ /dev/null @@ -1,109 +0,0 @@ -#error don't use -/* - Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA -*/ - -#ifndef THREAD_POOL_PRIV_INCLUDED -#define THREAD_POOL_PRIV_INCLUDED - -/* - The thread pool requires access to some MySQL server error codes, this is - accessed from mysqld_error.h. - We need access to the struct that defines the thread pool plugin interface - which is accessed through scheduler.h. - All accesses to THD variables and functions are defined in this header file. - A thread pool can also use DEBUG_SYNC and must thus include - debug_sync.h - To handle definitions of Information Schema plugins it is also required - to include sql_profile.h and table.h. -*/ -#include <mysqld_error.h> /* To get ER_ERROR_ON_READ */ -#define MYSQL_SERVER 1 -#include <scheduler.h> -#include <debug_sync.h> -#include <sql_profile.h> -#include <table.h> -#include <sql_list.h> - -/* Interface to THD variables and functions */ -void thd_set_killed(THD *thd); -void thd_clear_errors(THD *thd); -void thd_set_thread_stack(THD *thd, char *stack_start); -void thd_lock_thread_count(THD *thd); -void thd_close_connection(THD *thd); -THD *thd_get_current_thd(); -void thd_lock_data(THD *thd); -void thd_unlock_data(THD *thd); -bool thd_is_transaction_active(THD *thd); -int thd_connection_has_data(THD *thd); -void thd_set_net_read_write(THD *thd, uint val); -uint thd_get_net_read_write(THD *thd); -void thd_set_mysys_var(THD *thd, st_my_thread_var *mysys_var); -my_socket thd_get_fd(THD *thd); -int thd_store_globals(THD* thd); - -/* Print to the MySQL error log */ -void sql_print_error(const char *format, ...); - -/* Store a table record */ -bool schema_table_store_record(THD *thd, TABLE *table); - -/* - The thread pool must be able to execute statements using the connection - state in THD object. This is the main objective of the thread pool to - schedule the start of these commands. -*/ -bool do_command(THD *thd); - -/* - The thread pool requires an interface to the connection logic in the - MySQL Server since the thread pool will maintain the event logic on - the TCP connection of the MySQL Server. Thus new connections, dropped - connections will be discovered by the thread pool and it needs to - ensure that the proper MySQL Server logic attached to these events is - executed. -*/ -/* Set up connection thread before use as execution thread */ -bool setup_connection_thread_globals(THD *thd); -/* Prepare connection as part of connection set-up */ -bool thd_prepare_connection(THD *thd); -/* Release auditing before executing statement */ -void mysql_audit_release(THD *thd); -/* Check if connection is still alive */ -bool thd_is_connection_alive(THD *thd); -/* Close connection with possible error code */ -void close_connection(THD *thd, uint errcode); -/* Destroy THD object */ -void delete_thd(THD *thd); - -/* - thread_created is maintained by thread pool when activated since - user threads are created by the thread pool (and also special - threads to maintain the thread pool). This is done through - inc_thread_created. - - max_connections is needed to calculate the maximum number of threads - that is allowed to be started by the thread pool. The method - get_max_connections() gets reference to this variable. - - connection_attrib is the thread attributes for connection threads, - the method get_connection_attrib provides a reference to these - attributes. -*/ -void inc_thread_created(void); -ulong get_max_connections(void); -pthread_attr_t *get_connection_attrib(void); -#endif diff --git a/include/violite.h b/include/violite.h index 28e3ca08b0a..b823e62b2e1 100644 --- a/include/violite.h +++ b/include/violite.h @@ -74,11 +74,11 @@ struct vio_keepalive_opts Vio* vio_new(my_socket sd, enum enum_vio_type type, uint flags); Vio* mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum enum_vio_type type, uint flags); -#ifdef __WIN__ +#ifdef _WIN32 Vio* vio_new_win32pipe(HANDLE hPipe); #else #define HANDLE void * -#endif /* __WIN__ */ +#endif /* _WIN32 */ void vio_delete(Vio* vio); int vio_close(Vio* vio); @@ -249,7 +249,6 @@ struct st_vio char *read_pos; /* start of unfetched data in the read buffer */ char *read_end; /* end of unfetched data */ - struct mysql_async_context *async_context; /* For non-blocking API */ int read_timeout; /* Timeout value (ms) for read ops. */ int write_timeout; /* Timeout value (ms) for write ops. */ /* function pointers. They are similar for socket/SSL/whatever */ @@ -279,6 +278,7 @@ struct st_vio HANDLE hPipe; OVERLAPPED overlapped; int shutdown_flag; + void *tp_ctx; /* threadpool context */ #endif }; #endif /* vio_violite_h_ */ diff --git a/include/wsrep.h b/include/wsrep.h index 9150cd04b33..e68b14f4a17 100644 --- a/include/wsrep.h +++ b/include/wsrep.h @@ -27,33 +27,30 @@ #define WSREP_MYSQL_DB (char *)"mysql" #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ - if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \ + if (WSREP_ON && WSREP(thd) && \ + wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \ goto wsrep_error_label; #define WSREP_TO_ISOLATION_BEGIN_CREATE(db_, table_, table_list_, create_info_) \ - if (WSREP_ON && WSREP(thd) && \ - wsrep_to_isolation_begin(thd, db_, table_, \ - table_list_, nullptr, nullptr, create_info_))\ + if (WSREP_ON && WSREP(thd) && \ + wsrep_to_isolation_begin(thd, db_, table_, \ + table_list_, nullptr, nullptr, create_info_)) \ goto wsrep_error_label; #define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_, create_info_) \ - if (WSREP(thd) && wsrep_thd_is_local(thd) && \ - wsrep_to_isolation_begin(thd, db_, table_, \ - table_list_, alter_info_, \ + if (WSREP(thd) && \ + wsrep_to_isolation_begin(thd, db_, table_, \ + table_list_, alter_info_, \ fk_tables_, create_info_)) -#define WSREP_TO_ISOLATION_END \ - if ((WSREP(thd) && wsrep_thd_is_local_toi(thd)) || \ - wsrep_thd_is_in_rsu(thd)) \ - wsrep_to_isolation_end(thd); - /* Checks if lex->no_write_to_binlog is set for statements that use LOCAL or NO_WRITE_TO_BINLOG. */ -#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ - if (WSREP(thd) && !thd->lex->no_write_to_binlog \ - && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto wsrep_error_label; +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ + if (WSREP(thd) && !thd->lex->no_write_to_binlog && \ + wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \ + goto wsrep_error_label; #define WSREP_SYNC_WAIT(thd_, before_) \ { if (WSREP_CLIENT(thd_) && \ @@ -69,7 +66,6 @@ #define WSREP_ERROR(...) #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0) #define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_, create_info_) -#define WSREP_TO_ISOLATION_END #define WSREP_TO_ISOLATION_BEGIN_CREATE(db_, table_, table_list_, create_info_) #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) #define WSREP_SYNC_WAIT(thd_, before_) |