summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/atomic/gcc_builtins.h88
-rw-r--r--include/atomic/gcc_sync.h106
-rw-r--r--include/atomic/generic-msvc.h217
-rw-r--r--include/atomic/solaris.h143
-rw-r--r--include/atomic/x86-gcc.h151
-rw-r--r--include/hash.h1
-rw-r--r--include/ilist.h4
-rw-r--r--include/json_lib.h2
-rw-r--r--include/lf.h2
-rw-r--r--include/m_ctype.h19
-rw-r--r--include/m_string.h23
-rw-r--r--include/maria.h4
-rw-r--r--include/my_alloc.h2
-rw-r--r--include/my_atomic.h283
-rw-r--r--include/my_attribute.h4
-rw-r--r--include/my_base.h26
-rw-r--r--include/my_bit.h10
-rw-r--r--include/my_bitmap.h2
-rw-r--r--include/my_compare.h6
-rw-r--r--include/my_compiler.h2
-rw-r--r--include/my_cpu.h98
-rw-r--r--include/my_dbug.h30
-rw-r--r--include/my_dir.h10
-rw-r--r--include/my_getopt.h1
-rw-r--r--include/my_global.h159
-rw-r--r--include/my_handler_errors.h4
-rw-r--r--include/my_net.h4
-rw-r--r--include/my_pthread.h42
-rw-r--r--include/my_stacktrace.h7
-rw-r--r--include/my_sys.h87
-rw-r--r--include/my_time.h17
-rw-r--r--include/my_tree.h6
-rw-r--r--include/my_user.h2
-rw-r--r--include/my_valgrind.h69
-rw-r--r--include/myisam.h4
-rw-r--r--include/myisamchk.h3
-rw-r--r--include/myisammrg.h3
-rw-r--r--include/mysql.h1
-rw-r--r--include/mysql.h.pp8
-rw-r--r--include/mysql/plugin.h1
-rw-r--r--include/mysql/plugin_audit.h20
-rw-r--r--include/mysql/plugin_audit.h.pp35
-rw-r--r--include/mysql/plugin_auth.h2
-rw-r--r--include/mysql/plugin_auth.h.pp19
-rw-r--r--include/mysql/plugin_encryption.h.pp17
-rw-r--r--include/mysql/plugin_ftparser.h.pp17
-rw-r--r--include/mysql/plugin_password_validation.h4
-rw-r--r--include/mysql/plugin_password_validation.h.pp21
-rw-r--r--include/mysql/psi/mysql_file.h709
-rw-r--r--include/mysql/psi/mysql_idle.h2
-rw-r--r--include/mysql/psi/mysql_socket.h40
-rw-r--r--include/mysql/psi/mysql_statement.h22
-rw-r--r--include/mysql/psi/mysql_table.h8
-rw-r--r--include/mysql/psi/mysql_thread.h69
-rw-r--r--include/mysql/psi/psi.h16
-rw-r--r--include/mysql/psi/psi_abi_v1.h.pp1
-rw-r--r--include/mysql/psi/psi_abi_v2.h.pp1
-rw-r--r--include/mysql/service_my_print_error.h5
-rw-r--r--include/mysql/service_thd_alloc.h17
-rw-r--r--include/mysql/service_thd_rnd.h2
-rw-r--r--include/mysql/service_wsrep.h6
-rw-r--r--include/mysql_com.h28
-rw-r--r--include/mysql_version.h.in1
-rw-r--r--include/password.h2
-rw-r--r--include/queues.h4
-rw-r--r--include/source_revision.h.in1
-rw-r--r--include/ssl_compat.h4
-rw-r--r--include/thread_pool_priv.h1
-rw-r--r--include/typelib.h2
-rw-r--r--include/violite.h18
-rw-r--r--include/waiting_threads.h1
-rw-r--r--include/wqueue.h1
-rw-r--r--include/wsrep.h1
73 files changed, 1411 insertions, 1337 deletions
diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h
index dd19ccd9ed6..5b2b2c90118 100644
--- a/include/atomic/gcc_builtins.h
+++ b/include/atomic/gcc_builtins.h
@@ -1,7 +1,7 @@
#ifndef ATOMIC_GCC_BUILTINS_INCLUDED
#define ATOMIC_GCC_BUILTINS_INCLUDED
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2017 MariaDB Foundation
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
@@ -16,33 +16,63 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-#define make_atomic_add_body(S) \
- v= __sync_fetch_and_add(a, v);
-#define make_atomic_fas_body(S) \
- v= __sync_lock_test_and_set(a, v);
-#define make_atomic_cas_body(S) \
- int ## S sav; \
- int ## S cmp_val= *cmp; \
- sav= __sync_val_compare_and_swap(a, cmp_val, set);\
- if (!(ret= (sav == cmp_val))) *cmp= sav
-
-#ifdef MY_ATOMIC_MODE_DUMMY
-#define make_atomic_load_body(S) ret= *a
-#define make_atomic_store_body(S) *a= v
-#define MY_ATOMIC_MODE "gcc-builtins-up"
-
-#elif defined(HAVE_GCC_C11_ATOMICS)
-#define MY_ATOMIC_MODE "gcc-atomics-smp"
-#define make_atomic_load_body(S) \
- ret= __atomic_load_n(a, __ATOMIC_SEQ_CST)
-#define make_atomic_store_body(S) \
- __atomic_store_n(a, v, __ATOMIC_SEQ_CST)
-#else
-#define MY_ATOMIC_MODE "gcc-builtins-smp"
-#define make_atomic_load_body(S) \
- ret= __sync_fetch_and_or(a, 0);
-#define make_atomic_store_body(S) \
- (void) __sync_lock_test_and_set(a, v);
-#endif
+
+#define MY_MEMORY_ORDER_RELAXED __ATOMIC_RELAXED
+#define MY_MEMORY_ORDER_CONSUME __ATOMIC_CONSUME
+#define MY_MEMORY_ORDER_ACQUIRE __ATOMIC_ACQUIRE
+#define MY_MEMORY_ORDER_RELEASE __ATOMIC_RELEASE
+#define MY_MEMORY_ORDER_ACQ_REL __ATOMIC_ACQ_REL
+#define MY_MEMORY_ORDER_SEQ_CST __ATOMIC_SEQ_CST
+
+#define my_atomic_store32_explicit(P, D, O) __atomic_store_n((P), (D), (O))
+#define my_atomic_store64_explicit(P, D, O) __atomic_store_n((P), (D), (O))
+#define my_atomic_storeptr_explicit(P, D, O) __atomic_store_n((P), (D), (O))
+
+#define my_atomic_load32_explicit(P, O) __atomic_load_n((P), (O))
+#define my_atomic_load64_explicit(P, O) __atomic_load_n((P), (O))
+#define my_atomic_loadptr_explicit(P, O) __atomic_load_n((P), (O))
+
+#define my_atomic_fas32_explicit(P, D, O) __atomic_exchange_n((P), (D), (O))
+#define my_atomic_fas64_explicit(P, D, O) __atomic_exchange_n((P), (D), (O))
+#define my_atomic_fasptr_explicit(P, D, O) __atomic_exchange_n((P), (D), (O))
+
+#define my_atomic_add32_explicit(P, A, O) __atomic_fetch_add((P), (A), (O))
+#define my_atomic_add64_explicit(P, A, O) __atomic_fetch_add((P), (A), (O))
+
+#define my_atomic_cas32_weak_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_n((P), (E), (D), 1, (S), (F))
+#define my_atomic_cas64_weak_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_n((P), (E), (D), 1, (S), (F))
+#define my_atomic_casptr_weak_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_n((P), (E), (D), 1, (S), (F))
+
+#define my_atomic_cas32_strong_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_n((P), (E), (D), 0, (S), (F))
+#define my_atomic_cas64_strong_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_n((P), (E), (D), 0, (S), (F))
+#define my_atomic_casptr_strong_explicit(P, E, D, S, F) \
+ __atomic_compare_exchange_n((P), (E), (D), 0, (S), (F))
+
+#define my_atomic_store32(P, D) __atomic_store_n((P), (D), __ATOMIC_SEQ_CST)
+#define my_atomic_store64(P, D) __atomic_store_n((P), (D), __ATOMIC_SEQ_CST)
+#define my_atomic_storeptr(P, D) __atomic_store_n((P), (D), __ATOMIC_SEQ_CST)
+
+#define my_atomic_load32(P) __atomic_load_n((P), __ATOMIC_SEQ_CST)
+#define my_atomic_load64(P) __atomic_load_n((P), __ATOMIC_SEQ_CST)
+#define my_atomic_loadptr(P) __atomic_load_n((P), __ATOMIC_SEQ_CST)
+
+#define my_atomic_fas32(P, D) __atomic_exchange_n((P), (D), __ATOMIC_SEQ_CST)
+#define my_atomic_fas64(P, D) __atomic_exchange_n((P), (D), __ATOMIC_SEQ_CST)
+#define my_atomic_fasptr(P, D) __atomic_exchange_n((P), (D), __ATOMIC_SEQ_CST)
+
+#define my_atomic_add32(P, A) __atomic_fetch_add((P), (A), __ATOMIC_SEQ_CST)
+#define my_atomic_add64(P, A) __atomic_fetch_add((P), (A), __ATOMIC_SEQ_CST)
+
+#define my_atomic_cas32(P, E, D) \
+ __atomic_compare_exchange_n((P), (E), (D), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
+#define my_atomic_cas64(P, E, D) \
+ __atomic_compare_exchange_n((P), (E), (D), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
+#define my_atomic_casptr(P, E, D) \
+ __atomic_compare_exchange_n((P), (E), (D), 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
#endif /* ATOMIC_GCC_BUILTINS_INCLUDED */
diff --git a/include/atomic/gcc_sync.h b/include/atomic/gcc_sync.h
new file mode 100644
index 00000000000..82eea35b2ce
--- /dev/null
+++ b/include/atomic/gcc_sync.h
@@ -0,0 +1,106 @@
+#ifndef GCC_SYNC_INCLUDED
+#define GCC_SYNC_INCLUDED
+
+/* Copyright (c) 2008, 2016, 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-1301 USA */
+
+/* Old GCC __sync builtins introduced in GCC 4.1 */
+
+static inline int my_atomic_cas32(int32 volatile *a, int32 *cmp, int32 set)
+{
+ int32 cmp_val= *cmp;
+ int32 sav= __sync_val_compare_and_swap(a, cmp_val, set);
+ int ret= (sav == cmp_val);
+ if (!ret)
+ *cmp = sav;
+ return ret;
+}
+
+static inline int my_atomic_cas64(int64 volatile *a, int64 *cmp, int64 set)
+{
+ int64 cmp_val= *cmp;
+ int64 sav= __sync_val_compare_and_swap(a, cmp_val, set);
+ int ret= (sav == cmp_val);
+ if (!ret)
+ *cmp = sav;
+ return ret;
+}
+
+static inline int my_atomic_casptr(void * volatile *a, void **cmp, void *set)
+{
+ void *cmp_val= *cmp;
+ void *sav= __sync_val_compare_and_swap(a, cmp_val, set);
+ int ret= (sav == cmp_val);
+ if (!ret)
+ *cmp = sav;
+ return ret;
+}
+
+static inline int32 my_atomic_add32(int32 volatile *a, int32 v)
+{
+ return __sync_fetch_and_add(a, v);
+}
+
+static inline int64 my_atomic_add64(int64 volatile *a, int64 v)
+{
+ return __sync_fetch_and_add(a, v);
+}
+
+static inline int32 my_atomic_fas32(int32 volatile *a, int32 v)
+{
+ return __sync_lock_test_and_set(a, v);
+}
+
+static inline int64 my_atomic_fas64(int64 volatile *a, int64 v)
+{
+ return __sync_lock_test_and_set(a, v);
+}
+
+static inline void * my_atomic_fasptr(void * volatile *a, void * v)
+{
+ return __sync_lock_test_and_set(a, v);
+}
+
+static inline int32 my_atomic_load32(int32 volatile *a)
+{
+ return __sync_fetch_and_or(a, 0);
+}
+
+static inline int64 my_atomic_load64(int64 volatile *a)
+{
+ return __sync_fetch_and_or(a, 0);
+}
+
+static inline void* my_atomic_loadptr(void * volatile *a)
+{
+ return __sync_fetch_and_or(a, 0);
+}
+
+static inline void my_atomic_store32(int32 volatile *a, int32 v)
+{
+ (void) __sync_lock_test_and_set(a, v);
+}
+
+static inline void my_atomic_store64(int64 volatile *a, int64 v)
+{
+ (void) __sync_lock_test_and_set(a, v);
+}
+
+static inline void my_atomic_storeptr(void * volatile *a, void *v)
+{
+ (void) __sync_lock_test_and_set(a, v);
+}
+
+#endif /* GCC_SYNC_INCLUDED */
diff --git a/include/atomic/generic-msvc.h b/include/atomic/generic-msvc.h
index 754f0bfa8b4..ff2a5434071 100644
--- a/include/atomic/generic-msvc.h
+++ b/include/atomic/generic-msvc.h
@@ -1,5 +1,7 @@
-/* Copyright (c) 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc.
- Use is subject to license terms.
+#ifndef ATOMIC_MSC_INCLUDED
+#define ATOMIC_MSC_INCLUDED
+
+/* Copyright (c) 2006, 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
@@ -14,122 +16,125 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-#ifndef _atomic_h_cleanup_
-#define _atomic_h_cleanup_ "atomic/generic-msvc.h"
+#include <windows.h>
-/*
- We don't implement anything specific for MY_ATOMIC_MODE_DUMMY, always use
- intrinsics.
- 8 and 16-bit atomics are not implemented, but it can be done if necessary.
-*/
-#undef MY_ATOMIC_HAS_8_16
+static inline int my_atomic_cas32(int32 volatile *a, int32 *cmp, int32 set)
+{
+ int32 initial_cmp= *cmp;
+ int32 initial_a= InterlockedCompareExchange((volatile LONG*)a,
+ set, initial_cmp);
+ int ret= (initial_a == initial_cmp);
+ if (!ret)
+ *cmp= initial_a;
+ return ret;
+}
-#include <windows.h>
-/*
- x86 compilers (both VS2003 or VS2005) never use instrinsics, but generate
- function calls to kernel32 instead, even in the optimized build.
- We force intrinsics as described in MSDN documentation for
- _InterlockedCompareExchange.
-*/
-#ifdef _M_IX86
+static inline int my_atomic_cas64(int64 volatile *a, int64 *cmp, int64 set)
+{
+ int64 initial_cmp= *cmp;
+ int64 initial_a= InterlockedCompareExchange64((volatile LONGLONG*)a,
+ (LONGLONG)set,
+ (LONGLONG)initial_cmp);
+ int ret= (initial_a == initial_cmp);
+ if (!ret)
+ *cmp= initial_a;
+ return ret;
+}
+
+static inline int my_atomic_casptr(void * volatile *a, void **cmp, void *set)
+{
+ void *initial_cmp= *cmp;
+ void *initial_a= InterlockedCompareExchangePointer(a, set, initial_cmp);
+ int ret= (initial_a == initial_cmp);
+ if (!ret)
+ *cmp= initial_a;
+ return ret;
+}
+
+static inline int32 my_atomic_add32(int32 volatile *a, int32 v)
+{
+ return (int32)InterlockedExchangeAdd((volatile LONG*)a, v);
+}
+
+static inline int64 my_atomic_add64(int64 volatile *a, int64 v)
+{
+ return (int64)InterlockedExchangeAdd64((volatile LONGLONG*)a, (LONGLONG)v);
+}
-#if (_MSC_VER >= 1500)
-#include <intrin.h>
-#else
-C_MODE_START
-/*Visual Studio 2003 and earlier do not have prototypes for atomic intrinsics*/
-LONG _InterlockedCompareExchange (LONG volatile *Target, LONG Value, LONG Comp);
-LONGLONG _InterlockedCompareExchange64 (LONGLONG volatile *Target,
- LONGLONG Value, LONGLONG Comp);
-C_MODE_END
-
-#pragma intrinsic(_InterlockedCompareExchange)
-#pragma intrinsic(_InterlockedCompareExchange64)
-#endif
-#define InterlockedCompareExchange _InterlockedCompareExchange
-#define InterlockedCompareExchange64 _InterlockedCompareExchange64
/*
- No need to do something special for InterlockedCompareExchangePointer
- as it is a #define to InterlockedCompareExchange. The same applies to
- InterlockedExchangePointer.
+ According to MSDN:
+
+ Simple reads and writes to properly-aligned 32-bit variables are atomic
+ operations.
+ ...
+ Simple reads and writes to properly aligned 64-bit variables are atomic on
+ 64-bit Windows. Reads and writes to 64-bit values are not guaranteed to be
+ atomic on 32-bit Windows.
+
+ https://msdn.microsoft.com/en-us/library/windows/desktop/ms684122(v=vs.85).aspx
*/
-#endif /*_M_IX86*/
-
-#define MY_ATOMIC_MODE "msvc-intrinsics"
-/* Implement using CAS on WIN32 */
-#define IL_COMP_EXCHG32(X,Y,Z) \
- InterlockedCompareExchange((volatile LONG *)(X),(Y),(Z))
-#define IL_COMP_EXCHG64(X,Y,Z) \
- InterlockedCompareExchange64((volatile LONGLONG *)(X), \
- (LONGLONG)(Y),(LONGLONG)(Z))
-#define IL_COMP_EXCHGptr InterlockedCompareExchangePointer
-
-#define make_atomic_cas_body(S) \
- int ## S initial_cmp= *cmp; \
- int ## S initial_a= IL_COMP_EXCHG ## S (a, set, initial_cmp); \
- if (!(ret= (initial_a == initial_cmp))) *cmp= initial_a;
-
-#ifndef _M_IX86
-/* Use full set of optimised functions on WIN64 */
-#define IL_EXCHG_ADD32(X,Y) \
- InterlockedExchangeAdd((volatile LONG *)(X),(Y))
-#define IL_EXCHG_ADD64(X,Y) \
- InterlockedExchangeAdd64((volatile LONGLONG *)(X),(LONGLONG)(Y))
-#define IL_EXCHG32(X,Y) \
- InterlockedExchange((volatile LONG *)(X),(Y))
-#define IL_EXCHG64(X,Y) \
- InterlockedExchange64((volatile LONGLONG *)(X),(LONGLONG)(Y))
-#define IL_EXCHGptr InterlockedExchangePointer
-
-#define make_atomic_add_body(S) \
- v= IL_EXCHG_ADD ## S (a, v)
-#define make_atomic_swap_body(S) \
- v= IL_EXCHG ## S (a, v)
-#define make_atomic_load_body(S) \
- ret= 0; /* avoid compiler warning */ \
- ret= IL_COMP_EXCHG ## S (a, ret, ret);
-#endif
-/*
- my_yield_processor (equivalent of x86 PAUSE instruction) should be used
- to improve performance on hyperthreaded CPUs. Intel recommends to use it in
- spin loops also on non-HT machines to reduce power consumption (see e.g
- http://softwarecommunity.intel.com/articles/eng/2004.htm)
-
- Running benchmarks for spinlocks implemented with InterlockedCompareExchange
- and YieldProcessor shows that much better performance is achieved by calling
- YieldProcessor in a loop - that is, yielding longer. On Intel boxes setting
- loop count in the range 200-300 brought best results.
- */
-#ifndef YIELD_LOOPS
-#define YIELD_LOOPS 200
-#endif
-static __inline int my_yield_processor()
+static inline int32 my_atomic_load32(int32 volatile *a)
{
- int i;
- for(i=0; i<YIELD_LOOPS; i++)
- {
-#if (_MSC_VER <= 1310)
- /* On older compilers YieldProcessor is not available, use inline assembly*/
- __asm { rep nop }
+ int32 value= *a;
+ MemoryBarrier();
+ return value;
+}
+
+static inline int64 my_atomic_load64(int64 volatile *a)
+{
+#ifdef _M_X64
+ int64 value= *a;
+ MemoryBarrier();
+ return value;
#else
- YieldProcessor();
+ return (int64) InterlockedCompareExchange64((volatile LONGLONG *) a, 0, 0);
#endif
- }
- return 1;
}
-#define LF_BACKOFF my_yield_processor()
-#else /* cleanup */
+static inline void* my_atomic_loadptr(void * volatile *a)
+{
+ void *value= *a;
+ MemoryBarrier();
+ return value;
+}
-#undef IL_EXCHG_ADD32
-#undef IL_EXCHG_ADD64
-#undef IL_COMP_EXCHG32
-#undef IL_COMP_EXCHG64
-#undef IL_COMP_EXCHGptr
-#undef IL_EXCHG32
-#undef IL_EXCHG64
-#undef IL_EXCHGptr
+static inline int32 my_atomic_fas32(int32 volatile *a, int32 v)
+{
+ return (int32)InterlockedExchange((volatile LONG*)a, v);
+}
+
+static inline int64 my_atomic_fas64(int64 volatile *a, int64 v)
+{
+ return (int64)InterlockedExchange64((volatile LONGLONG*)a, v);
+}
+static inline void * my_atomic_fasptr(void * volatile *a, void * v)
+{
+ return InterlockedExchangePointer(a, v);
+}
+
+static inline void my_atomic_store32(int32 volatile *a, int32 v)
+{
+ MemoryBarrier();
+ *a= v;
+}
+
+static inline void my_atomic_store64(int64 volatile *a, int64 v)
+{
+#ifdef _M_X64
+ MemoryBarrier();
+ *a= v;
+#else
+ (void) InterlockedExchange64((volatile LONGLONG *) a, v);
#endif
+}
+
+static inline void my_atomic_storeptr(void * volatile *a, void *v)
+{
+ MemoryBarrier();
+ *a= v;
+}
+
+#endif /* ATOMIC_MSC_INCLUDED */
diff --git a/include/atomic/solaris.h b/include/atomic/solaris.h
index cac34040993..b48ab46f4df 100644
--- a/include/atomic/solaris.h
+++ b/include/atomic/solaris.h
@@ -1,4 +1,7 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#ifndef ATOMIC_SOLARIS_INCLUDED
+#define ATOMIC_SOLARIS_INCLUDED
+
+/* Copyright (c) 2008, 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
@@ -13,60 +16,102 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-#ifndef _atomic_h_cleanup_
-#define _atomic_h_cleanup_ "atomic/solaris.h"
-
#include <atomic.h>
-#define MY_ATOMIC_MODE "solaris-atomic"
-
#if defined(__GNUC__)
#define atomic_typeof(T,V) __typeof__(V)
#else
#define atomic_typeof(T,V) T
#endif
-#define uintptr_t void *
-#define atomic_or_ptr_nv(X,Y) (void *)atomic_or_ulong_nv((volatile ulong_t *)X, Y)
-
-#define make_atomic_cas_body(S) \
- atomic_typeof(uint ## S ## _t, *cmp) sav; \
- sav = atomic_cas_ ## S( \
- (volatile uint ## S ## _t *)a, \
- (uint ## S ## _t)*cmp, \
- (uint ## S ## _t)set); \
- if (! (ret= (sav == *cmp))) \
+static inline int my_atomic_cas32(int32 volatile *a, int32 *cmp, int32 set)
+{
+ int ret;
+ atomic_typeof(uint32_t, *cmp) sav;
+ sav= atomic_cas_32((volatile uint32_t *)a, (uint32_t)*cmp, (uint32_t)set);
+ ret= (sav == *cmp);
+ if (!ret)
*cmp= sav;
-
-#define make_atomic_add_body(S) \
- int ## S nv; /* new value */ \
- nv= atomic_add_ ## S ## _nv((volatile uint ## S ## _t *)a, v); \
- v= nv - v
-
-/* ------------------------------------------------------------------------ */
-
-#ifdef MY_ATOMIC_MODE_DUMMY
-
-#define make_atomic_load_body(S) ret= *a
-#define make_atomic_store_body(S) *a= v
-
-#else /* MY_ATOMIC_MODE_DUMMY */
-
-#define make_atomic_load_body(S) \
- ret= atomic_or_ ## S ## _nv((volatile uint ## S ## _t *)a, 0)
-
-#define make_atomic_store_body(S) \
- (void) atomic_swap_ ## S((volatile uint ## S ## _t *)a, (uint ## S ## _t)v)
-
-#endif
-
-#define make_atomic_fas_body(S) \
- v= atomic_swap_ ## S((volatile uint ## S ## _t *)a, (uint ## S ## _t)v)
-
-#else /* cleanup */
-
-#undef uintptr_t
-#undef atomic_or_ptr_nv
-
-#endif
-
+ return ret;
+}
+
+static inline int my_atomic_cas64(int64 volatile *a, int64 *cmp, int64 set)
+{
+ int ret;
+ atomic_typeof(uint64_t, *cmp) sav;
+ sav= atomic_cas_64((volatile uint64_t *)a, (uint64_t)*cmp, (uint64_t)set);
+ ret= (sav == *cmp);
+ if (!ret)
+ *cmp= sav;
+ return ret;
+}
+
+static inline int my_atomic_casptr(void * volatile *a, void **cmp, void *set)
+{
+ int ret;
+ atomic_typeof(void *, *cmp) sav;
+ sav= atomic_cas_ptr((volatile void **)a, (void *)*cmp, (void *)set);
+ ret= (sav == *cmp);
+ if (!ret)
+ *cmp= sav;
+ return ret;
+}
+
+static inline int32 my_atomic_add32(int32 volatile *a, int32 v)
+{
+ int32 nv= atomic_add_32_nv((volatile uint32_t *)a, v);
+ return nv - v;
+}
+
+static inline int64 my_atomic_add64(int64 volatile *a, int64 v)
+{
+ int64 nv= atomic_add_64_nv((volatile uint64_t *)a, v);
+ return nv - v;
+}
+
+static inline int32 my_atomic_fas32(int32 volatile *a, int32 v)
+{
+ return atomic_swap_32((volatile uint32_t *)a, (uint32_t)v);
+}
+
+static inline int64 my_atomic_fas64(int64 volatile *a, int64 v)
+{
+ return atomic_swap_64((volatile uint64_t *)a, (uint64_t)v);
+}
+
+static inline void * my_atomic_fasptr(void * volatile *a, void * v)
+{
+ return atomic_swap_ptr(a, v);
+}
+
+static inline int32 my_atomic_load32(int32 volatile *a)
+{
+ return atomic_or_32_nv((volatile uint32_t *)a, 0);
+}
+
+static inline int64 my_atomic_load64(int64 volatile *a)
+{
+ return atomic_or_64_nv((volatile uint64_t *)a, 0);
+}
+
+static inline void* my_atomic_loadptr(void * volatile *a)
+{
+ return atomic_add_ptr_nv(a, 0);
+}
+
+static inline void my_atomic_store32(int32 volatile *a, int32 v)
+{
+ (void) atomic_swap_32((volatile uint32_t *)a, (uint32_t)v);
+}
+
+static inline void my_atomic_store64(int64 volatile *a, int64 v)
+{
+ (void) atomic_swap_64((volatile uint64_t *)a, (uint64_t)v);
+}
+
+static inline void my_atomic_storeptr(void * volatile *a, void *v)
+{
+ (void) atomic_swap_ptr((volatile void **)a, (void *)v);
+}
+
+#endif /* ATOMIC_SOLARIS_INCLUDED */
diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h
deleted file mode 100644
index 18aa9b65c17..00000000000
--- a/include/atomic/x86-gcc.h
+++ /dev/null
@@ -1,151 +0,0 @@
-#ifndef ATOMIC_X86_GCC_INCLUDED
-#define ATOMIC_X86_GCC_INCLUDED
-
-/* Copyright (c) 2006, 2010, 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 */
-
-/*
- XXX 64-bit atomic operations can be implemented using
- cmpxchg8b, if necessary. Though I've heard that not all 64-bit
- architectures support double-word (128-bit) cas.
-*/
-
-/*
- No special support of 8 and 16 bit operations are implemented here
- currently.
-*/
-#undef MY_ATOMIC_HAS_8_AND_16
-
-#ifdef MY_ATOMIC_MODE_DUMMY
-#define LOCK_prefix ""
-#else
-#define LOCK_prefix "lock"
-#endif
-
-#ifdef __x86_64__
-# ifdef MY_ATOMIC_NO_XADD
-# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix "-no-xadd"
-# else
-# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix
-# endif
-#else
-# ifdef MY_ATOMIC_NO_XADD
-# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix "-no-xadd"
-# else
-# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix
-# endif
-#endif
-
-/* fix -ansi errors while maintaining readability */
-#ifndef asm
-#define asm __asm__
-#endif
-
-#ifndef MY_ATOMIC_NO_XADD
-#define make_atomic_add_body(S) make_atomic_add_body ## S
-#define make_atomic_cas_body(S) make_atomic_cas_body ## S
-#endif
-
-#define make_atomic_add_body32 \
- asm volatile (LOCK_prefix "; xadd %0, %1;" \
- : "+r" (v), "=m" (*a) \
- : "m" (*a) \
- : "memory")
-
-#define make_atomic_cas_body32 \
- __typeof__(*cmp) sav; \
- asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \
- : "=m" (*a), "=a" (sav), "=q" (ret) \
- : "r" (set), "m" (*a), "a" (*cmp) \
- : "memory"); \
- if (!ret) \
- *cmp= sav
-
-#ifdef __x86_64__
-#define make_atomic_add_body64 make_atomic_add_body32
-#define make_atomic_cas_body64 make_atomic_cas_body32
-
-#define make_atomic_fas_body(S) \
- asm volatile ("xchg %0, %1;" \
- : "+r" (v), "=m" (*a) \
- : "m" (*a) \
- : "memory")
-
-/*
- Actually 32/64-bit reads/writes are always atomic on x86_64,
- nonetheless issue memory barriers as appropriate.
-*/
-#define make_atomic_load_body(S) \
- /* Serialize prior load and store operations. */ \
- asm volatile ("mfence" ::: "memory"); \
- ret= *a; \
- /* Prevent compiler from reordering instructions. */ \
- asm volatile ("" ::: "memory")
-#define make_atomic_store_body(S) \
- asm volatile ("; xchg %0, %1;" \
- : "=m" (*a), "+r" (v) \
- : "m" (*a) \
- : "memory")
-
-#else
-/*
- Use default implementations of 64-bit operations since we solved
- the 64-bit problem on 32-bit platforms for CAS, no need to solve it
- once more for ADD, LOAD, STORE and FAS as well.
- Since we already added add32 support, we need to define add64
- here, but we haven't defined fas, load and store at all, so
- we can fallback on default implementations.
-*/
-#define make_atomic_add_body64 \
- int64 tmp=*a; \
- while (!my_atomic_cas64(a, &tmp, tmp+v)) ; \
- v=tmp;
-
-/*
- On some platforms (e.g. Mac OS X and Solaris) the ebx register
- is held as a pointer to the global offset table. Thus we're not
- allowed to use the b-register on those platforms when compiling
- PIC code, to avoid this we push ebx and pop ebx. The new value
- is copied directly from memory to avoid problems with a implicit
- manipulation of the stack pointer by the push.
-
- cmpxchg8b works on both 32-bit platforms and 64-bit platforms but
- the code here is only used on 32-bit platforms, on 64-bit
- platforms the much simpler make_atomic_cas_body32 will work
- fine.
-*/
-#define make_atomic_cas_body64 \
- asm volatile ("push %%ebx;" \
- "movl (%%ecx), %%ebx;" \
- "movl 4(%%ecx), %%ecx;" \
- LOCK_prefix "; cmpxchg8b (%%esi);" \
- "setz %2; pop %%ebx" \
- : "+S" (a), "+A" (*cmp), "=c" (ret) \
- : "c" (&set) \
- : "memory", "esp")
-#endif
-
-/*
- The implementation of make_atomic_cas_body32 is adaptable to
- the OS word size, so on 64-bit platforms it will automatically
- adapt to 64-bits and so it will work also on 64-bit platforms
-*/
-#define make_atomic_cas_bodyptr make_atomic_cas_body32
-
-#ifdef MY_ATOMIC_MODE_DUMMY
-#define make_atomic_load_body(S) ret=*a
-#define make_atomic_store_body(S) *a=v
-#endif
-#endif /* ATOMIC_X86_GCC_INCLUDED */
diff --git a/include/hash.h b/include/hash.h
index 1c30e973f92..fd64bf4c5df 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -19,7 +19,6 @@
#ifndef _hash_h
#define _hash_h
-#include "my_global.h" /* uchar */
#include "my_sys.h" /* DYNAMIC_ARRAY */
/*
diff --git a/include/ilist.h b/include/ilist.h
index ed1d978a0d6..f0d15054ab8 100644
--- a/include/ilist.h
+++ b/include/ilist.h
@@ -56,7 +56,7 @@ public:
typedef T *pointer;
typedef const T *const_pointer;
typedef Iterator iterator;
- typedef const Iterator const_iterator;
+ typedef Iterator const_iterator; /* FIXME */
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const iterator> const_reverse_iterator;
@@ -121,6 +121,8 @@ public:
reference front() { return *begin(); }
reference back() { return *--end(); }
+ const_reference front() const { return *begin(); }
+ const_reference back() const { return *--end(); }
iterator begin() { return iterator(sentinel_.next); }
const_iterator begin() const
diff --git a/include/json_lib.h b/include/json_lib.h
index e9c10906502..fed85b516d9 100644
--- a/include/json_lib.h
+++ b/include/json_lib.h
@@ -312,7 +312,7 @@ typedef const int *json_level_t;
int json_skip_to_level(json_engine_t *j, int level);
/*
- json_skip_level() works as above with just current structre.
+ json_skip_level() works as above with just current structure.
So it gets to the end of the current JSON array or object.
*/
#define json_skip_level(json_engine) \
diff --git a/include/lf.h b/include/lf.h
index d2538385d6f..10a60c5c949 100644
--- a/include/lf.h
+++ b/include/lf.h
@@ -17,6 +17,7 @@
#define INCLUDE_LF_INCLUDED
#include <my_atomic.h>
+#include <my_cpu.h>
C_MODE_START
@@ -64,7 +65,6 @@ typedef struct {
typedef struct {
void * volatile pin[LF_PINBOX_PINS];
LF_PINBOX *pinbox;
- void **stack_ends_here;
void *purgatory;
uint32 purgatory_count;
uint32 volatile link;
diff --git a/include/m_ctype.h b/include/m_ctype.h
index dc7b77a5756..1cdff1f54cc 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -21,7 +21,6 @@
#define _m_ctype_h
#include <my_attribute.h>
-#include "my_global.h" /* uint16, uchar */
enum loglevel {
ERROR_LEVEL= 0,
@@ -49,7 +48,7 @@ extern "C" {
/*
On i386 we store Unicode->CS conversion tables for
some character sets using Big-endian order,
- to copy two bytes at onces.
+ to copy two bytes at once.
This gives some performance improvement.
*/
#ifdef __i386__
@@ -377,7 +376,7 @@ typedef size_t (*my_charset_conv_case)(CHARSET_INFO *,
A structure to return the statistics of a native string copying,
when no Unicode conversion is involved.
- The stucture is OK to be unitialized before calling a copying routine.
+ The structure is OK to be uninitialized before calling a copying routine.
A copying routine must populate the structure as follows:
- m_source_end_pos must be set by to a non-NULL value
in the range of the input string.
@@ -426,7 +425,7 @@ struct my_charset_handler_st
my_charset_conv_case caseup;
my_charset_conv_case casedn;
- /* Charset dependant snprintf() */
+ /* Charset dependent snprintf() */
size_t (*snprintf)(CHARSET_INFO *, char *to, size_t n,
const char *fmt,
...) ATTRIBUTE_FORMAT_FPTR(printf, 4, 5);
@@ -518,7 +517,7 @@ struct my_charset_handler_st
/**
Write a character to the target string, using its native code.
For Unicode character sets (utf8, ucs2, utf16, utf16le, utf32, filename)
- native codes are equvalent to Unicode code points.
+ native codes are equivalent to Unicode code points.
For 8bit character sets the native code is just the byte value.
For Asian characters sets:
- MB1 native code is just the byte value (e.g. on the ASCII range)
@@ -920,7 +919,7 @@ typedef struct
void my_string_metadata_get(MY_STRING_METADATA *metadata,
CHARSET_INFO *cs, const char *str, size_t len);
-uint my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong len);
+uint my_string_repertoire(CHARSET_INFO *cs, const char *str, size_t len);
my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
uint my_charset_repertoire(CHARSET_INFO *cs);
@@ -956,9 +955,9 @@ uint32 my_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
Protocol::store_warning() uses this to escape control
and non-convertable characters.
*/
-uint32 my_convert_using_func(char *to, uint32 to_length, CHARSET_INFO *to_cs,
+uint32 my_convert_using_func(char *to, size_t to_length, CHARSET_INFO *to_cs,
my_charset_conv_wc_mb mb_wc,
- const char *from, uint32 from_length,
+ const char *from, size_t from_length,
CHARSET_INFO *from_cs,
my_charset_conv_mb_wc wc_mb,
uint *errors);
@@ -967,7 +966,7 @@ uint32 my_convert_using_func(char *to, uint32 to_length, CHARSET_INFO *to_cs,
Bad byte sequences as well as characters that cannot be
encoded in the destination character set are replaced to '?'.
Not more than "nchars" characters are copied.
- Conversion statistics is returnd in "status" and is set as follows:
+ Conversion statistics is returned in "status" and is set as follows:
- status->m_native_copy_status.m_source_end_pos - to the position
between (src) and (src+src_length), where the function stopped reading
the source string.
@@ -1096,7 +1095,7 @@ my_well_formed_length(CHARSET_INFO *cs, const char *b, const char *e,
MY_STRCOPY_STATUS status;
(void) cs->cset->well_formed_char_length(cs, b, e, nchars, &status);
*error= status.m_well_formed_error_pos == NULL ? 0 : 1;
- return status.m_source_end_pos - b;
+ return (size_t) (status.m_source_end_pos - b);
}
diff --git a/include/m_string.h b/include/m_string.h
index 2f609d5e29f..e967f140dc4 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -14,15 +14,14 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-/* There may be prolems include all of theese. Try to test in
- configure with ones are needed? */
+/* There may be problems included in all of these. Try to test in
+ configure which ones are needed? */
/* This is needed for the definitions of strchr... on solaris */
#ifndef _m_string_h
#define _m_string_h
-#include "my_global.h" /* HAVE_* */
#include "my_decimal_limits.h"
#ifndef __USE_GNU
@@ -100,7 +99,7 @@ extern char *strmake(char *dst,const char *src,size_t length);
#define strmake_buf(D,S) strmake(D, S, sizeof(D) - 1)
#else
#define strmake_buf(D,S) ({ \
- compile_time_assert(sizeof(D) != sizeof(char*)); \
+ typeof (D) __x __attribute__((unused)) = { 2 }; \
strmake(D, S, sizeof(D) - 1); \
})
#endif
@@ -202,12 +201,8 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
#define STRING_WITH_LEN(X) (X), ((size_t) (sizeof(X) - 1))
#define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1))
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
+#define LEX_STRING_WITH_LEN(X) (X).str, (X).length
-struct st_mysql_const_lex_string
-{
- const char *str;
- size_t length;
-};
typedef struct st_mysql_const_lex_string LEX_CSTRING;
/* A variant with const and unsigned */
@@ -218,11 +213,17 @@ struct st_mysql_const_unsigned_lex_string
};
typedef struct st_mysql_const_unsigned_lex_string LEX_CUSTRING;
-static inline void lex_string_set(LEX_STRING *lex_str, const char *c_str)
+static inline void lex_string_set(LEX_CSTRING *lex_str, const char *c_str)
{
- lex_str->str= (char *) c_str;
+ lex_str->str= c_str;
lex_str->length= strlen(c_str);
}
+static inline void lex_string_set3(LEX_CSTRING *lex_str, const char *c_str,
+ size_t len)
+{
+ lex_str->str= c_str;
+ lex_str->length= len;
+}
#ifdef __cplusplus
static inline char *safe_str(char *str)
diff --git a/include/maria.h b/include/maria.h
index c53ae472c46..880b7367c0b 100644
--- a/include/maria.h
+++ b/include/maria.h
@@ -304,7 +304,7 @@ extern int maria_rsame(MARIA_HA *file, uchar *record, int inx);
extern int maria_rsame_with_pos(MARIA_HA *file, uchar *record,
int inx, MARIA_RECORD_POS pos);
extern int maria_update(MARIA_HA *file, const uchar *old,
- uchar *new_record);
+ const uchar *new_record);
extern int maria_write(MARIA_HA *file, uchar *buff);
extern MARIA_RECORD_POS maria_position(MARIA_HA *file);
extern int maria_status(MARIA_HA *info, MARIA_INFO *x, uint flag);
@@ -391,7 +391,7 @@ my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows, ulonglong key_map,
int maria_init_bulk_insert(MARIA_HA *info, size_t cache_size, ha_rows rows);
void maria_flush_bulk_insert(MARIA_HA *info, uint inx);
-void maria_end_bulk_insert(MARIA_HA *info);
+int maria_end_bulk_insert(MARIA_HA *info, my_bool abort);
int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves);
void maria_versioning(MARIA_HA *info, my_bool versioning);
void maria_ignore_trids(MARIA_HA *info);
diff --git a/include/my_alloc.h b/include/my_alloc.h
index 52c04fe1b7d..9b0aad26956 100644
--- a/include/my_alloc.h
+++ b/include/my_alloc.h
@@ -43,6 +43,7 @@ typedef struct st_mem_root
/* if block have less memory it will be put in 'used' list */
size_t min_malloc;
size_t block_size; /* initial block size */
+ size_t total_alloc;
unsigned int block_num; /* allocated blocks counter */
/*
first free block in queue test counter (if it exceed
@@ -51,6 +52,7 @@ typedef struct st_mem_root
unsigned int first_block_usage;
void (*error_handler)(void);
+ const char *name;
} MEM_ROOT;
#ifdef __cplusplus
diff --git a/include/my_atomic.h b/include/my_atomic.h
index aa5c617e593..19983daed04 100644
--- a/include/my_atomic.h
+++ b/include/my_atomic.h
@@ -100,302 +100,39 @@
acquire-release operation, and additionally has
sequentially-consistent operation ordering.
- 8- and 16-bit atomics aren't implemented for windows (see generic-msvc.h),
- but can be added, if necessary.
+ We choose implementation as follows: on Windows using Visual C++ the native
+ implementation should be preferable. When using gcc we prefer the Solaris
+ implementation before the gcc because of stability preference, we choose gcc
+ builtins if available.
*/
-#define intptr void *
-/**
- Currently we don't support 8-bit and 16-bit operations.
- It can be added later if needed.
-*/
-#undef MY_ATOMIC_HAS_8_16
-
-/*
- We choose implementation as follows:
- ------------------------------------
- On Windows using Visual C++ the native implementation should be
- preferrable. When using gcc we prefer the Solaris implementation
- before the gcc because of stability preference, we choose gcc
- builtins if available, otherwise we choose the somewhat broken
- native x86 implementation. If neither Visual C++ or gcc we still
- choose the Solaris implementation on Solaris (mainly for SunStudio
- compilers).
-*/
#if defined(_MSC_VER)
#include "atomic/generic-msvc.h"
#elif defined(HAVE_SOLARIS_ATOMIC)
#include "atomic/solaris.h"
-#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+#elif defined(HAVE_GCC_C11_ATOMICS)
#include "atomic/gcc_builtins.h"
-#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
-#include "atomic/x86-gcc.h"
-#endif
-
-
-#ifndef make_atomic_cas_body
-/* nolock.h was not able to generate even a CAS function, fall back */
-#error atomic ops for this platform are not implemented
-#endif
-
-/* define missing functions by using the already generated ones */
-#ifndef make_atomic_add_body
-#define make_atomic_add_body(S) \
- int ## S tmp=*a; \
- while (!my_atomic_cas ## S(a, &tmp, tmp+v)) ; \
- v=tmp;
-#endif
-#ifndef make_atomic_fas_body
-#define make_atomic_fas_body(S) \
- int ## S tmp=*a; \
- while (!my_atomic_cas ## S(a, &tmp, v)) ; \
- v=tmp;
-#endif
-#ifndef make_atomic_load_body
-#define make_atomic_load_body(S) \
- ret= 0; /* avoid compiler warning */ \
- (void)(my_atomic_cas ## S(a, &ret, ret));
-#endif
-#ifndef make_atomic_store_body
-#define make_atomic_store_body(S) \
- (void)(my_atomic_fas ## S (a, v));
-#endif
-
-/*
- transparent_union doesn't work in g++
- Bug ?
-
- Darwin's gcc doesn't want to put pointers in a transparent_union
- when built with -arch ppc64. Complains:
- warning: 'transparent_union' attribute ignored
-*/
-#if defined(__GNUC__) && !defined(__cplusplus) && \
- ! (defined(__APPLE__) && (defined(_ARCH_PPC64) ||defined (_ARCH_PPC)))
-/*
- we want to be able to use my_atomic_xxx functions with
- both signed and unsigned integers. But gcc will issue a warning
- "passing arg N of `my_atomic_XXX' as [un]signed due to prototype"
- if the signedness of the argument doesn't match the prototype, or
- "pointer targets in passing argument N of my_atomic_XXX differ in signedness"
- if int* is used where uint* is expected (or vice versa).
- Let's shut these warnings up
-*/
-#define make_transparent_unions(S) \
- typedef union { \
- int ## S i; \
- uint ## S u; \
- } U_ ## S __attribute__ ((transparent_union)); \
- typedef union { \
- int ## S volatile *i; \
- uint ## S volatile *u; \
- } Uv_ ## S __attribute__ ((transparent_union));
-#define uintptr intptr
-make_transparent_unions(8)
-make_transparent_unions(16)
-make_transparent_unions(32)
-make_transparent_unions(64)
-make_transparent_unions(ptr)
-#undef uintptr
-#undef make_transparent_unions
-#define a U_a.i
-#define cmp U_cmp.i
-#define v U_v.i
-#define set U_set.i
-#else
-#define U_8 int8
-#define U_16 int16
-#define U_32 int32
-#define U_64 int64
-#define U_ptr intptr
-#define Uv_8 int8
-#define Uv_16 int16
-#define Uv_32 int32
-#define Uv_64 int64
-#define Uv_ptr intptr
-#define U_a volatile *a
-#define U_cmp *cmp
-#define U_v v
-#define U_set set
-#endif /* __GCC__ transparent_union magic */
-
-#define make_atomic_cas(S) \
-static inline int my_atomic_cas ## S(Uv_ ## S U_a, \
- Uv_ ## S U_cmp, U_ ## S U_set) \
-{ \
- int8 ret; \
- make_atomic_cas_body(S); \
- return ret; \
-}
-
-#define make_atomic_add(S) \
-static inline int ## S my_atomic_add ## S( \
- Uv_ ## S U_a, U_ ## S U_v) \
-{ \
- make_atomic_add_body(S); \
- return v; \
-}
-
-#define make_atomic_fas(S) \
-static inline int ## S my_atomic_fas ## S( \
- Uv_ ## S U_a, U_ ## S U_v) \
-{ \
- make_atomic_fas_body(S); \
- return v; \
-}
-
-#define make_atomic_load(S) \
-static inline int ## S my_atomic_load ## S(Uv_ ## S U_a) \
-{ \
- int ## S ret; \
- make_atomic_load_body(S); \
- return ret; \
-}
-
-#define make_atomic_store(S) \
-static inline void my_atomic_store ## S( \
- Uv_ ## S U_a, U_ ## S U_v) \
-{ \
- make_atomic_store_body(S); \
-}
-
-#ifdef MY_ATOMIC_HAS_8_16
-make_atomic_cas(8)
-make_atomic_cas(16)
-#endif
-make_atomic_cas(32)
-make_atomic_cas(64)
-make_atomic_cas(ptr)
-
-#ifdef MY_ATOMIC_HAS_8_16
-make_atomic_add(8)
-make_atomic_add(16)
-#endif
-make_atomic_add(32)
-make_atomic_add(64)
-
-#ifdef MY_ATOMIC_HAS_8_16
-make_atomic_load(8)
-make_atomic_load(16)
-#endif
-make_atomic_load(32)
-make_atomic_load(64)
-make_atomic_load(ptr)
-
-#ifdef MY_ATOMIC_HAS_8_16
-make_atomic_fas(8)
-make_atomic_fas(16)
-#endif
-make_atomic_fas(32)
-make_atomic_fas(64)
-make_atomic_fas(ptr)
-
-#ifdef MY_ATOMIC_HAS_8_16
-make_atomic_store(8)
-make_atomic_store(16)
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+#include "atomic/gcc_sync.h"
#endif
-make_atomic_store(32)
-make_atomic_store(64)
-make_atomic_store(ptr)
#if SIZEOF_LONG == 4
#define my_atomic_addlong(A,B) my_atomic_add32((int32*) (A), (B))
#define my_atomic_loadlong(A) my_atomic_load32((int32*) (A))
+#define my_atomic_loadlong_explicit(A,O) my_atomic_load32_explicit((int32*) (A), (O))
#define my_atomic_storelong(A,B) my_atomic_store32((int32*) (A), (B))
#define my_atomic_faslong(A,B) my_atomic_fas32((int32*) (A), (B))
#define my_atomic_caslong(A,B,C) my_atomic_cas32((int32*) (A), (int32*) (B), (C))
#else
#define my_atomic_addlong(A,B) my_atomic_add64((int64*) (A), (B))
#define my_atomic_loadlong(A) my_atomic_load64((int64*) (A))
+#define my_atomic_loadlong_explicit(A,O) my_atomic_load64_explicit((int64*) (A), (O))
#define my_atomic_storelong(A,B) my_atomic_store64((int64*) (A), (B))
#define my_atomic_faslong(A,B) my_atomic_fas64((int64*) (A), (B))
#define my_atomic_caslong(A,B,C) my_atomic_cas64((int64*) (A), (int64*) (B), (C))
#endif
-#ifdef _atomic_h_cleanup_
-#include _atomic_h_cleanup_
-#undef _atomic_h_cleanup_
-#endif
-
-#undef U_8
-#undef U_16
-#undef U_32
-#undef U_64
-#undef U_ptr
-#undef Uv_8
-#undef Uv_16
-#undef Uv_32
-#undef Uv_64
-#undef Uv_ptr
-#undef a
-#undef cmp
-#undef v
-#undef set
-#undef U_a
-#undef U_cmp
-#undef U_v
-#undef U_set
-#undef make_atomic_add
-#undef make_atomic_cas
-#undef make_atomic_load
-#undef make_atomic_store
-#undef make_atomic_fas
-#undef make_atomic_add_body
-#undef make_atomic_cas_body
-#undef make_atomic_load_body
-#undef make_atomic_store_body
-#undef make_atomic_fas_body
-#undef intptr
-
-/*
- the macro below defines (as an expression) the code that
- will be run in spin-loops. Intel manuals recummend to have PAUSE there.
- It is expected to be defined in include/atomic/ *.h files
-*/
-#ifndef LF_BACKOFF
-#define LF_BACKOFF (1)
-#endif
-
-#define MY_ATOMIC_OK 0
-#define MY_ATOMIC_NOT_1CPU 1
-extern int my_atomic_initialize();
-
-#ifdef HAVE_GCC_C11_ATOMICS
-#define MY_MEMORY_ORDER_RELAXED __ATOMIC_RELAXED
-#define MY_MEMORY_ORDER_CONSUME __ATOMIC_CONSUME
-#define MY_MEMORY_ORDER_ACQUIRE __ATOMIC_ACQUIRE
-#define MY_MEMORY_ORDER_RELEASE __ATOMIC_RELEASE
-#define MY_MEMORY_ORDER_ACQ_REL __ATOMIC_ACQ_REL
-#define MY_MEMORY_ORDER_SEQ_CST __ATOMIC_SEQ_CST
-
-#define my_atomic_store32_explicit(P, D, O) __atomic_store_n((P), (D), (O))
-#define my_atomic_store64_explicit(P, D, O) __atomic_store_n((P), (D), (O))
-#define my_atomic_storeptr_explicit(P, D, O) __atomic_store_n((P), (D), (O))
-
-#define my_atomic_load32_explicit(P, O) __atomic_load_n((P), (O))
-#define my_atomic_load64_explicit(P, O) __atomic_load_n((P), (O))
-#define my_atomic_loadptr_explicit(P, O) __atomic_load_n((P), (O))
-
-#define my_atomic_fas32_explicit(P, D, O) __atomic_exchange_n((P), (D), (O))
-#define my_atomic_fas64_explicit(P, D, O) __atomic_exchange_n((P), (D), (O))
-#define my_atomic_fasptr_explicit(P, D, O) __atomic_exchange_n((P), (D), (O))
-
-#define my_atomic_add32_explicit(P, A, O) __atomic_fetch_add((P), (A), (O))
-#define my_atomic_add64_explicit(P, A, O) __atomic_fetch_add((P), (A), (O))
-
-#define my_atomic_cas32_weak_explicit(P, E, D, S, F) \
- __atomic_compare_exchange_n((P), (E), (D), true, (S), (F))
-#define my_atomic_cas64_weak_explicit(P, E, D, S, F) \
- __atomic_compare_exchange_n((P), (E), (D), true, (S), (F))
-#define my_atomic_casptr_weak_explicit(P, E, D, S, F) \
- __atomic_compare_exchange_n((P), (E), (D), true, (S), (F))
-
-#define my_atomic_cas32_strong_explicit(P, E, D, S, F) \
- __atomic_compare_exchange_n((P), (E), (D), false, (S), (F))
-#define my_atomic_cas64_strong_explicit(P, E, D, S, F) \
- __atomic_compare_exchange_n((P), (E), (D), false, (S), (F))
-#define my_atomic_casptr_strong_explicit(P, E, D, S, F) \
- __atomic_compare_exchange_n((P), (E), (D), false, (S), (F))
-#else
+#ifndef MY_MEMORY_ORDER_SEQ_CST
#define MY_MEMORY_ORDER_RELAXED
#define MY_MEMORY_ORDER_CONSUME
#define MY_MEMORY_ORDER_ACQUIRE
diff --git a/include/my_attribute.h b/include/my_attribute.h
index 0bdec175fb4..c8e980702b6 100644
--- a/include/my_attribute.h
+++ b/include/my_attribute.h
@@ -34,9 +34,9 @@
compilation warnings.
*/
#ifndef __attribute__
-# if !defined(__GNUC__)
+# if !defined(__GNUC__) && !defined(__clang__)
# define __attribute__(A)
-# else
+# elif defined(__GNUC__)
# ifndef GCC_VERSION
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
# endif
diff --git a/include/my_base.h b/include/my_base.h
index b7cd1bbd0de..4c5b00649cc 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -20,7 +20,6 @@
#ifndef _my_base_h
#define _my_base_h
-#include <my_global.h>
#include <my_dir.h> /* This includes types */
#include <my_sys.h>
#include <m_string.h>
@@ -48,6 +47,8 @@
#define HA_OPEN_INTERNAL_TABLE 512U
#define HA_OPEN_NO_PSI_CALL 1024U /* Don't call/connect PSI */
#define HA_OPEN_MERGE_TABLE 2048U
+#define HA_OPEN_FOR_CREATE 4096U
+
/*
Allow opening even if table is incompatible as this is for ALTER TABLE which
will fix the table structure.
@@ -201,6 +202,13 @@ enum ha_extra_function {
HA_EXTRA_DETACH_CHILD,
/* Inform handler we will force a close as part of flush */
HA_EXTRA_PREPARE_FOR_FORCED_CLOSE,
+ /* Inform handler that we will do an alter table */
+ HA_EXTRA_PREPARE_FOR_ALTER_TABLE,
+ /*
+ Used in ha_partition::handle_ordered_index_scan() to inform engine
+ that we are starting an ordered index scan. Needed by Spider
+ */
+ HA_EXTRA_STARTING_ORDERED_INDEX_SCAN,
/** Start writing rows during ALTER TABLE...ALGORITHM=COPY. */
HA_EXTRA_BEGIN_ALTER_COPY,
/** Finish writing rows during ALTER TABLE...ALGORITHM=COPY. */
@@ -262,7 +270,7 @@ enum ha_base_keytype {
#define HA_UNIQUE_CHECK 256U /* Check the key for uniqueness */
#define HA_SPATIAL 1024U /* For spatial search */
#define HA_NULL_ARE_EQUAL 2048U /* NULL in key are cmp as equal */
-#define HA_GENERATED_KEY 8192U /* Automaticly generated key */
+#define HA_GENERATED_KEY 8192U /* Automatically generated key */
/* The combination of the above can be used for key type comparison. */
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
@@ -280,7 +288,8 @@ enum ha_base_keytype {
This flag can be calculated -- it's based on key lengths comparison.
*/
#define HA_KEY_HAS_PART_KEY_SEG 65536
-
+/* Internal Flag Can be calcaluted */
+#define HA_INVISIBLE_KEY 2<<18
/* Automatic bits in key-flag */
#define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */
@@ -357,6 +366,7 @@ enum ha_base_keytype {
#define HA_CREATE_RELIES_ON_SQL_LAYER 128U
#define HA_CREATE_INTERNAL_TABLE 256U
#define HA_PRESERVE_INSERT_ORDER 512U
+#define HA_CREATE_NO_ROLLBACK 1024U
/* Flags used by start_bulk_insert */
@@ -410,6 +420,10 @@ enum ha_base_keytype {
when only HA_STATUS_VARIABLE but it won't be used.
*/
#define HA_STATUS_VARIABLE_EXTRA 128U
+/*
+ Treat empty table as empty (ignore HA_STATUS_TIME hack).
+*/
+#define HA_STATUS_OPEN 256U
/*
Errorcodes given by handler functions
@@ -506,7 +520,9 @@ enum ha_base_keytype {
#define HA_ERR_DECRYPTION_FAILED 192 /* Table encrypted but decypt failed */
#define HA_ERR_FK_DEPTH_EXCEEDED 193 /* FK cascade depth exceeded */
#define HA_ERR_TABLESPACE_MISSING 194 /* Missing Tablespace */
-#define HA_ERR_LAST 194 /* Copy of last error nr * */
+#define HA_ERR_SEQUENCE_INVALID_DATA 195
+#define HA_ERR_SEQUENCE_RUN_OUT 196
+#define HA_ERR_LAST 196 /* Copy of last error nr * */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
@@ -632,7 +648,7 @@ typedef ulong ha_rows;
#define HA_OFFSET_ERROR (~ (my_off_t) 0)
#define HA_ROWS_MAX HA_POS_ERROR
-#if SYSTEM_SIZEOF_OFF_T == 4
+#if SIZEOF_OFF_T == 4
#define MAX_FILE_SIZE INT_MAX32
#else
#define MAX_FILE_SIZE LONGLONG_MAX
diff --git a/include/my_bit.h b/include/my_bit.h
index 4db6efcac8c..74469b5b899 100644
--- a/include/my_bit.h
+++ b/include/my_bit.h
@@ -17,8 +17,6 @@
#ifndef MY_BIT_INCLUDED
#define MY_BIT_INCLUDED
-#include <my_global.h>
-
/*
Some useful bit functions
*/
@@ -47,7 +45,7 @@ Count bits in 32bit integer
http://graphics.stanford.edu/~seander/bithacks.html
under "Counting bits set, in parallel"
- (Orignal code public domain).
+ (Original code public domain).
*/
static inline uint my_count_bits_uint32(uint32 v)
{
@@ -79,7 +77,7 @@ static inline uint my_count_bits(ulonglong x)
NOTES
Algorithm by Sean Anderson, according to:
http://graphics.stanford.edu/~seander/bithacks.html
- (Orignal code public domain)
+ (Original code public domain)
Comments shows how this works with 01100000000000000000000000001011
*/
@@ -119,9 +117,9 @@ static inline uint32 my_reverse_bits(uint32 key)
a number with the n lowest bits set
an overflow-safe version of (1 << n) - 1
*/
-static inline uint32 my_set_bits(int n)
+static inline uint64 my_set_bits(int n)
{
- return (((1UL << (n - 1)) - 1) << 1) | 1;
+ return (((1ULL << (n - 1)) - 1) << 1) | 1;
}
C_MODE_END
diff --git a/include/my_bitmap.h b/include/my_bitmap.h
index 9cd8b0ca1e8..1b0fbe40d2e 100644
--- a/include/my_bitmap.h
+++ b/include/my_bitmap.h
@@ -45,6 +45,8 @@ extern "C" {
/* compatibility functions */
#define bitmap_init(A,B,C,D) my_bitmap_init(A,B,C,D)
#define bitmap_free(A) my_bitmap_free(A)
+/* Reset memory. Faster then doing a full bzero */
+#define my_bitmap_clear(A) ((A)->bitmap= 0)
extern void create_last_word_mask(MY_BITMAP *map);
extern my_bool my_bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
diff --git a/include/my_compare.h b/include/my_compare.h
index b973664372a..bd1a7bd1f34 100644
--- a/include/my_compare.h
+++ b/include/my_compare.h
@@ -84,7 +84,7 @@ typedef struct st_HA_KEYSEG /* Key-portion */
#define store_key_length_inc(key,length) \
{ if ((length) < 255) \
- { *(key)++= (length); } \
+ { *(key)++= (uchar)(length); } \
else \
{ *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
}
@@ -109,8 +109,8 @@ static inline void set_rec_bits(uint16 bits, uchar *ptr, uchar ofs, uint len)
#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
-extern int ha_compare_text(CHARSET_INFO *, const uchar *, uint,
- const uchar *, uint , my_bool);
+extern int ha_compare_text(CHARSET_INFO *, const uchar *, size_t,
+ const uchar *, size_t , my_bool);
extern int ha_key_cmp(HA_KEYSEG *keyseg, const uchar *a,
const uchar *b, uint key_length, uint nextflag,
uint *diff_pos);
diff --git a/include/my_compiler.h b/include/my_compiler.h
index faffd852b5d..bee92078767 100644
--- a/include/my_compiler.h
+++ b/include/my_compiler.h
@@ -25,8 +25,6 @@
specific to a target compiler.
*/
-#include <my_global.h> /* stddef.h offsetof */
-
/**
Compiler-dependent internal convenience macros.
*/
diff --git a/include/my_cpu.h b/include/my_cpu.h
index ebabe6c7202..0e37eafe60e 100644
--- a/include/my_cpu.h
+++ b/include/my_cpu.h
@@ -1,3 +1,5 @@
+#ifndef MY_CPU_INCLUDED
+#define MY_CPU_INCLUDED
/* Copyright (c) 2013, MariaDB foundation Ab and SkySQL
This program is free software; you can redistribute it and/or modify
@@ -21,17 +23,18 @@
The defines are the same ones used by the linux kernel
*/
-#if defined(__powerpc__)
+#ifdef _ARCH_PWR8
+#include <sys/platform/ppc.h>
/* Very low priority */
-#define HMT_very_low() asm volatile("or 31,31,31")
+#define HMT_very_low() __ppc_set_ppr_very_low()
/* Low priority */
-#define HMT_low() asm volatile("or 1,1,1")
+#define HMT_low() __ppc_set_ppr_low()
/* Medium low priority */
-#define HMT_medium_low() asm volatile("or 6,6,6")
+#define HMT_medium_low() __ppc_set_ppr_med_low()
/* Medium priority */
-#define HMT_medium() asm volatile("or 2,2,2")
+#define HMT_medium() __ppc_set_ppr_med()
/* Medium high priority */
-#define HMT_medium_high() asm volatile("or 5,5,5")
+#define HMT_medium_high() __ppc_set_ppr_med_high()
/* High priority */
#define HMT_high() asm volatile("or 3,3,3")
#else
@@ -42,3 +45,86 @@
#define HMT_medium_high()
#define HMT_high()
#endif
+
+#if defined __i386__ || defined __x86_64__ || defined _WIN32
+# define HAVE_PAUSE_INSTRUCTION /* added in Intel Pentium 4 */
+#endif
+
+static inline void MY_RELAX_CPU(void)
+{
+#ifdef _WIN32
+ /*
+ In the Win32 API, the x86 PAUSE instruction is executed by calling
+ the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
+ independent way by using YieldProcessor.
+ */
+ YieldProcessor();
+#elif defined HAVE_PAUSE_INSTRUCTION
+ /*
+ According to the gcc info page, asm volatile means that the
+ instruction has important side-effects and must not be removed.
+ Also asm volatile may trigger a memory barrier (spilling all registers
+ to memory).
+ */
+#ifdef __SUNPRO_CC
+ asm ("pause" );
+#else
+ __asm__ __volatile__ ("pause");
+#endif
+#elif defined(_ARCH_PWR8)
+ __ppc_get_timebase();
+#else
+ int32 var, oldval = 0;
+ my_atomic_cas32_strong_explicit(&var, &oldval, 1, MY_MEMORY_ORDER_RELAXED,
+ MY_MEMORY_ORDER_RELAXED);
+#endif
+}
+
+
+#ifdef HAVE_PAUSE_INSTRUCTION
+# ifdef __cplusplus
+extern "C" {
+# endif
+extern unsigned my_cpu_relax_multiplier;
+void my_cpu_init(void);
+# ifdef __cplusplus
+}
+# endif
+#else
+# define my_cpu_relax_multiplier 200
+# define my_cpu_init() /* nothing */
+#endif
+
+/*
+ LF_BACKOFF should be used to improve performance on hyperthreaded CPUs. Intel
+ recommends to use it in spin loops also on non-HT machines to reduce power
+ consumption (see e.g http://softwarecommunity.intel.com/articles/eng/2004.htm)
+
+ Running benchmarks for spinlocks implemented with InterlockedCompareExchange
+ and YieldProcessor shows that much better performance is achieved by calling
+ YieldProcessor in a loop - that is, yielding longer. On Intel boxes setting
+ loop count in the range 200-300 brought best results.
+*/
+
+static inline int LF_BACKOFF(void)
+{
+ unsigned i= my_cpu_relax_multiplier;
+ while (i--)
+ MY_RELAX_CPU();
+ return 1;
+}
+
+/**
+ Run a delay loop while waiting for a shared resource to be released.
+ @param delay originally, roughly microseconds on 100 MHz Intel Pentium
+*/
+static inline void ut_delay(unsigned delay)
+{
+ unsigned i= my_cpu_relax_multiplier / 4 * delay;
+ HMT_low();
+ while (i--)
+ MY_RELAX_CPU();
+ HMT_medium();
+}
+
+#endif
diff --git a/include/my_dbug.h b/include/my_dbug.h
index debcfc50505..9ae482005b9 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
- Copyright (C) 2000, 2017, MariaDB Corporation Ab
+ Copyright (C) 2000, 2019, 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
@@ -58,11 +58,14 @@ extern void _db_dump_(uint _line_,const char *keyword,
extern void _db_end_(void);
extern void _db_lock_file_(void);
extern void _db_unlock_file_(void);
+ATTRIBUTE_COLD
+extern my_bool _db_my_assert(const char *file, int line, const char *msg);
extern FILE *_db_fp_(void);
extern void _db_flush_(void);
extern void dbug_swap_code_state(void **code_state_store);
extern void dbug_free_code_state(void **code_state_store);
extern const char* _db_get_func_(void);
+extern int (*dbug_sanity)(void);
#ifdef DBUG_TRACE
#define DBUG_LEAVE do { \
@@ -110,14 +113,20 @@ extern const char* _db_get_func_(void);
#define DBUG_END() _db_end_ ()
#define DBUG_LOCK_FILE _db_lock_file_()
#define DBUG_UNLOCK_FILE _db_unlock_file_()
-#define DBUG_ASSERT(A) assert(A)
+#define DBUG_ASSERT(A) do { \
+ if (unlikely(!(A)) && _db_my_assert(__FILE__, __LINE__, #A)) assert(A); \
+} while (0)
+#define DBUG_SLOW_ASSERT(A) DBUG_ASSERT(A)
+#define DBUG_ASSERT_EXISTS
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
#define IF_DBUG(A,B) A
+#define IF_DBUG_ASSERT(A,B) A
#define DBUG_SWAP_CODE_STATE(arg) dbug_swap_code_state(arg)
#define DBUG_FREE_CODE_STATE(arg) dbug_free_code_state(arg)
+#undef DBUG_ASSERT_AS_PRINTF
#ifndef __WIN__
#define DBUG_ABORT() (_db_flush_(), abort())
@@ -146,7 +155,7 @@ extern const char* _db_get_func_(void);
#else
extern void _db_suicide_(void);
#define DBUG_SUICIDE() (_db_flush_(), _db_suicide_())
-#endif
+#endif /* __WIN__ */
#else /* No debugger */
@@ -167,7 +176,7 @@ extern void _db_suicide_(void);
#define DBUG_PROCESS(a1) do { } while(0)
#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
#define DBUG_END() do { } while(0)
-#define DBUG_ASSERT(A) do { } while(0)
+#define DBUG_SLOW_ASSERT(A) do { } while(0)
#define DBUG_LOCK_FILE do { } while(0)
#define DBUG_FILE (stderr)
#define DBUG_UNLOCK_FILE do { } while(0)
@@ -184,7 +193,16 @@ extern void _db_suicide_(void);
#define DBUG_CRASH_VOID_RETURN do { return; } while(0)
#define DBUG_SUICIDE() do { } while(0)
-#endif
+#ifdef DBUG_ASSERT_AS_PRINTF
+extern void (*my_dbug_assert_failed)(const char *assert_expr, const char* file, unsigned long line);
+#define DBUG_ASSERT(assert_expr) do { if (!(assert_expr)) { my_dbug_assert_failed(#assert_expr, __FILE__, __LINE__); }} while (0)
+#define DBUG_ASSERT_EXISTS
+#define IF_DBUG_ASSERT(A,B) A
+#else
+#define DBUG_ASSERT(A) do { } while(0)
+#define IF_DBUG_ASSERT(A,B) B
+#endif /* DBUG_ASSERT_AS_PRINTF */
+#endif /* !defined(DBUG_OFF) && !defined(_lint) */
#ifdef EXTRA_DEBUG
/**
@@ -205,7 +223,7 @@ void debug_sync_point(const char* lock_name, uint lock_timeout);
}
/*
DBUG_LOG() was initially intended for InnoDB. To be able to use it elsewhere
- one should #include <sstream>. We intentially avoid including it here to save
+ one should #include <sstream>. We intentionally avoid including it here to save
compilation time.
*/
# ifdef DBUG_OFF
diff --git a/include/my_dir.h b/include/my_dir.h
index a2e04a488f0..930d54ca72f 100644
--- a/include/my_dir.h
+++ b/include/my_dir.h
@@ -16,8 +16,6 @@
#ifndef MY_DIR_H
#define MY_DIR_H
-#include "my_global.h"
-
#include <sys/stat.h>
#ifdef __cplusplus
@@ -52,7 +50,7 @@ extern "C" {
#define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG)
#define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO)
-/* Ensure these dosn't clash with anything in my_sys.h */
+/* Ensure these doesn't clash with anything in my_sys.h */
#define MY_WANT_SORT 8192 /* my_lib; sort files */
#define MY_WANT_STAT 16384 /* my_lib; stat files */
#define MY_DONT_SORT 0
@@ -65,7 +63,7 @@ typedef struct my_stat
{
dev_t st_dev; /* major & minor device numbers */
ino_t st_ino; /* inode number */
- ushort st_mode; /* file permissons (& suid sgid .. bits) */
+ ushort st_mode; /* file permissions (& suid sgid .. bits) */
short st_nlink; /* number of links to file */
ushort st_uid; /* user id */
ushort st_gid; /* group id */
@@ -78,10 +76,10 @@ typedef struct my_stat
#else
-#if(_MSC_VER)
+#if defined(_MSC_VER)
#define MY_STAT struct _stati64 /* 64 bit file size */
#else
-#define MY_STAT struct stat /* Orginal struct have what we need */
+#define MY_STAT struct stat /* Original struct has what we need */
#endif
#endif /* USE_MY_STAT_STRUCT */
diff --git a/include/my_getopt.h b/include/my_getopt.h
index c6aa21eda2e..72ce03d5654 100644
--- a/include/my_getopt.h
+++ b/include/my_getopt.h
@@ -38,6 +38,7 @@ C_MODE_START
#define GET_SET 13
#define GET_DOUBLE 14
#define GET_FLAGSET 15
+#define GET_BIT 16
#define GET_ASK_ADDR 128
#define GET_AUTO 64
diff --git a/include/my_global.h b/include/my_global.h
index 5e96400eac1..b96a04f4566 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1,6 +1,6 @@
/*
Copyright (c) 2001, 2013, Oracle and/or its affiliates.
- Copyright (c) 2009, 2017, MariaDB Corporation
+ Copyright (c) 2009, 2019, 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
@@ -178,7 +178,7 @@
/*
The macros below are borrowed from include/linux/compiler.h in the
- Linux kernel. Use them to indicate the likelyhood of the truthfulness
+ Linux kernel. Use them to indicate the likelihood of the truthfulness
of a condition. This serves two purposes - newer versions of gcc will be
able to optimize for branch predication, which could yield siginficant
performance gains in frequently executed sections of the code, and the
@@ -189,15 +189,6 @@
#define __builtin_expect(x, expected_value) (x)
#endif
-/**
- The semantics of builtin_expect() are that
- 1) its two arguments are long
- 2) it's likely that they are ==
- Those of our likely(x) are that x can be bool/int/longlong/pointer.
-*/
-#define likely(x) __builtin_expect(((x) != 0),1)
-#define unlikely(x) __builtin_expect(((x) != 0),0)
-
/* Fix problem with S_ISLNK() on Linux */
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
#undef _GNU_SOURCE
@@ -386,6 +377,36 @@ C_MODE_END
#include <crypt.h>
#endif
+/* Add checking if we are using likely/unlikely wrong */
+#ifdef CHECK_UNLIKELY
+C_MODE_START
+extern void init_my_likely(), end_my_likely(FILE *);
+extern int my_likely_ok(const char *file_name, uint line);
+extern int my_likely_fail(const char *file_name, uint line);
+C_MODE_END
+
+#define likely(A) ((A) ? (my_likely_ok(__FILE__, __LINE__),1) : (my_likely_fail(__FILE__, __LINE__), 0))
+#define unlikely(A) ((A) ? (my_likely_fail(__FILE__, __LINE__),1) : (my_likely_ok(__FILE__, __LINE__), 0))
+/*
+ These macros should be used when the check fails often when running benchmarks but
+ we know for sure that the check is correct in a production environment
+*/
+#define checked_likely(A) (A)
+#define checked_unlikely(A) (A)
+#else
+/**
+ The semantics of builtin_expect() are that
+ 1) its two arguments are long
+ 2) it's likely that they are ==
+ Those of our likely(x) are that x can be bool/int/longlong/pointer.
+*/
+
+#define likely(x) __builtin_expect(((x) != 0),1)
+#define unlikely(x) __builtin_expect(((x) != 0),0)
+#define checked_likely(x) likely(x)
+#define checked_unlikely(x) unlikely(x)
+#endif /* CHECK_UNLIKELY */
+
/*
A lot of our programs uses asserts, so better to always include it
This also fixes a problem when people uses DBUG_ASSERT without including
@@ -424,6 +445,20 @@ C_MODE_END
#if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus)
extern "C" int madvise(void *addr, size_t len, int behav);
#endif
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+/** FreeBSD equivalent */
+#if defined(MADV_CORE) && !defined(MADV_DODUMP)
+#define MADV_DODUMP MADV_CORE
+#define MADV_DONTDUMP MADV_NOCORE
+#define DODUMP_STR "MADV_CORE"
+#define DONTDUMP_STR "MADV_NOCORE"
+#else
+#define DODUMP_STR "MADV_DODUMP"
+#define DONTDUMP_STR "MADV_DONTDUMP"
+#endif
+
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */
@@ -462,7 +497,7 @@ extern "C" int madvise(void *addr, size_t len, int behav);
#define UNINIT_VAR(x) x
#endif
-/* This is only to be used when reseting variables in a class constructor */
+/* This is only to be used when resetting variables in a class constructor */
#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
#define LINT_INIT(x) x= 0
#else
@@ -529,7 +564,7 @@ typedef SOCKET my_socket;
typedef int my_socket; /* File descriptor for sockets */
#define INVALID_SOCKET -1
#endif
-/* Type for fuctions that handles signals */
+/* Type for functions that handles signals */
#define sig_handler RETSIGTYPE
#if defined(__GNUC__) && !defined(_lint)
typedef char pchar; /* Mixed prototypes can take char */
@@ -548,7 +583,7 @@ C_MODE_START
typedef int (*qsort_cmp)(const void *,const void *);
typedef int (*qsort_cmp2)(void*, const void *,const void *);
C_MODE_END
-#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */
+#define qsort_t RETQSORTTYPE /* Broken GCC can't handle typedef !!!! */
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
@@ -574,8 +609,8 @@ typedef SOCKET_SIZE_TYPE size_socket;
#endif
#endif /* O_SHARE */
-#ifndef O_TEMPORARY
-#define O_TEMPORARY 0
+#ifndef O_SEQUENTIAL
+#define O_SEQUENTIAL 0
#endif
#ifndef O_SHORT_LIVED
#define O_SHORT_LIVED 0
@@ -707,7 +742,7 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define closesocket(A) close(A)
#endif
-#if (_MSC_VER)
+#if defined(_MSC_VER)
#if !defined(_WIN64)
inline double my_ulonglong2double(unsigned long long value)
{
@@ -804,10 +839,6 @@ inline unsigned long long my_double2ulonglong(double d)
#define SIZE_T_MAX (~((size_t) 0))
#endif
-#ifdef __cplusplus
-#include <cmath>
-#endif
-
/* Define missing math constants. */
#ifndef M_PI
#define M_PI 3.14159265358979323846
@@ -819,20 +850,9 @@ inline unsigned long long my_double2ulonglong(double d)
#define M_LN2 0.69314718055994530942
#endif
-#ifndef HAVE_LOG2
-/*
- This will be slightly slower and perhaps a tiny bit less accurate than
- doing it the IEEE754 way but log2() should be available on C99 systems.
-*/
-static inline double log2(double x)
-{
- return (log(x) / M_LN2);
-}
-#endif
-
/*
Max size that must be added to a so that we know Size to make
- adressable obj.
+ addressable obj.
*/
#if SIZEOF_CHARP == 4
typedef long my_ptrdiff_t;
@@ -844,7 +864,7 @@ typedef long long my_ptrdiff_t;
#define MY_ALIGN_DOWN(A,L) ((A) & ~((L) - 1))
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
#define ALIGN_MAX_UNIT (sizeof(double))
-/* Size to make adressable obj. */
+/* Size to make addressable obj. */
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A), sizeof(double)))
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
@@ -973,7 +993,6 @@ typedef unsigned long my_off_t;
TODO Convert these to use Bitmap class.
*/
typedef ulonglong table_map; /* Used for table bits in join */
-typedef ulong nesting_map; /* Used for flags of nesting constructs */
/* often used type names - opaque declarations */
typedef const struct charset_info_st CHARSET_INFO;
@@ -1031,6 +1050,19 @@ typedef ulong myf; /* Type of MyFlags in my_funcs */
#define reg16 register
#endif
+/*
+ MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
+ (i.e variables) for usage in storage engine loadable plugins.
+ Outside of Windows, it is dummy.
+*/
+#ifndef MYSQL_PLUGIN_IMPORT
+#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
+#define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
+#else
+#define MYSQL_PLUGIN_IMPORT
+#endif
+#endif
+
#include <my_dbug.h>
/* Some helper macros */
@@ -1041,7 +1073,9 @@ typedef ulong myf; /* Type of MyFlags in my_funcs */
#include <my_byteorder.h>
-#ifdef HAVE_CHARSET_utf8
+#ifdef HAVE_CHARSET_utf8mb4
+#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8mb4"
+#elif defined(HAVE_CHARSET_utf8)
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
#else
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
@@ -1136,7 +1170,7 @@ typedef struct { const char *dli_fname, dli_fbase; } Dl_info;
/* Provide __func__ macro definition for platforms that miss it. */
#if !defined (__func__)
-#if __STDC_VERSION__ < 199901L
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
# else
@@ -1155,54 +1189,6 @@ typedef struct { const char *dli_fname, dli_fbase; } Dl_info;
#endif
#endif /* !defined(__func__) */
-#ifndef HAVE_RINT
-/**
- All integers up to this number can be represented exactly as double precision
- values (DBL_MANT_DIG == 53 for IEEE 754 hardware).
-*/
-#define MAX_EXACT_INTEGER ((1LL << DBL_MANT_DIG) - 1)
-
-/**
- rint(3) implementation for platforms that do not have it.
- Always rounds to the nearest integer with ties being rounded to the nearest
- even integer to mimic glibc's rint() behavior in the "round-to-nearest"
- FPU mode. Hardware-specific optimizations are possible (frndint on x86).
- Unlike this implementation, hardware will also honor the FPU rounding mode.
-*/
-
-static inline double rint(double x)
-{
- double f, i;
- f = modf(x, &i);
- /*
- All doubles with absolute values > MAX_EXACT_INTEGER are even anyway,
- no need to check it.
- */
- if (x > 0.0)
- i += (double) ((f > 0.5) || (f == 0.5 &&
- i <= (double) MAX_EXACT_INTEGER &&
- (longlong) i % 2));
- else
- i -= (double) ((f < -0.5) || (f == -0.5 &&
- i >= (double) -MAX_EXACT_INTEGER &&
- (longlong) i % 2));
- return i;
-}
-#endif /* HAVE_RINT */
-
-/*
- MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
- (i.e variables) for usage in storage engine loadable plugins.
- Outside of Windows, it is dummy.
-*/
-#ifndef MYSQL_PLUGIN_IMPORT
-#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
-#define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
-#else
-#define MYSQL_PLUGIN_IMPORT
-#endif
-#endif
-
/* Defines that are unique to the embedded version of MySQL */
#ifdef EMBEDDED_LIBRARY
@@ -1228,7 +1214,7 @@ static inline double rint(double x)
CMake using getconf
*/
#if !defined(CPU_LEVEL1_DCACHE_LINESIZE) || CPU_LEVEL1_DCACHE_LINESIZE == 0
- #if CPU_LEVEL1_DCACHE_LINESIZE == 0
+ #if defined(CPU_LEVEL1_DCACHE_LINESIZE) && CPU_LEVEL1_DCACHE_LINESIZE == 0
#undef CPU_LEVEL1_DCACHE_LINESIZE
#endif
@@ -1249,5 +1235,4 @@ static inline double rint(double x)
#else
#define NOT_FIXED_DEC FLOATING_POINT_DECIMALS
#endif
-
#endif /* my_global_h */
diff --git a/include/my_handler_errors.h b/include/my_handler_errors.h
index 87e52f141c7..45614ce221a 100644
--- a/include/my_handler_errors.h
+++ b/include/my_handler_errors.h
@@ -105,7 +105,9 @@ static const char *handler_error_messages[]=
"Too many words in a FTS phrase or proximity search",
"Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.",
"Foreign key cascade delete/update exceeds max depth",
- "Tablespace is missing for a table"
+ "Tablespace is missing for a table",
+ "Sequence has been run out",
+ "Sequence values are conflicting"
};
#endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */
diff --git a/include/my_net.h b/include/my_net.h
index bd42ccf6336..9a4f2f44b49 100644
--- a/include/my_net.h
+++ b/include/my_net.h
@@ -15,15 +15,13 @@
/*
This file is also used to make handling of sockets and ioctl()
- portable accross systems.
+ portable across systems.
*/
#ifndef _my_net_h
#define _my_net_h
-#include "my_global.h" /* C_MODE_START, C_MODE_END */
-
C_MODE_START
#include <errno.h>
diff --git a/include/my_pthread.h b/include/my_pthread.h
index f369b765edd..bff36072b71 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2009, 2017, MariaDB Corporation.
+ Copyright (c) 2009, 2020, 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
@@ -19,12 +19,12 @@
#ifndef _my_pthread_h
#define _my_pthread_h
-#include "my_global.h" /* myf */
-
#ifndef ETIME
#define ETIME ETIMEDOUT /* For FreeBSD */
#endif
+#include <my_atomic.h>
+
#ifdef __cplusplus
#define EXTERNC extern "C"
extern "C" {
@@ -82,7 +82,7 @@ int pthread_cond_signal(pthread_cond_t *cond);
int pthread_cond_broadcast(pthread_cond_t *cond);
int pthread_cond_destroy(pthread_cond_t *cond);
int pthread_attr_init(pthread_attr_t *connect_att);
-int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
+int pthread_attr_setstacksize(pthread_attr_t *connect_att,size_t stack);
int pthread_attr_destroy(pthread_attr_t *connect_att);
int my_pthread_once(my_pthread_once_t *once_control,void (*init_routine)(void));
@@ -198,7 +198,7 @@ int sigwait(sigset_t *set, int *sig);
#endif
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(_AIX)
-int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
+int sigwait(sigset_t *setp, int *sigp); /* Use our implementation */
#endif
@@ -309,7 +309,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#ifndef set_timespec_nsec
#define set_timespec_nsec(ABSTIME,NSEC) \
- set_timespec_time_nsec((ABSTIME), my_hrtime().val*1000 + (NSEC))
+ set_timespec_time_nsec((ABSTIME), my_hrtime_coarse().val*1000 + (NSEC))
#endif /* !set_timespec_nsec */
/* adapt for two different flavors of struct timespec */
@@ -395,7 +395,7 @@ typedef struct st_safe_mutex_deadlock_t
#ifdef SAFE_MUTEX_DETECT_DESTROY
/*
- Used to track the destroying of mutexes. This needs to be a seperate
+ Used to track the destroying of mutexes. This needs to be a separate
structure because the safe_mutex_t structure could be freed before
the mutexes are destroyed.
*/
@@ -503,9 +503,9 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp);
MDL subsystem deadlock detector relies on this property for
its correctness.
2) They are optimized for uncontended wr-lock/unlock case.
- This is scenario in which they are most oftenly used
+ This is a scenario in which they are most often used
within MDL subsystem. Optimizing for it gives significant
- performance improvements in some of tests involving many
+ performance improvements in some of the tests involving many
connections.
Another important requirement imposed on this type of rwlock
@@ -694,9 +694,9 @@ extern void my_mutex_end(void);
with the current number of keys and key parts.
*/
#if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN)
-#define DEFAULT_THREAD_STACK (364*1024L)
+#define DEFAULT_THREAD_STACK (383*1024L) /* 392192 */
#else
-#define DEFAULT_THREAD_STACK (292*1024L)
+#define DEFAULT_THREAD_STACK (292*1024L) /* 299008 */
#endif
#endif
@@ -806,6 +806,26 @@ extern uint thd_lib_detected;
#define statistic_sub(V,C,L) (V)-=(C)
#endif /* SAFE_STATISTICS */
+static inline void thread_safe_increment32(int32 *value)
+{
+ (void) my_atomic_add32_explicit(value, 1, MY_MEMORY_ORDER_RELAXED);
+}
+
+static inline void thread_safe_decrement32(int32 *value)
+{
+ (void) my_atomic_add32_explicit(value, -1, MY_MEMORY_ORDER_RELAXED);
+}
+
+static inline void thread_safe_increment64(int64 *value)
+{
+ (void) my_atomic_add64_explicit(value, 1, MY_MEMORY_ORDER_RELAXED);
+}
+
+static inline void thread_safe_decrement64(int64 *value)
+{
+ (void) my_atomic_add64_explicit(value, -1, MY_MEMORY_ORDER_RELAXED);
+}
+
/*
No locking needed, the counter is owned by the thread
*/
diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h
index 6eb6359cf2d..015fa062752 100644
--- a/include/my_stacktrace.h
+++ b/include/my_stacktrace.h
@@ -17,8 +17,6 @@
#ifndef _my_stacktrace_h_
#define _my_stacktrace_h_
-#include <my_global.h>
-
#ifdef TARGET_OS_LINUX
#if defined (__x86_64__) || defined (__i386__) || \
(defined(__alpha__) && defined(__GNUC__))
@@ -43,8 +41,9 @@
C_MODE_START
#if defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)
-void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack);
-int my_safe_print_str(const char* val, int max_len);
+void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack,
+ my_bool silent);
+int my_safe_print_str(const char* val, size_t max_len);
void my_write_core(int sig);
#if BACKTRACE_DEMANGLE
char *my_demangle(const char *mangled_name, int *status);
diff --git a/include/my_sys.h b/include/my_sys.h
index ac1730eeaff..020f20926ff 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2017, MariaDB Corporation.
+ Copyright (c) 2010, 2019, 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
@@ -17,8 +17,6 @@
#ifndef _my_sys_h
#define _my_sys_h
-#include "my_global.h" /* C_MODE_START, C_MODE_END */
-
#include <m_string.h>
C_MODE_START
@@ -62,18 +60,19 @@ typedef struct my_aio_result {
/* General bitmaps for my_func's */
#define MY_FFNF 1U /* Fatal if file not found */
-#define MY_FNABP 2U /* Fatal if not all bytes read/writen */
-#define MY_NABP 4U /* Error if not all bytes read/writen */
+#define MY_FNABP 2U /* Fatal if not all bytes read/written */
+#define MY_NABP 4U /* Error if not all bytes read/written */
#define MY_FAE 8U /* Fatal if any error */
#define MY_WME 16U /* Write message on error */
#define MY_WAIT_IF_FULL 32U /* Wait and try again if disk full error */
#define MY_IGNORE_BADFD 32U /* my_sync(): ignore 'bad descriptor' errors */
#define MY_ENCRYPT 64U /* Encrypt IO_CACHE temporary files */
+#define MY_TEMPORARY 64U /* create_temp_file(): delete file at once */
#define MY_NOSYMLINKS 512U /* my_open(): don't follow symlinks */
#define MY_FULL_IO 512U /* my_read(): loop until I/O is complete */
#define MY_DONT_CHECK_FILESIZE 128U /* Option to init_io_cache() */
#define MY_LINK_WARNING 32U /* my_redel() gives warning if links */
-#define MY_COPYTIME 64U /* my_redel() copys time */
+#define MY_COPYTIME 64U /* my_redel() copies time */
#define MY_DELETE_OLD 256U /* my_create_with_symlink() */
#define MY_RESOLVE_LINK 128U /* my_realpath(); Only resolve links */
#define MY_HOLD_ORIGINAL_MODES 128U /* my_copy() holds to file modes */
@@ -98,7 +97,7 @@ typedef struct my_aio_result {
#define MY_SYNC_FILESIZE 65536U /* my_sync(): safe sync when file is extended */
#define MY_THREAD_SPECIFIC 0x10000U /* my_malloc(): thread specific */
#define MY_THREAD_MOVE 0x20000U /* realloc(); Memory can move */
-/* Tree that should delete things automaticly */
+/* Tree that should delete things automatically */
#define MY_TREE_WITH_DELETE 0x40000U
#define MY_CHECK_ERROR 1U /* Params to my_end; Check open-close */
@@ -108,7 +107,7 @@ typedef struct my_aio_result {
#define ME_BELL 4U /* Ring bell then printing message */
#define ME_WAITTANG 0 /* Wait for a user action */
#define ME_NOREFRESH 64U /* Write the error message to error log */
-#define ME_NOINPUT 0 /* Dont use the input libary */
+#define ME_NOINPUT 0 /* Don't use the input library */
#define ME_JUST_INFO 1024U /**< not error but just info */
#define ME_JUST_WARNING 2048U /**< not error but just warning */
#define ME_FATALERROR 4096U /* Fatal statement error */
@@ -154,9 +153,12 @@ typedef struct my_aio_result {
/* Extra length needed for filename if one calls my_create_backup_name */
#define MY_BACKUP_NAME_EXTRA_LENGTH 17
+char *guess_malloc_library();
+
/* If we have our own safemalloc (for debugging) */
#if defined(SAFEMALLOC)
void sf_report_leaked_memory(my_thread_id id);
+int sf_sanity();
extern my_thread_id (*sf_malloc_dbug_id)(void);
#define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X)
#else
@@ -259,18 +261,20 @@ extern ulonglong my_collation_statistics_get_use_count(uint id);
extern const char *my_collation_get_tailoring(uint id);
/* statistics */
-extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
+extern ulong my_stream_opened, my_tmp_file_created;
extern ulong my_file_total_opened;
extern ulong my_sync_count;
extern uint mysys_usage_id;
+extern int32 my_file_opened;
extern my_bool my_init_done, my_thr_key_mysys_exists;
+extern my_bool my_assert;
extern my_bool my_assert_on_error;
extern myf my_global_flags; /* Set to MY_WME for more error messages */
/* Point to current my_message() */
extern void (*my_sigtstp_cleanup)(void),
/* Executed before jump to shell */
(*my_sigtstp_restart)(void);
- /* Executed when comming from shell */
+ /* Executed when coming from shell */
extern MYSQL_PLUGIN_IMPORT int my_umask; /* Default creation mask */
extern int my_umask_dir,
my_recived_signals, /* Signals we have got */
@@ -310,7 +314,7 @@ enum flush_type
FLUSH_KEEP_LAZY
};
-typedef struct st_record_cache /* Used when cacheing records */
+typedef struct st_record_cache /* Used when caching records */
{
File file;
int rc_seek,error,inited;
@@ -390,7 +394,7 @@ typedef struct st_io_cache_share
#endif
} IO_CACHE_SHARE;
-typedef struct st_io_cache /* Used when cacheing files */
+typedef struct st_io_cache /* Used when caching files */
{
/* Offset in file corresponding to the first byte of uchar* buffer. */
my_off_t pos_in_file;
@@ -532,6 +536,7 @@ static inline int my_b_read(IO_CACHE *info, uchar *Buffer, size_t Count)
static inline int my_b_write(IO_CACHE *info, const uchar *Buffer, size_t Count)
{
+ MEM_CHECK_DEFINED(Buffer, Count);
if (info->write_pos + Count <= info->write_end)
{
if (Count)
@@ -554,12 +559,14 @@ static inline int my_b_get(IO_CACHE *info)
return _my_b_get(info);
}
-/* my_b_write_byte dosn't have any err-check */
-static inline void my_b_write_byte(IO_CACHE *info, uchar chr)
+static inline my_bool my_b_write_byte(IO_CACHE *info, uchar chr)
{
+ MEM_CHECK_DEFINED(&chr, 1);
if (info->write_pos >= info->write_end)
- my_b_flush_io_cache(info, 1);
+ if (my_b_flush_io_cache(info, 1))
+ return 1;
*info->write_pos++= chr;
+ return 0;
}
/**
@@ -575,21 +582,21 @@ static inline void my_b_write_byte(IO_CACHE *info, uchar chr)
static inline size_t my_b_fill(IO_CACHE *info)
{
info->read_pos= info->read_end;
- return _my_b_read(info,0,0) ? 0 : info->read_end - info->read_pos;
+ return _my_b_read(info,0,0) ? 0 : (size_t) (info->read_end - info->read_pos);
}
static inline my_off_t my_b_tell(const IO_CACHE *info)
{
if (info->type == WRITE_CACHE) {
- return info->pos_in_file + (info->write_pos - info->request_pos);
+ return info->pos_in_file + (my_off_t)(info->write_pos - info->request_pos);
}
- return info->pos_in_file + (info->read_pos - info->request_pos);
+ return info->pos_in_file + (my_off_t) (info->read_pos - info->request_pos);
}
static inline my_off_t my_b_write_tell(const IO_CACHE *info)
{
- return info->pos_in_file + (info->write_pos - info->write_buffer);
+ return info->pos_in_file + (my_off_t) (info->write_pos - info->write_buffer);
}
static inline uchar* my_b_get_buffer_start(const IO_CACHE *info)
@@ -599,7 +606,7 @@ static inline uchar* my_b_get_buffer_start(const IO_CACHE *info)
static inline size_t my_b_get_bytes_in_buffer(const IO_CACHE *info)
{
- return info->read_end - info->request_pos;
+ return (size_t) (info->read_end - info->request_pos);
}
static inline my_off_t my_b_get_pos_in_file(const IO_CACHE *info)
@@ -610,9 +617,9 @@ static inline my_off_t my_b_get_pos_in_file(const IO_CACHE *info)
static inline size_t my_b_bytes_in_cache(const IO_CACHE *info)
{
if (info->type == WRITE_CACHE) {
- return info->write_end - info->write_pos;
+ return (size_t) (info->write_end - info->write_pos);
}
- return info->read_end - info->read_pos;
+ return (size_t) (info->read_end - info->read_pos);
}
int my_b_copy_to_file (IO_CACHE *cache, FILE *file, size_t count);
@@ -738,12 +745,6 @@ void my_create_backup_name(char *to, const char *from,
extern int my_copystat(const char *from, const char *to, int MyFlags);
extern char * my_filename(File fd);
-#ifdef EXTRA_DEBUG
-void my_print_open_files(void);
-#else
-#define my_print_open_files()
-#endif
-
extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
extern char *my_tmpdir(MY_TMPDIR *tmpdir);
extern void free_tmpdir(MY_TMPDIR *tmpdir);
@@ -830,9 +831,9 @@ extern int end_io_cache(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
extern my_off_t my_b_filelength(IO_CACHE *info);
-extern size_t my_b_write_backtick_quote(IO_CACHE *info, const char *str,
- size_t len);
-extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
+extern my_bool my_b_write_backtick_quote(IO_CACHE *info, const char *str,
+ size_t len);
+extern my_bool my_b_printf(IO_CACHE *info, const char* fmt, ...);
extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
const char *prefix, size_t cache_size,
@@ -898,8 +899,9 @@ extern void my_free_lock(void *ptr);
#define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
-extern void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
- size_t pre_alloc_size, myf my_flags);
+extern void init_alloc_root(MEM_ROOT *mem_root, const char *name,
+ size_t block_size, size_t pre_alloc_size,
+ myf my_flags);
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
extern void *multi_alloc_root(MEM_ROOT *mem_root, ...);
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
@@ -926,7 +928,7 @@ extern int unpackfrm(uchar **, size_t *, const uchar *);
extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem,
size_t count);
-#ifndef DBUG_OFF
+#ifdef DBUG_ASSERT_EXISTS
extern void my_debug_put_break_here(void);
#else
#define my_debug_put_break_here() do {} while(0)
@@ -944,6 +946,13 @@ extern int my_getncpus(void);
typedef struct {ulonglong val;} my_hrtime_t;
void my_time_init(void);
extern my_hrtime_t my_hrtime(void);
+
+#ifdef _WIN32
+extern my_hrtime_t my_hrtime_coarse();
+#else
+#define my_hrtime_coarse() my_hrtime()
+#endif
+
extern ulonglong my_interval_timer(void);
extern ulonglong my_getcputime(void);
@@ -952,7 +961,7 @@ extern ulonglong my_getcputime(void);
#define hrtime_from_time(X) ((ulonglong)((X)*HRTIME_RESOLUTION))
#define hrtime_to_double(X) ((X).val/(double)HRTIME_RESOLUTION)
#define hrtime_sec_part(X) ((ulong)((X).val % HRTIME_RESOLUTION))
-#define my_time(X) hrtime_to_time(my_hrtime())
+#define my_time(X) hrtime_to_time(my_hrtime_coarse())
#if STACK_DIRECTION < 0
#define available_stack_size(CUR,END) (long) ((char*)(CUR) - (char*)(END))
@@ -961,8 +970,6 @@ extern ulonglong my_getcputime(void);
#endif
#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-
#ifndef MAP_NOSYNC
#define MAP_NOSYNC 0
#endif
@@ -1052,9 +1059,9 @@ extern size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
char *to, size_t to_length,
const char *from, size_t length);
-extern void thd_increment_bytes_sent(void *thd, ulong length);
-extern void thd_increment_bytes_received(void *thd, ulong length);
-extern void thd_increment_net_big_packet_count(void *thd, ulong length);
+extern void thd_increment_bytes_sent(void *thd, size_t length);
+extern void thd_increment_bytes_received(void *thd, size_t length);
+extern void thd_increment_net_big_packet_count(void *thd, size_t length);
#ifdef __WIN__
extern my_bool have_tcpip; /* Is set if tcpip is used */
diff --git a/include/my_time.h b/include/my_time.h
index eeb790cdb54..7c8f3ce909b 100644
--- a/include/my_time.h
+++ b/include/my_time.h
@@ -22,7 +22,6 @@
#ifndef _my_time_h_
#define _my_time_h_
-#include "my_global.h"
#include "mysql_time.h"
#include "my_decimal_limits.h"
@@ -79,7 +78,7 @@ extern uchar days_in_month[];
#define MYSQL_TIME_WARN_HAVE_WARNINGS(x) MY_TEST((x) & MYSQL_TIME_WARN_WARNINGS)
#define MYSQL_TIME_WARN_HAVE_NOTES(x) MY_TEST((x) & MYSQL_TIME_WARN_NOTES)
-/* Usefull constants */
+/* Useful constants */
#define SECONDS_IN_24H 86400L
/* Limits for the TIME data type */
@@ -105,20 +104,21 @@ typedef struct st_mysql_time_status
static inline void my_time_status_init(MYSQL_TIME_STATUS *status)
{
- status->warnings= status->precision= 0;
+ status->warnings= 0;
+ status->precision= 0;
}
my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
ulonglong flags, int *was_cut);
-my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
+my_bool str_to_time(const char *str, size_t length, MYSQL_TIME *l_time,
ulonglong flag, MYSQL_TIME_STATUS *status);
-my_bool str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
+my_bool str_to_datetime(const char *str, size_t length, MYSQL_TIME *l_time,
ulonglong flags, MYSQL_TIME_STATUS *status);
longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res,
ulonglong flags, int *was_cut);
static inline
-longlong double_to_datetime(double nr, MYSQL_TIME *ltime, uint flags, int *cut)
+longlong double_to_datetime(double nr, MYSQL_TIME *ltime, ulonglong flags, int *cut)
{
if (nr < 0 || nr > (double)LONGLONG_MAX)
nr= (double)LONGLONG_MAX;
@@ -135,9 +135,6 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *);
ulonglong TIME_to_ulonglong(const MYSQL_TIME *);
double TIME_to_double(const MYSQL_TIME *my_time);
-longlong pack_time(const MYSQL_TIME *my_time);
-MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time);
-
int check_time_range(struct st_mysql_time *my_time, uint dec, int *warning);
my_bool check_datetime_range(const MYSQL_TIME *ltime);
@@ -240,7 +237,7 @@ static inline void my_timeval_trunc(struct timeval *tv, uint decimals)
order of elements in 'interval_type_to_name' and 'interval_names'
arrays
- See also interval_type_to_name, get_interval_value, interval_names
+ See also interval_type_to_name, get_interval_value, interval_names, append_interval
*/
enum interval_type
diff --git a/include/my_tree.h b/include/my_tree.h
index d0c898f7659..9bed28efcb3 100644
--- a/include/my_tree.h
+++ b/include/my_tree.h
@@ -48,7 +48,7 @@ typedef uint32 element_count;
typedef int (*tree_walk_action)(void *,element_count,void *);
typedef enum { free_init, free_free, free_end } TREE_FREE;
-typedef void (*tree_element_free)(void*, TREE_FREE, void *);
+typedef int (*tree_element_free)(void*, TREE_FREE, void *);
typedef struct st_tree_element {
struct st_tree_element *left,*right;
@@ -77,8 +77,8 @@ void init_tree(TREE *tree, size_t default_alloc_size, size_t memory_limit,
int size, qsort_cmp2 compare,
tree_element_free free_element, void *custom_arg,
myf my_flags);
-void delete_tree(TREE*);
-void reset_tree(TREE*);
+int delete_tree(TREE*, my_bool abort);
+int reset_tree(TREE*);
/* similar to delete tree, except we do not my_free() blocks in mem_root */
#define is_tree_inited(tree) ((tree)->root != 0)
diff --git a/include/my_user.h b/include/my_user.h
index a4b39edad77..46a811d56bf 100644
--- a/include/my_user.h
+++ b/include/my_user.h
@@ -22,8 +22,6 @@
#ifndef _my_user_h_
#define _my_user_h_
-#include <my_global.h>
-
C_MODE_START
int parse_user(const char *user_id_str, size_t user_id_len,
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index a4fc738fd59..62794a2d70c 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -24,16 +24,22 @@
# define __SANITIZE_ADDRESS__ 1
#endif
-#ifdef HAVE_valgrind
-#define IF_VALGRIND(A,B) A
-#else
-#define IF_VALGRIND(A,B) B
-#endif
-
-#if defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
+#if __has_feature(memory_sanitizer)
+# include <sanitizer/msan_interface.h>
+# define HAVE_valgrind
+# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
+# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
+# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
+# define MEM_NOACCESS(a,len) ((void) 0)
+# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
+# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
+# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
+# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
+# define REDZONE_SIZE 8
+#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
# include <valgrind/memcheck.h>
-# define HAVE_valgrind_or_MSAN
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
+# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
# define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len)
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
@@ -45,27 +51,19 @@
# include <sanitizer/asan_interface.h>
/* How to do manual poisoning:
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
-# define MEM_UNDEFINED(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
+# define MEM_UNDEFINED(a,len) ((void) 0)
+# define MEM_MAKE_ADDRESSABLE(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
# define MEM_MAKE_DEFINED(a,len) ((void) 0)
# define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len)
-# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
+# define MEM_CHECK_ADDRESSABLE(a,len) \
+ assert(!__asan_region_is_poisoned((void*) a,len))
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
# define REDZONE_SIZE 8
-#elif __has_feature(memory_sanitizer)
-# include <sanitizer/msan_interface.h>
-# define HAVE_valgrind_or_MSAN
-# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
-# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
-# define MEM_NOACCESS(a,len) ((void) 0)
-# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
-# define MEM_CHECK_DEFINED(a,len) __msan_check_mem_is_initialized(a,len)
-# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
-# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
-# define REDZONE_SIZE 8
#else
-# define MEM_UNDEFINED(a,len) ((void) (a), (void) (len))
+# define MEM_UNDEFINED(a,len) ((void) 0)
+# define MEM_MAKE_ADDRESSABLE(a,len) ((void) 0)
# define MEM_MAKE_DEFINED(a,len) ((void) 0)
# define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
@@ -73,25 +71,30 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
# define REDZONE_SIZE 0
-#endif /* HAVE_VALGRIND_MEMCHECK_H */
+#endif /* __has_feature(memory_sanitizer) */
+
+#ifdef HAVE_valgrind
+#define IF_VALGRIND(A,B) A
+#else
+#define IF_VALGRIND(A,B) B
+#endif
-#ifndef DBUG_OFF
+#ifdef TRASH_FREED_MEMORY
/*
- TRASH_FILL() has to call MEM_UNDEFINED() to cancel any effect of TRASH_FREE().
+ _TRASH_FILL() has to call MEM_MAKE_ADDRESSABLE() to cancel any effect of
+ TRASH_FREE().
This can happen in the case one does
TRASH_ALLOC(A,B) ; TRASH_FREE(A,B) ; TRASH_ALLOC(A,B)
to reuse the same memory in an internal memory allocator like MEM_ROOT.
- For my_malloc() and safemalloc() the extra MEM_UNDEFINED is bit of an
- overkill.
- TRASH_FILL() is an internal function and should not be used externally.
+ _TRASH_FILL() is an internal function and should not be used externally.
*/
-#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
+#define _TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_MAKE_ADDRESSABLE(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#else
-#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
+#define _TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
#endif
-/** Note that some memory became allocated or uninitialized. */
-#define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0)
+/** Note that some memory became allocated and/or uninitialized. */
+#define TRASH_ALLOC(A,B) do { _TRASH_FILL(A,B,0xA5); MEM_MAKE_ADDRESSABLE(A,B); } while(0)
/** Note that some memory became freed. (Prohibit further access to it.) */
-#define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
+#define TRASH_FREE(A,B) do { _TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
#endif /* MY_VALGRIND_INCLUDED */
diff --git a/include/myisam.h b/include/myisam.h
index 26857b4ac32..3138dc832f7 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -275,7 +275,7 @@ extern int mi_rsame(struct st_myisam_info *file,uchar *record,int inx);
extern int mi_rsame_with_pos(struct st_myisam_info *file,uchar *record,
int inx, my_off_t pos);
extern int mi_update(struct st_myisam_info *file,const uchar *old,
- uchar *new_record);
+ const uchar *new_record);
extern int mi_write(struct st_myisam_info *file,uchar *buff);
extern my_off_t mi_position(struct st_myisam_info *file);
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint flag);
@@ -417,7 +417,7 @@ my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map,
int mi_init_bulk_insert(MI_INFO *info, size_t cache_size, ha_rows rows);
void mi_flush_bulk_insert(MI_INFO *info, uint inx);
-void mi_end_bulk_insert(MI_INFO *info);
+int mi_end_bulk_insert(MI_INFO *info, my_bool abort);
int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map,
KEY_CACHE *key_cache);
void mi_change_key_cache(KEY_CACHE *old_key_cache,
diff --git a/include/myisamchk.h b/include/myisamchk.h
index 883165b78fd..5876d67ca5f 100644
--- a/include/myisamchk.h
+++ b/include/myisamchk.h
@@ -100,12 +100,13 @@ typedef struct st_handler_check_param
time_t backup_time; /* To sign backup files */
ulong rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY];
double new_rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY];
- uint out_flag, warning_printed, error_printed, note_printed, verbose;
+ uint out_flag, error_printed, verbose;
uint opt_sort_key, total_files, max_level;
uint key_cache_block_size, pagecache_block_size;
int tmpfile_createflag, err_count;
myf myf_rw;
uint16 language;
+ my_bool warning_printed, note_printed, wrong_trd_printed;
my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
my_bool retry_repair, force_sort, calc_checksum, static_row_size;
char temp_filename[FN_REFLEN];
diff --git a/include/myisammrg.h b/include/myisammrg.h
index a1b921bbbc3..fe229a85cb0 100644
--- a/include/myisammrg.h
+++ b/include/myisammrg.h
@@ -104,7 +104,8 @@ extern int myrg_rkey(MYRG_INFO *info,uchar *buf,int inx, const uchar *key,
key_part_map keypart_map, enum ha_rkey_function search_flag);
extern int myrg_rrnd(MYRG_INFO *file,uchar *buf,ulonglong pos);
extern int myrg_rsame(MYRG_INFO *file,uchar *record,int inx);
-extern int myrg_update(MYRG_INFO *file,const uchar *old,uchar *new_rec);
+extern int myrg_update(MYRG_INFO *file,const uchar *old,
+ const uchar *new_rec);
extern int myrg_write(MYRG_INFO *info,uchar *rec);
extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag);
extern int myrg_lock_database(MYRG_INFO *file,int lock_type);
diff --git a/include/mysql.h b/include/mysql.h
index 07702a54dba..ec49ca0482a 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -145,7 +145,6 @@ typedef unsigned long long my_ulonglong;
#define ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#define ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN ER_PRIMARY_KEY_BASED_ON_GENERATED_COLUMN
#define ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
-#define ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
#define ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
#define ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index 73b9f9f588b..1e4479e8f2b 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -66,6 +66,8 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_TIMESTAMP2,
MYSQL_TYPE_DATETIME2,
MYSQL_TYPE_TIME2,
+ MYSQL_TYPE_BLOB_COMPRESSED= 140,
+ MYSQL_TYPE_VARCHAR_COMPRESSED= 141,
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248,
@@ -137,7 +139,7 @@ typedef struct st_udf_args
char **args;
unsigned long *lengths;
char *maybe_null;
- char **attributes;
+ const char **attributes;
unsigned long *attribute_lengths;
void *extension;
} UDF_ARGS;
@@ -163,7 +165,7 @@ void scramble(char *to, const char *message, const char *password);
my_bool check_scramble(const unsigned char *reply, const char *message,
const unsigned char *hash_stage2);
void get_salt_from_password(unsigned char *res, const char *password);
-char *octet2hex(char *to, const char *str, unsigned int len);
+char *octet2hex(char *to, const char *str, size_t len);
char *get_tty_password(const char *opt_message);
void get_tty_password_buff(const char *opt_message, char *to, size_t length);
const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
@@ -236,9 +238,11 @@ typedef struct st_mem_root
USED_MEM *pre_alloc;
size_t min_malloc;
size_t block_size;
+ size_t total_alloc;
unsigned int block_num;
unsigned int first_block_usage;
void (*error_handler)(void);
+ const char *name;
} MEM_ROOT;
typedef struct st_typelib {
unsigned int count;
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 3a522af8a9e..e084b6becec 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -649,7 +649,6 @@ void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
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);
-int thd_rpl_is_parallel(const MYSQL_THD thd);
/**
Create a temporary file.
diff --git a/include/mysql/plugin_audit.h b/include/mysql/plugin_audit.h
index 2a3a59eea72..e99c01376e6 100644
--- a/include/mysql/plugin_audit.h
+++ b/include/mysql/plugin_audit.h
@@ -65,8 +65,7 @@ struct mysql_event_general
unsigned long long general_rows;
/* Added in version 0x302 */
unsigned long long query_id;
- const char *database;
- unsigned int database_length;
+ MYSQL_CONST_LEX_STRING database;
};
@@ -101,8 +100,7 @@ struct mysql_event_connection
unsigned int host_length;
const char *ip;
unsigned int ip_length;
- const char *database;
- unsigned int database_length;
+ MYSQL_CONST_LEX_STRING database;
};
/*
@@ -137,17 +135,13 @@ struct mysql_event_table
const char *proxy_user;
const char *host;
const char *ip;
- const char *database;
- unsigned int database_length;
- const char *table;
- unsigned int table_length;
+ MYSQL_CONST_LEX_STRING database;
+ MYSQL_CONST_LEX_STRING table;
+ /* for MYSQL_AUDIT_TABLE_RENAME */
+ MYSQL_CONST_LEX_STRING new_database;
+ MYSQL_CONST_LEX_STRING new_table;
/* for MYSQL_AUDIT_TABLE_LOCK, true if read-only, false if read/write */
int read_only;
- /* for MYSQL_AUDIT_TABLE_RENAME */
- const char *new_database;
- unsigned int new_database_length;
- const char *new_table;
- unsigned int new_table_length;
/* Added in version 0x302 */
unsigned long long query_id;
};
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index 410781669ba..89f7dcc36c4 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -270,13 +270,20 @@ struct st_mysql_lex_string
size_t length;
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+struct st_mysql_const_lex_string
+{
+ const char *str;
+ size_t length;
+};
+typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, size_t);
void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, size_t);
void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
void *thd_alloc(void* thd, size_t size);
@@ -284,9 +291,10 @@ void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, size_t size);
void *thd_memdup(void* thd, const void* str, size_t size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, size_t size,
- int allocate_lex_string);
+MYSQL_CONST_LEX_STRING
+*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+ const char *str, size_t size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
@@ -510,7 +518,6 @@ void **thd_ha_data(const void* thd, const struct handlerton *hton);
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
-int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
@@ -536,8 +543,7 @@ struct mysql_event_general
unsigned long long general_time;
unsigned long long general_rows;
unsigned long long query_id;
- const char *database;
- unsigned int database_length;
+ MYSQL_CONST_LEX_STRING database;
};
struct mysql_event_connection
{
@@ -556,8 +562,7 @@ struct mysql_event_connection
unsigned int host_length;
const char *ip;
unsigned int ip_length;
- const char *database;
- unsigned int database_length;
+ MYSQL_CONST_LEX_STRING database;
};
struct mysql_event_table
{
@@ -570,15 +575,11 @@ struct mysql_event_table
const char *proxy_user;
const char *host;
const char *ip;
- const char *database;
- unsigned int database_length;
- const char *table;
- unsigned int table_length;
+ MYSQL_CONST_LEX_STRING database;
+ MYSQL_CONST_LEX_STRING table;
+ MYSQL_CONST_LEX_STRING new_database;
+ MYSQL_CONST_LEX_STRING new_table;
int read_only;
- const char *new_database;
- unsigned int new_database_length;
- const char *new_table;
- unsigned int new_table_length;
unsigned long long query_id;
};
struct st_mysql_audit
diff --git a/include/mysql/plugin_auth.h b/include/mysql/plugin_auth.h
index 561acbf2226..6741283d5bd 100644
--- a/include/mysql/plugin_auth.h
+++ b/include/mysql/plugin_auth.h
@@ -51,7 +51,7 @@ typedef struct st_mysql_server_auth_info
User name as sent by the client and shown in USER().
NULL if the client packet with the user name was not received yet.
*/
- char *user_name;
+ const char *user_name;
/**
Length of user_name
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index 62061f74274..e515699cad6 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -270,13 +270,20 @@ struct st_mysql_lex_string
size_t length;
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+struct st_mysql_const_lex_string
+{
+ const char *str;
+ size_t length;
+};
+typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, size_t);
void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, size_t);
void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
void *thd_alloc(void* thd, size_t size);
@@ -284,9 +291,10 @@ void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, size_t size);
void *thd_memdup(void* thd, const void* str, size_t size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, size_t size,
- int allocate_lex_string);
+MYSQL_CONST_LEX_STRING
+*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+ const char *str, size_t size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
@@ -510,7 +518,6 @@ void **thd_ha_data(const void* thd, const struct handlerton *hton);
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
-int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
@@ -538,7 +545,7 @@ typedef struct st_plugin_vio
} MYSQL_PLUGIN_VIO;
typedef struct st_mysql_server_auth_info
{
- char *user_name;
+ const char *user_name;
unsigned int user_name_length;
const char *auth_string;
unsigned long auth_string_length;
diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp
index 1277147e55f..7defe0aec2c 100644
--- a/include/mysql/plugin_encryption.h.pp
+++ b/include/mysql/plugin_encryption.h.pp
@@ -270,13 +270,20 @@ struct st_mysql_lex_string
size_t length;
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+struct st_mysql_const_lex_string
+{
+ const char *str;
+ size_t length;
+};
+typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, size_t);
void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, size_t);
void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
void *thd_alloc(void* thd, size_t size);
@@ -284,9 +291,10 @@ void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, size_t size);
void *thd_memdup(void* thd, const void* str, size_t size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, size_t size,
- int allocate_lex_string);
+MYSQL_CONST_LEX_STRING
+*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+ const char *str, size_t size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
@@ -510,7 +518,6 @@ void **thd_ha_data(const void* thd, const struct handlerton *hton);
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
-int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp
index 85c6700227f..a36f51e74e1 100644
--- a/include/mysql/plugin_ftparser.h.pp
+++ b/include/mysql/plugin_ftparser.h.pp
@@ -270,13 +270,20 @@ struct st_mysql_lex_string
size_t length;
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+struct st_mysql_const_lex_string
+{
+ const char *str;
+ size_t length;
+};
+typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, size_t);
void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, size_t);
void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
void *thd_alloc(void* thd, size_t size);
@@ -284,9 +291,10 @@ void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, size_t size);
void *thd_memdup(void* thd, const void* str, size_t size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, size_t size,
- int allocate_lex_string);
+MYSQL_CONST_LEX_STRING
+*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+ const char *str, size_t size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
@@ -464,7 +472,6 @@ void **thd_ha_data(const void* thd, const struct handlerton *hton);
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
-int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
diff --git a/include/mysql/plugin_password_validation.h b/include/mysql/plugin_password_validation.h
index 894d17cba0f..ddc9387c72e 100644
--- a/include/mysql/plugin_password_validation.h
+++ b/include/mysql/plugin_password_validation.h
@@ -42,8 +42,8 @@ struct st_mariadb_password_validation
Function provided by the plugin which should perform password validation
and return 0 if the password has passed the validation.
*/
- int (*validate_password)(MYSQL_LEX_STRING *username,
- MYSQL_LEX_STRING *password);
+ int (*validate_password)(MYSQL_CONST_LEX_STRING *username,
+ MYSQL_CONST_LEX_STRING *password);
};
#ifdef __cplusplus
diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp
index 25eb5425e52..9701ad1b92f 100644
--- a/include/mysql/plugin_password_validation.h.pp
+++ b/include/mysql/plugin_password_validation.h.pp
@@ -270,13 +270,20 @@ struct st_mysql_lex_string
size_t length;
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+struct st_mysql_const_lex_string
+{
+ const char *str;
+ size_t length;
+};
+typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, size_t);
void *(*thd_calloc_func)(void*, size_t);
char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, size_t);
void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
void *thd_alloc(void* thd, size_t size);
@@ -284,9 +291,10 @@ void *thd_calloc(void* thd, size_t size);
char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, size_t size);
void *thd_memdup(void* thd, const void* str, size_t size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, size_t size,
- int allocate_lex_string);
+MYSQL_CONST_LEX_STRING
+*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+ const char *str, size_t size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
@@ -510,7 +518,6 @@ void **thd_ha_data(const void* thd, const struct handlerton *hton);
void thd_storage_lock_wait(void* thd, long long value);
int thd_tx_isolation(const void* thd);
int thd_tx_is_read_only(const void* thd);
-int thd_rpl_is_parallel(const void* thd);
int mysql_tmpfile(const char *prefix);
unsigned long thd_get_thread_id(const void* thd);
void thd_get_xid(const void* thd, MYSQL_XID *xid);
@@ -524,6 +531,6 @@ void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
struct st_mariadb_password_validation
{
int interface_version;
- int (*validate_password)(MYSQL_LEX_STRING *username,
- MYSQL_LEX_STRING *password);
+ int (*validate_password)(MYSQL_CONST_LEX_STRING *username,
+ MYSQL_CONST_LEX_STRING *password);
};
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h
index bd01cff69e4..1d2ec34fc98 100644
--- a/include/mysql/psi/mysql_file.h
+++ b/include/mysql/psi/mysql_file.h
@@ -23,8 +23,6 @@
#ifndef MYSQL_FILE_H
#define MYSQL_FILE_H
-#include <my_global.h>
-
/* For strlen() */
#include <string.h>
/* For MY_STAT */
@@ -538,16 +536,18 @@ inline_mysql_file_fgets(
{
char *result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_READ);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) size, src_file, src_line);
- result= fgets(str, size, file->m_file);
- PSI_FILE_CALL(end_file_wait)(locker, result ? strlen(result) : 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_READ);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) size, src_file, src_line);
+ result= fgets(str, size, file->m_file);
+ PSI_FILE_CALL(end_file_wait)(locker, result ? strlen(result) : 0);
+ return result;
+ }
}
#endif
@@ -564,16 +564,18 @@ inline_mysql_file_fgetc(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_READ);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line);
- result= fgetc(file->m_file);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_READ);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line);
+ result= fgetc(file->m_file);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1);
+ return result;
+ }
}
#endif
@@ -590,18 +592,20 @@ inline_mysql_file_fputs(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_WRITE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- bytes= str ? strlen(str) : 0;
- PSI_FILE_CALL(start_file_wait)(locker, bytes, src_file, src_line);
- result= fputs(str, file->m_file);
- PSI_FILE_CALL(end_file_wait)(locker, bytes);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
+ {
+ bytes= str ? strlen(str) : 0;
+ PSI_FILE_CALL(start_file_wait)(locker, bytes, src_file, src_line);
+ result= fputs(str, file->m_file);
+ PSI_FILE_CALL(end_file_wait)(locker, bytes);
+ return result;
+ }
}
#endif
@@ -618,16 +622,18 @@ inline_mysql_file_fputc(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_WRITE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line);
- result= fputc(c, file->m_file);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 1, src_file, src_line);
+ result= fputc(c, file->m_file);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 1);
+ return result;
+ }
}
#endif
@@ -644,18 +650,20 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...)
int result;
va_list args;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_WRITE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, __FILE__, __LINE__);
- va_start(args, format);
- result= vfprintf(file->m_file, format, args);
- va_end(args);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) result);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, __FILE__, __LINE__);
+ va_start(args, format);
+ result= vfprintf(file->m_file, format, args);
+ va_end(args);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) result);
+ return result;
+ }
}
#endif
@@ -674,16 +682,18 @@ inline_mysql_file_vfprintf(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_WRITE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= vfprintf(file->m_file, format, args);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) result);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker) (&state, file->m_psi, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= vfprintf(file->m_file, format, args);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) result);
+ return result;
+ }
}
#endif
@@ -700,16 +710,18 @@ inline_mysql_file_fflush(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_FLUSH);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= fflush(file->m_file);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_FLUSH);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= fflush(file->m_file);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
+ }
}
#endif
@@ -732,16 +744,18 @@ inline_mysql_file_fstat(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, filenr, PSI_FILE_FSTAT);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_fstat(filenr, stat_area, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr, PSI_FILE_FSTAT);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_fstat(filenr, stat_area, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
+ }
}
#endif
@@ -758,16 +772,18 @@ inline_mysql_file_stat(
{
MY_STAT *result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_STAT, path, &locker);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- result= my_stat(path, stat_area, flags);
- PSI_FILE_CALL(end_file_open_wait)(locker, result);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STAT, path, &locker);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ result= my_stat(path, stat_area, flags);
+ PSI_FILE_CALL(end_file_open_wait)(locker, result);
+ return result;
+ }
}
#endif
@@ -784,17 +800,19 @@ inline_mysql_file_chsize(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, file, PSI_FILE_CHSIZE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) newlength, src_file,
- src_line);
- result= my_chsize(file, newlength, filler, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) newlength);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CHSIZE);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) newlength, src_file,
+ src_line);
+ result= my_chsize(file, newlength, filler, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) newlength);
+ return result;
+ }
}
#endif
@@ -814,22 +832,24 @@ inline_mysql_file_fopen(
if (likely(that != NULL))
{
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_STREAM_OPEN, filename, that);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_open_wait)
- (locker, src_file, src_line);
- that->m_file= my_fopen(filename, flags, myFlags);
- that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
- if (unlikely(that->m_file == NULL))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STREAM_OPEN,
+ filename, that);
+ if (likely(locker != NULL))
{
- my_free(that);
- return NULL;
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ that->m_file= my_fopen(filename, flags, myFlags);
+ that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
+ if (unlikely(that->m_file == NULL))
+ {
+ my_free(that);
+ return NULL;
+ }
+ return that;
}
- return that;
}
#endif
@@ -855,17 +875,20 @@ inline_mysql_file_fclose(
if (likely(file != NULL))
{
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_STREAM_CLOSE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_fclose(file->m_file, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- my_free(file);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi,
+ PSI_FILE_STREAM_CLOSE);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
+ result= my_fclose(file->m_file, flags);
+ PSI_FILE_CALL(end_file_close_wait)(locker, result);
+ my_free(file);
+ return result;
+ }
}
#endif
@@ -884,21 +907,23 @@ inline_mysql_file_fread(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_read;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_READ);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_fread(file->m_file, buffer, count, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_read= (result == 0) ? count : 0;
- else
- bytes_read= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_READ);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_fread(file->m_file, buffer, count, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_read= (result == 0) ? count : 0;
+ else
+ bytes_read= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
+ }
}
#endif
@@ -915,21 +940,23 @@ inline_mysql_file_fwrite(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_written;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_WRITE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_fwrite(file->m_file, buffer, count, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_written= (result == 0) ? count : 0;
- else
- bytes_written= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_fwrite(file->m_file, buffer, count, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_written= (result == 0) ? count : 0;
+ else
+ bytes_written= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
+ }
}
#endif
@@ -946,16 +973,18 @@ inline_mysql_file_fseek(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_SEEK);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_fseek(file->m_file, pos, whence, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_SEEK);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_fseek(file->m_file, pos, whence, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
+ }
}
#endif
@@ -972,16 +1001,18 @@ inline_mysql_file_ftell(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_stream_locker)
- (&state, file->m_psi, PSI_FILE_TELL);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_ftell(file->m_file, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)(&state, file->m_psi, PSI_FILE_TELL);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_ftell(file->m_file, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
+ }
}
#endif
@@ -998,16 +1029,19 @@ inline_mysql_file_create(
{
File file;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_CREATE, filename, &locker);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- file= my_create(filename, create_flags, access_flags, myFlags);
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
- return file;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
+ &locker);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ file= my_create(filename, create_flags, access_flags, myFlags);
+ PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
+ return file;
+ }
}
#endif
@@ -1044,16 +1078,19 @@ inline_mysql_file_open(
{
File file;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_OPEN, filename, &locker);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- file= my_open(filename, flags, myFlags);
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
- return file;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_OPEN, filename,
+ &locker);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ file= my_open(filename, flags, myFlags);
+ PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
+ return file;
+ }
}
#endif
@@ -1070,16 +1107,18 @@ inline_mysql_file_close(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, file, PSI_FILE_CLOSE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_close(file, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CLOSE);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
+ result= my_close(file, flags);
+ PSI_FILE_CALL(end_file_close_wait)(locker, result);
+ return result;
+ }
}
#endif
@@ -1096,21 +1135,23 @@ inline_mysql_file_read(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_read;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, file, PSI_FILE_READ);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_read(file, buffer, count, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_read= (result == 0) ? count : 0;
- else
- bytes_read= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_read(file, buffer, count, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_read= (result == 0) ? count : 0;
+ else
+ bytes_read= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
+ }
}
#endif
@@ -1127,21 +1168,23 @@ inline_mysql_file_write(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_written;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, file, PSI_FILE_WRITE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_write(file, buffer, count, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_written= (result == 0) ? count : 0;
- else
- bytes_written= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_write(file, buffer, count, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_written= (result == 0) ? count : 0;
+ else
+ bytes_written= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
+ }
}
#endif
@@ -1158,21 +1201,23 @@ inline_mysql_file_pread(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_read;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, file, PSI_FILE_READ);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_pread(file, buffer, count, offset, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_read= (result == 0) ? count : 0;
- else
- bytes_read= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_pread(file, buffer, count, offset, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_read= (result == 0) ? count : 0;
+ else
+ bytes_read= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
+ }
}
#endif
@@ -1189,21 +1234,23 @@ inline_mysql_file_pwrite(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_written;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, file, PSI_FILE_WRITE);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_pwrite(file, buffer, count, offset, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_written= (result == 0) ? count : 0;
- else
- bytes_written= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_pwrite(file, buffer, count, offset, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_written= (result == 0) ? count : 0;
+ else
+ bytes_written= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
+ }
}
#endif
@@ -1220,16 +1267,18 @@ inline_mysql_file_seek(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, file, PSI_FILE_SEEK);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_seek(file, pos, whence, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_SEEK);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_seek(file, pos, whence, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
+ }
}
#endif
@@ -1246,16 +1295,18 @@ inline_mysql_file_tell(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, file, PSI_FILE_TELL);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_tell(file, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_TELL);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_tell(file, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
+ }
}
#endif
@@ -1272,16 +1323,18 @@ inline_mysql_file_delete(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_DELETE, name, &locker);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_delete(name, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, name, &locker);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
+ result= my_delete(name, flags);
+ PSI_FILE_CALL(end_file_close_wait)(locker, result);
+ return result;
+ }
}
#endif
@@ -1298,16 +1351,18 @@ inline_mysql_file_rename(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_RENAME, to, &locker);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_rename(from, to, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_rename(from, to, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
+ }
}
#endif
@@ -1326,17 +1381,20 @@ inline_mysql_file_create_with_symlink(
{
File file;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_CREATE, filename, &locker);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- file= my_create_with_symlink(linkname, filename, create_flags, access_flags,
- flags);
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
- return file;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
+ &locker);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ file= my_create_with_symlink(linkname, filename, create_flags, access_flags,
+ flags);
+ PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
+ return file;
+ }
}
#endif
@@ -1357,16 +1415,19 @@ inline_mysql_file_delete_with_symlink(
char buf[FN_REFLEN];
char *fullname= fn_format(buf, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_DELETE, fullname, &locker);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_handler_delete_with_symlink(fullname, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, fullname,
+ &locker);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
+ result= my_handler_delete_with_symlink(fullname, flags);
+ PSI_FILE_CALL(end_file_close_wait)(locker, result);
+ return result;
+ }
}
#endif
@@ -1384,16 +1445,18 @@ inline_mysql_file_rename_with_symlink(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_RENAME, to, &locker);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_rename_with_symlink(from, to, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_rename_with_symlink(from, to, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
+ }
}
#endif
@@ -1410,16 +1473,18 @@ inline_mysql_file_sync(
{
int result= 0;
#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
- (&state, fd, PSI_FILE_SYNC);
- if (likely(locker != NULL))
+ if (psi_likely(pfs_enabled))
{
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_sync(fd, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd, PSI_FILE_SYNC);
+ if (likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_sync(fd, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
+ }
}
#endif
diff --git a/include/mysql/psi/mysql_idle.h b/include/mysql/psi/mysql_idle.h
index 834a1908e35..1eb19f8f684 100644
--- a/include/mysql/psi/mysql_idle.h
+++ b/include/mysql/psi/mysql_idle.h
@@ -89,7 +89,7 @@ inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
static inline void
inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
{
- if (likely(locker != NULL))
+ if (psi_likely(locker != NULL))
PSI_IDLE_CALL(end_idle_wait)(locker);
}
#endif
diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h
index 918acb65ebe..f2f1d5ce519 100644
--- a/include/mysql/psi/mysql_socket.h
+++ b/include/mysql/psi/mysql_socket.h
@@ -109,7 +109,7 @@ mysql_socket_invalid()
@param socket nstrumented socket
@param fd socket descriptor
@param addr unformatted socket address
- @param adr_len length of socket addres
+ @param adr_len length of socket address
*/
static inline void
@@ -251,7 +251,7 @@ inline_mysql_start_socket_wait(PSI_socket_locker_state *state,
const char *src_file, uint src_line)
{
struct PSI_socket_locker *locker;
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
locker= PSI_SOCKET_CALL(start_socket_wait)
(state, mysql_socket.m_psi, op, byte_count, src_file, src_line);
@@ -268,7 +268,7 @@ inline_mysql_start_socket_wait(PSI_socket_locker_state *state,
static inline void
inline_mysql_end_socket_wait(struct PSI_socket_locker *locker, size_t byte_count)
{
- if (locker != NULL)
+ if (psi_likely(locker != NULL))
PSI_SOCKET_CALL(end_socket_wait)(locker, byte_count);
}
@@ -584,12 +584,12 @@ inline_mysql_socket_bind
#ifdef HAVE_PSI_SOCKET_INTERFACE
const char *src_file, uint src_line,
#endif
- MYSQL_SOCKET mysql_socket, const struct sockaddr *addr, socklen_t len)
+ MYSQL_SOCKET mysql_socket, const struct sockaddr *addr, size_t len)
{
int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker_state state;
@@ -598,11 +598,11 @@ inline_mysql_socket_bind
(&state, mysql_socket.m_psi, PSI_SOCKET_BIND, (size_t)0, src_file, src_line);
/* Instrumented code */
- result= bind(mysql_socket.fd, addr, len);
+ result= bind(mysql_socket.fd, addr, (int)len);
/* Instrumentation end */
if (result == 0)
- PSI_SOCKET_CALL(set_socket_info)(mysql_socket.m_psi, NULL, addr, len);
+ PSI_SOCKET_CALL(set_socket_info)(mysql_socket.m_psi, NULL, addr, (socklen_t)len);
if (locker != NULL)
PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
@@ -612,7 +612,7 @@ inline_mysql_socket_bind
#endif
/* Non instrumented code */
- result= bind(mysql_socket.fd, addr, len);
+ result= bind(mysql_socket.fd, addr, (int)len);
return result;
}
@@ -629,7 +629,7 @@ inline_mysql_socket_getsockname
int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -667,7 +667,7 @@ inline_mysql_socket_connect
int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -705,7 +705,7 @@ inline_mysql_socket_getpeername
int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -743,7 +743,7 @@ inline_mysql_socket_send
ssize_t result;
DBUG_ASSERT(mysql_socket.fd != INVALID_SOCKET);
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -784,7 +784,7 @@ inline_mysql_socket_recv
ssize_t result;
DBUG_ASSERT(mysql_socket.fd != INVALID_SOCKET);
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -825,7 +825,7 @@ inline_mysql_socket_sendto
ssize_t result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -867,7 +867,7 @@ inline_mysql_socket_recvfrom
ssize_t result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -908,7 +908,7 @@ inline_mysql_socket_getsockopt
int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -947,7 +947,7 @@ inline_mysql_socket_setsockopt
int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi)
+ if (psi_likely(mysql_socket.m_psi))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -985,7 +985,7 @@ inline_mysql_socket_listen
int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -1107,7 +1107,7 @@ inline_mysql_socket_close
int result;
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
/* Instrumentation start */
PSI_socket_locker *locker;
@@ -1162,7 +1162,7 @@ inline_mysql_socket_shutdown
/* Instrumentation start */
#ifdef HAVE_PSI_SOCKET_INTERFACE
- if (mysql_socket.m_psi != NULL)
+ if (psi_likely(mysql_socket.m_psi != NULL))
{
PSI_socket_locker *locker;
PSI_socket_locker_state state;
diff --git a/include/mysql/psi/mysql_statement.h b/include/mysql/psi/mysql_statement.h
index 28543ba95a2..6d38131ea99 100644
--- a/include/mysql/psi/mysql_statement.h
+++ b/include/mysql/psi/mysql_statement.h
@@ -134,7 +134,7 @@ inline_mysql_digest_start(PSI_statement_locker *locker)
{
PSI_digest_locker* digest_locker= NULL;
- if (likely(locker != NULL))
+ if (psi_likely(locker != NULL))
digest_locker= PSI_DIGEST_CALL(digest_start)(locker);
return digest_locker;
}
@@ -144,7 +144,7 @@ inline_mysql_digest_start(PSI_statement_locker *locker)
static inline void
inline_mysql_digest_end(PSI_digest_locker *locker, const sql_digest_storage *digest)
{
- if (likely(locker != NULL))
+ if (psi_likely(locker != NULL))
PSI_DIGEST_CALL(digest_end)(locker, digest);
}
#endif
@@ -152,14 +152,14 @@ inline_mysql_digest_end(PSI_digest_locker *locker, const sql_digest_storage *dig
static inline struct PSI_statement_locker *
inline_mysql_start_statement(PSI_statement_locker_state *state,
PSI_statement_key key,
- const char *db, uint db_len,
+ const char *db, size_t db_len,
const CHARSET_INFO *charset,
const char *src_file, uint src_line)
{
PSI_statement_locker *locker;
locker= PSI_STATEMENT_CALL(get_thread_statement_locker)(state, key, charset);
- if (likely(locker != NULL))
- PSI_STATEMENT_CALL(start_statement)(locker, db, db_len, src_file, src_line);
+ if (psi_likely(locker != NULL))
+ PSI_STATEMENT_CALL(start_statement)(locker, db, (uint)db_len, src_file, src_line);
return locker;
}
@@ -167,7 +167,7 @@ static inline struct PSI_statement_locker *
inline_mysql_refine_statement(PSI_statement_locker *locker,
PSI_statement_key key)
{
- if (likely(locker != NULL))
+ if (psi_likely(locker != NULL))
{
locker= PSI_STATEMENT_CALL(refine_statement)(locker, key);
}
@@ -178,7 +178,7 @@ static inline void
inline_mysql_set_statement_text(PSI_statement_locker *locker,
const char *text, uint text_len)
{
- if (likely(locker != NULL))
+ if (psi_likely(locker != NULL))
{
PSI_STATEMENT_CALL(set_statement_text)(locker, text, text_len);
}
@@ -188,7 +188,7 @@ static inline void
inline_mysql_set_statement_lock_time(PSI_statement_locker *locker,
ulonglong count)
{
- if (likely(locker != NULL))
+ if (psi_likely(locker != NULL))
{
PSI_STATEMENT_CALL(set_statement_lock_time)(locker, count);
}
@@ -198,7 +198,7 @@ static inline void
inline_mysql_set_statement_rows_sent(PSI_statement_locker *locker,
ulonglong count)
{
- if (likely(locker != NULL))
+ if (psi_likely(locker != NULL))
{
PSI_STATEMENT_CALL(set_statement_rows_sent)(locker, count);
}
@@ -208,7 +208,7 @@ static inline void
inline_mysql_set_statement_rows_examined(PSI_statement_locker *locker,
ulonglong count)
{
- if (likely(locker != NULL))
+ if (psi_likely(locker != NULL))
{
PSI_STATEMENT_CALL(set_statement_rows_examined)(locker, count);
}
@@ -219,7 +219,7 @@ inline_mysql_end_statement(struct PSI_statement_locker *locker,
Diagnostics_area *stmt_da)
{
PSI_STAGE_CALL(end_stage)();
- if (likely(locker != NULL))
+ if (psi_likely(locker != NULL))
PSI_STATEMENT_CALL(end_statement)(locker, stmt_da);
}
#endif
diff --git a/include/mysql/psi/mysql_table.h b/include/mysql/psi/mysql_table.h
index 8c216ba2d65..c1244e38866 100644
--- a/include/mysql/psi/mysql_table.h
+++ b/include/mysql/psi/mysql_table.h
@@ -94,7 +94,7 @@
#ifdef HAVE_PSI_TABLE_INTERFACE
#define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
{ \
- if (PSI != NULL) \
+ if (psi_likely(PSI != NULL)) \
{ \
PSI_table_locker *locker; \
PSI_table_locker_state state; \
@@ -127,7 +127,7 @@
#ifdef HAVE_PSI_TABLE_INTERFACE
#define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
{ \
- if (PSI != NULL) \
+ if (psi_likely(PSI != NULL)) \
{ \
PSI_table_locker *locker; \
PSI_table_locker_state state; \
@@ -193,7 +193,7 @@ inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
enum PSI_table_lock_operation op,
ulong flags, const char *src_file, uint src_line)
{
- if (psi != NULL)
+ if (psi_likely(psi != NULL))
{
struct PSI_table_locker *locker;
locker= PSI_TABLE_CALL(start_table_lock_wait)
@@ -210,7 +210,7 @@ inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
static inline void
inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
{
- if (locker != NULL)
+ if (psi_likely(locker != NULL))
PSI_TABLE_CALL(end_table_lock_wait)(locker);
}
#endif
diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h
index b93aee622db..eab87402140 100644
--- a/include/mysql/psi/mysql_thread.h
+++ b/include/mysql/psi/mysql_thread.h
@@ -69,6 +69,35 @@
@{
*/
+#ifdef HAVE_PSI_THREAD_INTERFACE
+#define PSI_CALL_delete_current_thread PSI_THREAD_CALL(delete_current_thread)
+#define PSI_CALL_get_thread PSI_THREAD_CALL(get_thread)
+#define PSI_CALL_new_thread PSI_THREAD_CALL(new_thread)
+#define PSI_CALL_register_thread PSI_THREAD_CALL(register_thread)
+#define PSI_CALL_set_thread PSI_THREAD_CALL(set_thread)
+#define PSI_CALL_set_thread_connect_attrs PSI_THREAD_CALL(set_thread_connect_attrs)
+#define PSI_CALL_set_thread_db PSI_THREAD_CALL(set_thread_db)
+#define PSI_CALL_set_thread_id PSI_THREAD_CALL(set_thread_id)
+#define PSI_CALL_set_thread_info PSI_THREAD_CALL(set_thread_info)
+#define PSI_CALL_set_thread_start_time PSI_THREAD_CALL(set_thread_start_time)
+#define PSI_CALL_set_thread_user_host PSI_THREAD_CALL(set_thread_user_host)
+#define PSI_CALL_spawn_thread PSI_THREAD_CALL(spawn_thread)
+#else
+#define PSI_CALL_delete_current_thread() do { } while(0)
+#define PSI_CALL_get_thread() NULL
+#define PSI_CALL_new_thread(A1,A2,A3) NULL
+#define PSI_CALL_register_thread(A1,A2,A3) do { } while(0)
+#define PSI_CALL_set_thread(A1) do { } while(0)
+#define PSI_CALL_set_thread_connect_attrs(A1,A2,A3) 0
+#define PSI_CALL_set_thread_db(A1,A2) do { } while(0)
+#define PSI_CALL_set_thread_id(A1,A2) do { } while(0)
+#define PSI_CALL_set_thread_info(A1, A2) do { } while(0)
+#define PSI_CALL_set_thread_start_time(A1) do { } while(0)
+#define PSI_CALL_set_thread_user_host(A1, A2, A3, A4) do { } while(0)
+#define PSI_CALL_spawn_thread(A1, A2, A3, A4, A5) 0
+#endif
+
+
/**
An instrumented mutex structure.
@sa mysql_mutex_t
@@ -580,7 +609,7 @@ typedef struct st_mysql_cond mysql_cond_t;
/**
@def mysql_thread_set_psi_id(I)
- Set the thread indentifier for the instrumentation.
+ Set the thread identifier for the instrumentation.
@param I The thread identifier
*/
#ifdef HAVE_PSI_THREAD_INTERFACE
@@ -660,7 +689,7 @@ static inline int inline_mysql_mutex_lock(
int result;
#ifdef HAVE_PSI_MUTEX_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_mutex_locker *locker;
@@ -703,7 +732,7 @@ static inline int inline_mysql_mutex_trylock(
int result;
#ifdef HAVE_PSI_MUTEX_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_mutex_locker *locker;
@@ -746,7 +775,7 @@ static inline int inline_mysql_mutex_unlock(
int result;
#ifdef HAVE_PSI_MUTEX_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
PSI_MUTEX_CALL(unlock_mutex)(that->m_psi);
#endif
@@ -813,7 +842,7 @@ static inline int inline_mysql_rwlock_destroy(
mysql_rwlock_t *that)
{
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi);
that->m_psi= NULL;
@@ -827,7 +856,7 @@ static inline int inline_mysql_prlock_destroy(
mysql_prlock_t *that)
{
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi);
that->m_psi= NULL;
@@ -847,7 +876,7 @@ static inline int inline_mysql_rwlock_rdlock(
int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_rwlock_locker *locker;
@@ -883,7 +912,7 @@ static inline int inline_mysql_prlock_rdlock(
int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_rwlock_locker *locker;
@@ -919,7 +948,7 @@ static inline int inline_mysql_rwlock_wrlock(
int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_rwlock_locker *locker;
@@ -955,7 +984,7 @@ static inline int inline_mysql_prlock_wrlock(
int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_rwlock_locker *locker;
@@ -991,7 +1020,7 @@ static inline int inline_mysql_rwlock_tryrdlock(
int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_rwlock_locker *locker;
@@ -1026,7 +1055,7 @@ static inline int inline_mysql_rwlock_trywrlock(
int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_rwlock_locker *locker;
@@ -1056,7 +1085,7 @@ static inline int inline_mysql_rwlock_unlock(
{
int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi);
#endif
result= rw_unlock(&that->m_rwlock);
@@ -1069,7 +1098,7 @@ static inline int inline_mysql_prlock_unlock(
{
int result;
#ifdef HAVE_PSI_RWLOCK_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi);
#endif
result= rw_pr_unlock(&that->m_prlock);
@@ -1113,7 +1142,7 @@ static inline int inline_mysql_cond_destroy(
mysql_cond_t *that)
{
#ifdef HAVE_PSI_COND_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
PSI_COND_CALL(destroy_cond)(that->m_psi);
that->m_psi= NULL;
@@ -1133,7 +1162,7 @@ static inline int inline_mysql_cond_wait(
int result;
#ifdef HAVE_PSI_COND_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_cond_locker *locker;
@@ -1170,7 +1199,7 @@ static inline int inline_mysql_cond_timedwait(
int result;
#ifdef HAVE_PSI_COND_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
{
/* Instrumentation start */
PSI_cond_locker *locker;
@@ -1182,7 +1211,7 @@ static inline int inline_mysql_cond_timedwait(
result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
/* Instrumentation end */
- if (locker != NULL)
+ if (psi_likely(locker != NULL))
PSI_COND_CALL(end_cond_wait)(locker, result);
return result;
@@ -1200,7 +1229,7 @@ static inline int inline_mysql_cond_signal(
{
int result;
#ifdef HAVE_PSI_COND_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
PSI_COND_CALL(signal_cond)(that->m_psi);
#endif
result= pthread_cond_signal(&that->m_cond);
@@ -1212,7 +1241,7 @@ static inline int inline_mysql_cond_broadcast(
{
int result;
#ifdef HAVE_PSI_COND_INTERFACE
- if (that->m_psi != NULL)
+ if (psi_likely(that->m_psi != NULL))
PSI_COND_CALL(broadcast_cond)(that->m_psi);
#endif
result= pthread_cond_broadcast(&that->m_cond);
diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h
index 3f7b04b0841..238471c7af1 100644
--- a/include/mysql/psi/psi.h
+++ b/include/mysql/psi/psi.h
@@ -47,6 +47,21 @@
#error "You must include my_global.h in the code for the build to be correct."
#endif
+/*
+ If PSI_ON_BY_DFAULT is defined, assume PSI will be enabled by default and
+ optimize jumps testing for PSI this case. If not, optimize the binary for
+ that PSI is not enabled
+*/
+
+#ifdef PSI_ON_BY_DEFAULT
+#define psi_likely(A) likely(A)
+#define psi_unlikely(A) unlikely(A)
+#else
+#define psi_likely(A) unlikely(A)
+#define psi_unlikely(A) likely(A)
+#endif
+
+
C_MODE_START
struct TABLE_SHARE;
@@ -2353,6 +2368,7 @@ typedef struct PSI_stage_info_none PSI_stage_info;
#endif /* HAVE_PSI_INTERFACE */
+extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
/*
diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp
index 17ac0271da2..ef18f59e4a9 100644
--- a/include/mysql/psi/psi_abi_v1.h.pp
+++ b/include/mysql/psi/psi_abi_v1.h.pp
@@ -616,5 +616,6 @@ typedef struct PSI_file_locker_state_v1 PSI_file_locker_state;
typedef struct PSI_table_locker_state_v1 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
+extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
C_MODE_END
diff --git a/include/mysql/psi/psi_abi_v2.h.pp b/include/mysql/psi/psi_abi_v2.h.pp
index 4e81fd66ca4..adf1af7cfae 100644
--- a/include/mysql/psi/psi_abi_v2.h.pp
+++ b/include/mysql/psi/psi_abi_v2.h.pp
@@ -209,5 +209,6 @@ typedef struct PSI_file_locker_state_v2 PSI_file_locker_state;
typedef struct PSI_table_locker_state_v2 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
+extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
C_MODE_END
diff --git a/include/mysql/service_my_print_error.h b/include/mysql/service_my_print_error.h
index 4026233ea5b..64e875d83ca 100644
--- a/include/mysql/service_my_print_error.h
+++ b/include/mysql/service_my_print_error.h
@@ -50,11 +50,12 @@ extern struct my_print_error_service_st {
#define my_printv_error(A,B,C,D) my_print_error_service->my_printv_error_func(A,B,C,D)
#else
-
+#ifndef MY_ERROR_DEFINED
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
-#endif
+#endif /* MY_ERROR_DEFINED */
+#endif /* MYSQL_DYNAMIC_PLUGIN */
#ifdef __cplusplus
}
diff --git a/include/mysql/service_thd_alloc.h b/include/mysql/service_thd_alloc.h
index 8b3ac707fc1..0be4687b8e6 100644
--- a/include/mysql/service_thd_alloc.h
+++ b/include/mysql/service_thd_alloc.h
@@ -42,13 +42,21 @@ struct st_mysql_lex_string
};
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+struct st_mysql_const_lex_string
+{
+ const char *str;
+ size_t length;
+};
+typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
+
extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(MYSQL_THD, size_t);
void *(*thd_calloc_func)(MYSQL_THD, size_t);
char *(*thd_strdup_func)(MYSQL_THD, const char *);
char *(*thd_strmake_func)(MYSQL_THD, const char *, size_t);
void *(*thd_memdup_func)(MYSQL_THD, const void*, size_t);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(MYSQL_THD, MYSQL_LEX_STRING *,
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(MYSQL_THD,
+ MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
@@ -115,9 +123,10 @@ void *thd_memdup(MYSQL_THD thd, const void* str, size_t size);
@see thd_alloc()
*/
-MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
- const char *str, size_t size,
- int allocate_lex_string);
+MYSQL_CONST_LEX_STRING
+*thd_make_lex_string(MYSQL_THD thd, MYSQL_CONST_LEX_STRING *lex_str,
+ const char *str, size_t size,
+ int allocate_lex_string);
#endif
diff --git a/include/mysql/service_thd_rnd.h b/include/mysql/service_thd_rnd.h
index 78a93fe172a..8761077ea73 100644
--- a/include/mysql/service_thd_rnd.h
+++ b/include/mysql/service_thd_rnd.h
@@ -18,7 +18,7 @@
@file
This service provides access to the thd-local random number generator.
- It's preferrable over the global one, because concurrent threads
+ It's preferable over the global one, because concurrent threads
can generate random numbers without fighting each other over the access
to the shared rnd state.
*/
diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h
index 54b9eb9250c..e9c3b0fa86a 100644
--- a/include/mysql/service_wsrep.h
+++ b/include/mysql/service_wsrep.h
@@ -84,6 +84,8 @@ extern struct wsrep_service_st {
void (*wsrep_aborting_thd_enqueue_func)(THD *thd);
bool (*wsrep_consistency_check_func)(THD *thd);
int (*wsrep_is_wsrep_xid_func)(const struct xid_t *xid);
+ long long (*wsrep_xid_seqno_func)(const struct xid_t *xid);
+ const unsigned char* (*wsrep_xid_uuid_func)(const struct xid_t *xid);
void (*wsrep_lock_rollback_func)();
int (*wsrep_on_func)(MYSQL_THD);
void (*wsrep_post_commit_func)(THD* thd, bool all);
@@ -132,6 +134,8 @@ extern struct wsrep_service_st {
#define wsrep_aborting_thd_enqueue(T) wsrep_service->wsrep_aborting_thd_enqueue_func(T)
#define wsrep_consistency_check(T) wsrep_service->wsrep_consistency_check_func(T)
#define wsrep_is_wsrep_xid(X) wsrep_service->wsrep_is_wsrep_xid_func(X)
+#define wsrep_xid_seqno(X) wsrep_service->wsrep_xid_seqno_func(X)
+#define wsrep_xid_uuid(X) wsrep_service->wsrep_xid_uuid_func(X)
#define wsrep_lock_rollback() wsrep_service->wsrep_lock_rollback_func()
#define wsrep_on(X) wsrep_service->wsrep_on_func(X)
#define wsrep_post_commit(T,A) wsrep_service->wsrep_post_commit_func(T,A)
@@ -195,6 +199,8 @@ enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd);
enum wsrep_query_state wsrep_thd_query_state(THD *thd);
enum wsrep_trx_status wsrep_run_wsrep_commit(THD *thd, bool all);
int wsrep_is_wsrep_xid(const struct xid_t* xid);
+long long wsrep_xid_seqno(const struct xid_t* xid);
+const unsigned char* wsrep_xid_uuid(const struct xid_t* xid);
int wsrep_on(MYSQL_THD thd);
int wsrep_thd_retry_counter(THD *thd);
int wsrep_trx_is_aborting(MYSQL_THD thd);
diff --git a/include/mysql_com.h b/include/mysql_com.h
index 398bf9058df..b1534b1d746 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -152,7 +152,7 @@ enum enum_indicator_type
*/
#define SCRAMBLE_LENGTH 20
#define SCRAMBLE_LENGTH_323 8
-/* length of password stored in the db: new passwords are preceeded with '*' */
+/* length of password stored in the db: new passwords are preceded with '*' */
#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
@@ -193,6 +193,17 @@ enum enum_indicator_type
#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3U << FIELD_FLAGS_COLUMN_FORMAT)
#define FIELD_IS_DROPPED (1U << 26) /* Intern: Field is being dropped */
+#define VERS_SYS_START_FLAG (1 << 27) /* autogenerated column declared with
+ `generated always as row start`
+ (see II.a SQL Standard) */
+#define VERS_SYS_END_FLAG (1 << 28) /* autogenerated column declared with
+ `generated always as row end`
+ (see II.a SQL Standard).*/
+#define VERS_SYSTEM_FIELD (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG)
+#define VERS_UPDATE_UNVERSIONED_FLAG (1 << 29) /* column that doesn't support
+ system versioning when table
+ itself supports it*/
+
#define REFRESH_GRANT (1ULL << 0) /* Refresh grant tables */
#define REFRESH_LOG (1ULL << 1) /* Start on new log file */
#define REFRESH_TABLES (1ULL << 2) /* close all tables */
@@ -205,7 +216,7 @@ enum enum_indicator_type
and truncate the index */
/* The following can't be set with mysql_refresh() */
-#define REFRESH_ERROR_LOG (1ULL << 8) /* Rotate only the erorr log */
+#define REFRESH_ERROR_LOG (1ULL << 8) /* Rotate only the error log */
#define REFRESH_ENGINE_LOG (1ULL << 9) /* Flush all storage engine logs */
#define REFRESH_BINARY_LOG (1ULL << 10) /* Flush the binary log */
#define REFRESH_RELAY_LOG (1ULL << 11) /* Flush the relay log */
@@ -289,7 +300,7 @@ enum enum_indicator_type
#endif
/*
- Gather all possible capabilites (flags) supported by the server
+ Gather all possible capabilities (flags) supported by the server
MARIADB_* flags supported only by MariaDB connector(s).
*/
@@ -423,7 +434,7 @@ typedef struct st_vio Vio;
#define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */
#define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */
#define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */
-#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
+#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR column */
#define MAX_BLOB_WIDTH 16777216 /* Default width for blob */
typedef struct st_net {
@@ -486,7 +497,10 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_TIMESTAMP2,
MYSQL_TYPE_DATETIME2,
MYSQL_TYPE_TIME2,
-
+ /* Compressed types are only used internally for RBR. */
+ MYSQL_TYPE_BLOB_COMPRESSED= 140,
+ MYSQL_TYPE_VARCHAR_COMPRESSED= 141,
+
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248,
@@ -646,7 +660,7 @@ typedef struct st_udf_args
char **args; /* Pointer to argument */
unsigned long *lengths; /* Length of string arguments */
char *maybe_null; /* Set to 1 for all maybe_null args */
- char **attributes; /* Pointer to attribute name */
+ const char **attributes; /* Pointer to attribute name */
unsigned long *attribute_lengths; /* Length of attribute arguments */
void *extension;
} UDF_ARGS;
@@ -696,7 +710,7 @@ void scramble(char *to, const char *message, const char *password);
my_bool check_scramble(const unsigned char *reply, const char *message,
const unsigned char *hash_stage2);
void get_salt_from_password(unsigned char *res, const char *password);
-char *octet2hex(char *to, const char *str, unsigned int len);
+char *octet2hex(char *to, const char *str, size_t len);
/* end of password.c */
diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in
index 16876dbfedd..da572953fc5 100644
--- a/include/mysql_version.h.in
+++ b/include/mysql_version.h.in
@@ -22,6 +22,7 @@
#define MARIADB_UNIX_ADDR "@MYSQL_UNIX_ADDR@"
#define MYSQL_CONFIG_NAME "my"
#define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@"
+#define SERVER_MATURITY_LEVEL @SERVER_MATURITY_LEVEL@
#define MYSQL_PORT MARIADB_PORT
#define MYSQL_UNIX_ADDR MARIADB_UNIX_ADDR
diff --git a/include/password.h b/include/password.h
index 917ec1acc00..a076a6a37e9 100644
--- a/include/password.h
+++ b/include/password.h
@@ -16,8 +16,6 @@
#ifndef PASSWORD_INCLUDED
#define PASSWORD_INCLUDED
-#include "my_global.h"
-
C_MODE_START
void my_make_scrambled_password_323(char *to, const char *password,
diff --git a/include/queues.h b/include/queues.h
index 99e640413e3..e9948857dde 100644
--- a/include/queues.h
+++ b/include/queues.h
@@ -25,14 +25,12 @@
/*
Code for generell handling of priority Queues.
- Implemention of queues from "Algoritms in C" by Robert Sedgewick.
+ Implementation of queues from "Algorithms in C" by Robert Sedgewick.
*/
#ifndef _queues_h
#define _queues_h
-#include "my_global.h" /* uchar */
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/include/source_revision.h.in b/include/source_revision.h.in
new file mode 100644
index 00000000000..991df992e2f
--- /dev/null
+++ b/include/source_revision.h.in
@@ -0,0 +1 @@
+#define SOURCE_REVISION "@SOURCE_REVISION@"
diff --git a/include/ssl_compat.h b/include/ssl_compat.h
index 2777ae94527..c94b9671d5f 100644
--- a/include/ssl_compat.h
+++ b/include/ssl_compat.h
@@ -30,9 +30,9 @@
#define EVP_CIPHER_CTX_SIZE 176
#define EVP_MD_CTX_SIZE 48
#undef EVP_MD_CTX_init
-#define EVP_MD_CTX_init(X) do { bzero((X), EVP_MD_CTX_SIZE); EVP_MD_CTX_reset(X); } while(0)
+#define EVP_MD_CTX_init(X) do { memset((X), 0, EVP_MD_CTX_SIZE); EVP_MD_CTX_reset(X); } while(0)
#undef EVP_CIPHER_CTX_init
-#define EVP_CIPHER_CTX_init(X) do { bzero((X), EVP_CIPHER_CTX_SIZE); EVP_CIPHER_CTX_reset(X); } while(0)
+#define EVP_CIPHER_CTX_init(X) do { memset((X), 0, EVP_CIPHER_CTX_SIZE); EVP_CIPHER_CTX_reset(X); } while(0)
/*
Macros below are deprecated. OpenSSL 1.1 may define them or not,
diff --git a/include/thread_pool_priv.h b/include/thread_pool_priv.h
index f27391adbfa..f7d2da0b082 100644
--- a/include/thread_pool_priv.h
+++ b/include/thread_pool_priv.h
@@ -58,7 +58,6 @@ 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);
-ulong thd_get_net_wait_timeout(THD *thd);
my_socket thd_get_fd(THD *thd);
int thd_store_globals(THD* thd);
diff --git a/include/typelib.h b/include/typelib.h
index 530767ebe01..b20724fe05e 100644
--- a/include/typelib.h
+++ b/include/typelib.h
@@ -33,7 +33,7 @@ extern int find_type_with_warning(const char *x, TYPELIB *typelib,
#define FIND_TYPE_BASIC 0
/** makes @c find_type() require the whole name, no prefix */
#define FIND_TYPE_NO_PREFIX (1U << 0)
-/** always implicitely on, so unused, but old code may pass it */
+/** always implicitly on, so unused, but old code may pass it */
#define FIND_TYPE_NO_OVERWRITE 0
/** makes @c find_type() accept a number. Not used either */
#define FIND_TYPE_ALLOW_NUMBER 0
diff --git a/include/violite.h b/include/violite.h
index b9ab7aeb99a..bb3fd8f6b6c 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -51,6 +51,14 @@ enum enum_vio_io_event
VIO_IO_EVENT_CONNECT
};
+struct vio_keepalive_opts
+{
+ int interval;
+ int idle;
+ int probes;
+};
+
+
#define VIO_LOCALHOST 1U /* a localhost connection */
#define VIO_BUFFERED_READ 2U /* use buffered read */
#define VIO_READ_BUFFER_SIZE 16384U /* size of read buffer */
@@ -84,6 +92,7 @@ my_bool vio_is_blocking(Vio *vio);
int vio_fastsend(Vio *vio);
/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */
int vio_keepalive(Vio *vio, my_bool onoff);
+int vio_set_keepalive_options(Vio * vio, const struct vio_keepalive_opts *opts);
/* Whenever we should retry the last read/write operation. */
my_bool vio_should_retry(Vio *vio);
/* Check that operation was timed out */
@@ -101,9 +110,7 @@ my_bool vio_peer_addr(Vio *vio, char *buf, uint16 *port, size_t buflen);
/* Wait for an I/O event notification. */
int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout);
my_bool vio_is_connected(Vio *vio);
-#ifndef DBUG_OFF
ssize_t vio_pending(Vio *vio);
-#endif
/* Set timeout for a network operation. */
extern int vio_timeout(Vio *vio, uint which, int timeout_sec);
extern void vio_set_wait_callback(void (*before_wait)(void),
@@ -112,7 +119,9 @@ extern void vio_set_wait_callback(void (*before_wait)(void),
my_bool vio_socket_connect(Vio *vio, struct sockaddr *addr, socklen_t len,
int timeout);
-my_bool vio_get_normalized_ip_string(const struct sockaddr *addr, int addr_length,
+void vio_get_normalized_ip(const struct sockaddr *src, size_t src_length, struct sockaddr *dst);
+
+my_bool vio_get_normalized_ip_string(const struct sockaddr *addr, size_t addr_length,
char *ip_string, size_t ip_string_size);
my_bool vio_is_no_name_error(int err_code);
@@ -215,7 +224,6 @@ enum SSL_type
SSL_TYPE_SPECIFIED
};
-
/* HFTODO - hide this if we don't want client in embedded server */
/* This structure is for every connection on both sides */
struct st_vio
@@ -225,7 +233,6 @@ struct st_vio
int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
struct sockaddr_storage local; /* Local internet address */
struct sockaddr_storage remote; /* Remote internet address */
- int addrLen; /* Length of remote address */
enum enum_vio_type type; /* Type of connection */
const char *desc; /* String description */
char *read_buffer; /* buffer for vio_read_buff */
@@ -274,6 +281,7 @@ struct st_vio
OVERLAPPED overlapped;
DWORD read_timeout_ms;
DWORD write_timeout_ms;
+ int shutdown_flag;
#endif
};
#endif /* vio_violite_h_ */
diff --git a/include/waiting_threads.h b/include/waiting_threads.h
index 217b49bd8b2..f785cc8988b 100644
--- a/include/waiting_threads.h
+++ b/include/waiting_threads.h
@@ -16,7 +16,6 @@
#ifndef _waiting_threads_h
#define _waiting_threads_h
-#include <my_global.h>
#include <my_sys.h>
#include <lf.h>
diff --git a/include/wqueue.h b/include/wqueue.h
index ce7fe4e4057..de7a71701fc 100644
--- a/include/wqueue.h
+++ b/include/wqueue.h
@@ -18,7 +18,6 @@
#ifndef WQUEUE_INCLUDED
#define WQUEUE_INCLUDED
-#include <my_global.h>
#include <my_pthread.h>
/* info about requests in a waiting queue */
diff --git a/include/wsrep.h b/include/wsrep.h
index f0d42265ec5..a3a58324f3e 100644
--- a/include/wsrep.h
+++ b/include/wsrep.h
@@ -62,6 +62,7 @@
#define WSREP_WARN(...)
#define WSREP_ERROR(...)
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)
+#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_)
#define WSREP_TO_ISOLATION_END
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
#define WSREP_SYNC_WAIT(thd_, before_) do { } while(0)