summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt7
-rw-r--r--include/atomic/gcc_builtins.h6
-rw-r--r--include/atomic/rwlock.h38
-rw-r--r--include/base64.h15
-rw-r--r--include/big_endian.h82
-rw-r--r--include/byte_order_generic.h95
-rw-r--r--include/byte_order_generic_x86.h87
-rw-r--r--include/byte_order_generic_x86_64.h75
-rw-r--r--include/decimal.h8
-rw-r--r--include/errmsg.h12
-rw-r--r--include/ft_global.h21
-rw-r--r--include/hash.h20
-rw-r--r--include/heap.h1
-rw-r--r--include/keycache.h13
-rw-r--r--include/lf.h23
-rw-r--r--include/little_endian.h75
-rw-r--r--include/m_ctype.h236
-rw-r--r--include/m_string.h16
-rw-r--r--include/ma_dyncol.h144
-rw-r--r--include/maria.h32
-rw-r--r--include/my_alarm.h2
-rw-r--r--include/my_base.h102
-rw-r--r--include/my_bitmap.h13
-rw-r--r--include/my_byteorder.h54
-rw-r--r--include/my_check_opt.h3
-rw-r--r--include/my_context.h6
-rw-r--r--include/my_dbug.h6
-rw-r--r--include/my_default.h50
-rw-r--r--include/my_dir.h8
-rw-r--r--include/my_getopt.h7
-rw-r--r--include/my_global.h410
-rw-r--r--include/my_handler_errors.h100
-rw-r--r--include/my_md5.h58
-rw-r--r--include/my_net.h10
-rw-r--r--include/my_pthread.h68
-rw-r--r--include/my_rnd.h32
-rw-r--r--include/my_stacktrace.h5
-rw-r--r--include/my_sys.h177
-rw-r--r--include/my_time.h65
-rw-r--r--include/my_tree.h6
-rw-r--r--include/my_user.h6
-rw-r--r--include/my_valgrind.h4
-rw-r--r--include/my_xml.h11
-rw-r--r--include/myisam.h37
-rw-r--r--include/myisamchk.h5
-rw-r--r--include/myisammrg.h3
-rw-r--r--include/mysql.h25
-rw-r--r--include/mysql.h.pp29
-rw-r--r--include/mysql/plugin.h56
-rw-r--r--include/mysql/plugin_audit.h.pp68
-rw-r--r--include/mysql/plugin_auth.h.pp68
-rw-r--r--include/mysql/plugin_auth_common.h21
-rw-r--r--include/mysql/plugin_ftparser.h.pp68
-rw-r--r--include/mysql/psi/mysql_file.h869
-rw-r--r--include/mysql/psi/mysql_idle.h92
-rw-r--r--include/mysql/psi/mysql_socket.h1161
-rw-r--r--include/mysql/psi/mysql_stage.h72
-rw-r--r--include/mysql/psi/mysql_statement.h222
-rw-r--r--include/mysql/psi/mysql_table.h207
-rw-r--r--include/mysql/psi/mysql_thread.h608
-rw-r--r--include/mysql/psi/psi.h1360
-rw-r--r--include/mysql/psi/psi_abi_v0.h24
-rw-r--r--include/mysql/psi/psi_abi_v0.h.pp47
-rw-r--r--include/mysql/psi/psi_abi_v1.h4
-rw-r--r--include/mysql/psi/psi_abi_v1.h.pp404
-rw-r--r--include/mysql/psi/psi_abi_v2.h2
-rw-r--r--include/mysql/psi/psi_abi_v2.h.pp99
-rw-r--r--include/mysql/service_debug_sync.h13
-rw-r--r--include/mysql/service_my_plugin_log.h64
-rw-r--r--include/mysql/service_progress_report.h2
-rw-r--r--include/mysql/service_sha1.h57
-rw-r--r--include/mysql/service_thd_autoinc.h53
-rw-r--r--include/mysql/service_thd_error_context.h93
-rw-r--r--include/mysql/service_thd_timezone.h73
-rw-r--r--include/mysql/service_thd_wait.h3
-rw-r--r--include/mysql/service_thread_scheduler.h65
-rw-r--r--include/mysql/services.h8
-rw-r--r--include/mysql_async.h10
-rw-r--r--include/mysql_com.h136
-rw-r--r--include/mysql_com_server.h41
-rw-r--r--include/mysql_time.h11
-rw-r--r--include/probes_mysql_nodtrace.h.in116
-rw-r--r--include/queues.h1
-rw-r--r--include/service_versions.h14
-rw-r--r--include/sha1.h90
-rw-r--r--include/sql_common.h6
-rw-r--r--include/sslopt-case.h7
-rw-r--r--include/sslopt-longopts.h7
-rw-r--r--include/sslopt-vars.h14
-rw-r--r--include/thread_pool_priv.h3
-rw-r--r--include/violite.h84
91 files changed, 6776 insertions, 1955 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 219a2917917..d0c4768e882 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -24,6 +24,13 @@ SET(HEADERS_GEN_CONFIGURE
SET(HEADERS
mysql.h
mysql_com.h
+ mysql_com_server.h
+ my_byteorder.h
+ byte_order_generic.h
+ byte_order_generic_x86.h
+ byte_order_generic_x86_64.h
+ little_endian.h
+ big_endian.h
mysql_time.h
ma_dyncol.h
my_list.h
diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h
index fb6a537d204..56a0323aedf 100644
--- a/include/atomic/gcc_builtins.h
+++ b/include/atomic/gcc_builtins.h
@@ -31,6 +31,12 @@
#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) \
diff --git a/include/atomic/rwlock.h b/include/atomic/rwlock.h
index f6bf7d0b76f..2ffdd384cc5 100644
--- a/include/atomic/rwlock.h
+++ b/include/atomic/rwlock.h
@@ -41,13 +41,6 @@ typedef char my_atomic_rwlock_t;
typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
-#ifndef SAFE_MUTEX
-
-/*
- we're using read-write lock macros but map them to mutex locks, and they're
- faster. Still, having semantically rich API we can change the
- underlying implementation, if necessary.
-*/
#define my_atomic_rwlock_destroy(name) pthread_mutex_destroy(& (name)->rw)
#define my_atomic_rwlock_init(name) pthread_mutex_init(& (name)->rw, 0)
#define my_atomic_rwlock_rdlock(name) pthread_mutex_lock(& (name)->rw)
@@ -55,37 +48,6 @@ typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
#define my_atomic_rwlock_rdunlock(name) pthread_mutex_unlock(& (name)->rw)
#define my_atomic_rwlock_wrunlock(name) pthread_mutex_unlock(& (name)->rw)
-#else /* SAFE_MUTEX */
-
-/*
- SAFE_MUTEX pollutes the compiling name space with macros
- that alter pthread_mutex_t, pthread_mutex_init, etc.
- Atomic operations should never use the safe mutex wrappers.
- Unfortunately, there is no way to have both:
- - safe mutex macros expanding pthread_mutex_lock to safe_mutex_lock
- - my_atomic macros expanding to unmodified pthread_mutex_lock
- inlined in the same compilation unit.
- So, in case of SAFE_MUTEX, a function call is required.
- Given that SAFE_MUTEX is a debugging facility,
- this extra function call is not a performance concern for
- production builds.
-*/
-C_MODE_START
-extern void plain_pthread_mutex_init(safe_mutex_t *);
-extern void plain_pthread_mutex_destroy(safe_mutex_t *);
-extern void plain_pthread_mutex_lock(safe_mutex_t *);
-extern void plain_pthread_mutex_unlock(safe_mutex_t *);
-C_MODE_END
-
-#define my_atomic_rwlock_destroy(name) plain_pthread_mutex_destroy(&(name)->rw)
-#define my_atomic_rwlock_init(name) plain_pthread_mutex_init(&(name)->rw)
-#define my_atomic_rwlock_rdlock(name) plain_pthread_mutex_lock(&(name)->rw)
-#define my_atomic_rwlock_wrlock(name) plain_pthread_mutex_lock(&(name)->rw)
-#define my_atomic_rwlock_rdunlock(name) plain_pthread_mutex_unlock(&(name)->rw)
-#define my_atomic_rwlock_wrunlock(name) plain_pthread_mutex_unlock(&(name)->rw)
-
-#endif /* SAFE_MUTEX */
-
#define MY_ATOMIC_MODE "mutex"
#ifndef MY_ATOMIC_MODE_RWLOCKS
#define MY_ATOMIC_MODE_RWLOCKS 1
diff --git a/include/base64.h b/include/base64.h
index 1069c286a7a..9a843b5088e 100644
--- a/include/base64.h
+++ b/include/base64.h
@@ -27,11 +27,21 @@ extern "C" {
int base64_needed_encoded_length(int length_of_data);
/*
+ Maximum length base64_encode_needed_length() can accept with no overflow.
+*/
+int base64_encode_max_arg_length(void);
+
+/*
Calculate how much memory needed for dst of base64_decode()
*/
int base64_needed_decoded_length(int length_of_encoded_data);
/*
+ Maximum length base64_decode_needed_length() can accept with no overflow.
+*/
+int base64_decode_max_arg_length();
+
+/*
Encode data as a base64 string
*/
int base64_encode(const void *src, size_t src_len, char *dst);
@@ -40,7 +50,10 @@ int base64_encode(const void *src, size_t src_len, char *dst);
Decode a base64 string into data
*/
int base64_decode(const char *src, size_t src_len,
- void *dst, const char **end_ptr);
+ void *dst, const char **end_ptr, int flags);
+
+/* Allow multuple chunks 'AAA= AA== AA==', binlog uses this */
+#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1
#ifdef __cplusplus
diff --git a/include/big_endian.h b/include/big_endian.h
new file mode 100644
index 00000000000..021b6abc383
--- /dev/null
+++ b/include/big_endian.h
@@ -0,0 +1,82 @@
+/* Copyright (c) 2012, 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 02111-1307 USA */
+
+/*
+ Data in big-endian format.
+*/
+#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
+ *((T)+1)=(char) ((uchar *) &A)[2];\
+ *((T)+2)=(char) ((uchar *) &A)[1];\
+ *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
+
+#define float4get(V,M) do { float def_temp;\
+ ((uchar*) &def_temp)[0]=(M)[3];\
+ ((uchar*) &def_temp)[1]=(M)[2];\
+ ((uchar*) &def_temp)[2]=(M)[1];\
+ ((uchar*) &def_temp)[3]=(M)[0];\
+ (V)=def_temp; } while(0)
+
+#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
+ *((T)+1)=(char) ((uchar *) &V)[6];\
+ *((T)+2)=(char) ((uchar *) &V)[5];\
+ *((T)+3)=(char) ((uchar *) &V)[4];\
+ *((T)+4)=(char) ((uchar *) &V)[3];\
+ *((T)+5)=(char) ((uchar *) &V)[2];\
+ *((T)+6)=(char) ((uchar *) &V)[1];\
+ *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
+
+#define float8get(V,M) do { double def_temp;\
+ ((uchar*) &def_temp)[0]=(M)[7];\
+ ((uchar*) &def_temp)[1]=(M)[6];\
+ ((uchar*) &def_temp)[2]=(M)[5];\
+ ((uchar*) &def_temp)[3]=(M)[4];\
+ ((uchar*) &def_temp)[4]=(M)[3];\
+ ((uchar*) &def_temp)[5]=(M)[2];\
+ ((uchar*) &def_temp)[6]=(M)[1];\
+ ((uchar*) &def_temp)[7]=(M)[0];\
+ (V) = def_temp; } while(0)
+
+#define ushortget(V,M) do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
+ ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
+#define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\
+ ((short) ((short) (M)[0]) << 8)); } while(0)
+#define longget(V,M) do { int32 def_temp;\
+ ((uchar*) &def_temp)[0]=(M)[0];\
+ ((uchar*) &def_temp)[1]=(M)[1];\
+ ((uchar*) &def_temp)[2]=(M)[2];\
+ ((uchar*) &def_temp)[3]=(M)[3];\
+ (V)=def_temp; } while(0)
+#define ulongget(V,M) do { uint32 def_temp;\
+ ((uchar*) &def_temp)[0]=(M)[0];\
+ ((uchar*) &def_temp)[1]=(M)[1];\
+ ((uchar*) &def_temp)[2]=(M)[2];\
+ ((uchar*) &def_temp)[3]=(M)[3];\
+ (V)=def_temp; } while(0)
+#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
+ *(((char*)T)+1)=(char)(def_temp); \
+ *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
+#define longstore(T,A) do { *(((char*)T)+3)=((A));\
+ *(((char*)T)+2)=(((A) >> 8));\
+ *(((char*)T)+1)=(((A) >> 16));\
+ *(((char*)T)+0)=(((A) >> 24)); } while(0)
+
+#define floatget(V,M) memcpy(&V, (M), sizeof(float))
+/* Cast away type qualifiers (necessary as macro takes argument by value). */
+#define floatstore(T,V) memcpy((T), (void*) (&V), sizeof(float))
+#define doubleget(V,M) memcpy(&V, (M), sizeof(double))
+/* Cast away type qualifiers (necessary as macro takes argument by value). */
+#define doublestore(T,V) memcpy((T), (void*) &V, sizeof(double))
+#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong))
+#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong))
diff --git a/include/byte_order_generic.h b/include/byte_order_generic.h
new file mode 100644
index 00000000000..d4ac27eeb9c
--- /dev/null
+++ b/include/byte_order_generic.h
@@ -0,0 +1,95 @@
+/* Copyright (c) 2001, 2012, 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 02111-1307 USA */
+
+/*
+ Endianness-independent definitions for architectures other
+ than the x86 architecture.
+*/
+#define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\
+ ((int16) ((int16) (A)[1]) << 8))
+#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
+ (((uint32) 255L << 24) | \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])) : \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])))
+#define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\
+ (((int32) ((uchar) (A)[1]) << 8)) +\
+ (((int32) ((uchar) (A)[2]) << 16)) +\
+ (((int32) ((int16) (A)[3]) << 24)))
+#define sint8korr(A) (longlong) uint8korr(A)
+#define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\
+ ((uint16) ((uchar) (A)[1]) << 8))
+#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16))
+#define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24))
+#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) ((uchar) (A)[4])) << 32))
+#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) + \
+ (((uint32) ((uchar) (A)[1])) << 8) + \
+ (((uint32) ((uchar) (A)[2])) << 16) + \
+ (((uint32) ((uchar) (A)[3])) << 24)) + \
+ (((ulonglong) ((uchar) (A)[4])) << 32) + \
+ (((ulonglong) ((uchar) (A)[5])) << 40))
+#define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) (((uint32) ((uchar) (A)[4])) +\
+ (((uint32) ((uchar) (A)[5])) << 8) +\
+ (((uint32) ((uchar) (A)[6])) << 16) +\
+ (((uint32) ((uchar) (A)[7])) << 24))) <<\
+ 32))
+#define int2store(T,A) do { uint def_temp= (uint) (A) ;\
+ *((uchar*) (T))= (uchar)(def_temp); \
+ *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
+ } while(0)
+#define int3store(T,A) do { /*lint -save -e734 */\
+ *((uchar*)(T))=(uchar) ((A));\
+ *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
+ *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
+ /*lint -restore */} while(0)
+#define int4store(T,A) do { *((char *)(T))=(char) ((A));\
+ *(((char *)(T))+1)=(char) (((A) >> 8));\
+ *(((char *)(T))+2)=(char) (((A) >> 16));\
+ *(((char *)(T))+3)=(char) (((A) >> 24));\
+ } while(0)
+#define int5store(T,A) do { *((char *)(T))= (char)((A)); \
+ *(((char *)(T))+1)= (char)(((A) >> 8)); \
+ *(((char *)(T))+2)= (char)(((A) >> 16)); \
+ *(((char *)(T))+3)= (char)(((A) >> 24)); \
+ *(((char *)(T))+4)= (char)(((A) >> 32)); \
+ } while(0)
+#define int6store(T,A) do { *((char *)(T))= (char)((A)); \
+ *(((char *)(T))+1)= (char)(((A) >> 8)); \
+ *(((char *)(T))+2)= (char)(((A) >> 16)); \
+ *(((char *)(T))+3)= (char)(((A) >> 24)); \
+ *(((char *)(T))+4)= (char)(((A) >> 32)); \
+ *(((char *)(T))+5)= (char)(((A) >> 40)); \
+ } while(0)
+#define int8store(T,A) do { uint def_temp= (uint) (A), \
+ def_temp2= (uint) ((A) >> 32); \
+ int4store((T),def_temp); \
+ int4store((T+4),def_temp2);\
+ } while(0)
diff --git a/include/byte_order_generic_x86.h b/include/byte_order_generic_x86.h
new file mode 100644
index 00000000000..a97dd0f43a3
--- /dev/null
+++ b/include/byte_order_generic_x86.h
@@ -0,0 +1,87 @@
+/* Copyright (c) 2001, 2012, 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 02111-1307 USA */
+
+/*
+ Optimized function-like macros for the x86 architecture (_WIN32 included).
+*/
+#define sint2korr(A) (*((const int16 *) (A)))
+#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
+ (((uint32) 255L << 24) | \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])) : \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])))
+#define sint4korr(A) (*((const long *) (A)))
+#define uint2korr(A) (*((const uint16 *) (A)))
+#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16))
+#define uint4korr(A) (*((const uint32 *) (A)))
+#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) ((uchar) (A)[4])) << 32))
+#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) + \
+ (((uint32) ((uchar) (A)[1])) << 8) + \
+ (((uint32) ((uchar) (A)[2])) << 16) + \
+ (((uint32) ((uchar) (A)[3])) << 24)) + \
+ (((ulonglong) ((uchar) (A)[4])) << 32) + \
+ (((ulonglong) ((uchar) (A)[5])) << 40))
+#define uint8korr(A) (*((const ulonglong *) (A)))
+#define sint8korr(A) (*((const longlong *) (A)))
+
+#define int2store(T,A) *((uint16*) (T))= (uint16) (A)
+#define int3store(T,A) do { *(T)= (uchar) ((A));\
+ *(T+1)=(uchar) (((uint) (A) >> 8));\
+ *(T+2)=(uchar) (((A) >> 16));\
+ } while (0)
+#define int4store(T,A) *((long *) (T))= (long) (A)
+#define int5store(T,A) do { *(T)= (uchar)((A));\
+ *((T)+1)=(uchar) (((A) >> 8));\
+ *((T)+2)=(uchar) (((A) >> 16));\
+ *((T)+3)=(uchar) (((A) >> 24));\
+ *((T)+4)=(uchar) (((A) >> 32));\
+ } while(0)
+#define int6store(T,A) do { *(T)= (uchar)((A)); \
+ *((T)+1)=(uchar) (((A) >> 8)); \
+ *((T)+2)=(uchar) (((A) >> 16)); \
+ *((T)+3)=(uchar) (((A) >> 24)); \
+ *((T)+4)=(uchar) (((A) >> 32)); \
+ *((T)+5)=(uchar) (((A) >> 40)); \
+ } while(0)
+#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
+typedef union {
+ double v;
+ long m[2];
+} doubleget_union;
+#define doubleget(V,M) \
+do { doubleget_union _tmp; \
+ _tmp.m[0] = *((const long*)(M)); \
+ _tmp.m[1] = *(((const long*) (M))+1); \
+ (V) = _tmp.v; } while(0)
+#define doublestore(T,V) \
+do { *((long *) T) = ((const doubleget_union *)&V)->m[0]; \
+ *(((long *) T)+1) = ((const doubleget_union *)&V)->m[1]; \
+ } while (0)
+#define float4get(V,M) \
+do { *((float *) &(V)) = *((const float*) (M)); } while(0)
+#define float8get(V,M) doubleget((V),(M))
+#define float4store(V,M) memcpy((uchar*)(V), (uchar*)(&M), sizeof(float))
+#define floatstore(T,V) memcpy((uchar*)(T), (uchar*)(&V), sizeof(float))
+#define floatget(V,M) memcpy((uchar*)(&V),(uchar*) (M), sizeof(float))
+#define float8store(V,M) doublestore((V),(M))
diff --git a/include/byte_order_generic_x86_64.h b/include/byte_order_generic_x86_64.h
new file mode 100644
index 00000000000..8c7493965a9
--- /dev/null
+++ b/include/byte_order_generic_x86_64.h
@@ -0,0 +1,75 @@
+/* Copyright (c) 2001, 2012, 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 02111-1307 USA */
+
+/*
+ Optimized function-like macros for the x86 architecture (_WIN32 included).
+*/
+#define sint2korr(A) (int16) (*((int16 *) (A)))
+#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
+ (((uint32) 255L << 24) | \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])) : \
+ (((uint32) (uchar) (A)[2]) << 16) |\
+ (((uint32) (uchar) (A)[1]) << 8) | \
+ ((uint32) (uchar) (A)[0])))
+#define sint4korr(A) (int32) (*((int32 *) (A)))
+#define uint2korr(A) (uint16) (*((uint16 *) (A)))
+#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16))
+#define uint4korr(A) (uint32) (*((uint32 *) (A)))
+#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
+ (((uint32) ((uchar) (A)[1])) << 8) +\
+ (((uint32) ((uchar) (A)[2])) << 16) +\
+ (((uint32) ((uchar) (A)[3])) << 24)) +\
+ (((ulonglong) ((uchar) (A)[4])) << 32))
+#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) + \
+ (((uint32) ((uchar) (A)[1])) << 8) + \
+ (((uint32) ((uchar) (A)[2])) << 16) + \
+ (((uint32) ((uchar) (A)[3])) << 24)) + \
+ (((ulonglong) ((uchar) (A)[4])) << 32) + \
+ (((ulonglong) ((uchar) (A)[5])) << 40))
+#define uint8korr(A) (ulonglong) (*((ulonglong *) (A)))
+#define sint8korr(A) (longlong) (*((longlong *) (A)))
+
+#define int2store(T,A) do { uchar *pT= (uchar*)(T);\
+ *((uint16*)(pT))= (uint16) (A);\
+ } while (0)
+
+#define int3store(T,A) do { *(T)= (uchar) ((A));\
+ *(T+1)=(uchar) (((uint) (A) >> 8));\
+ *(T+2)=(uchar) (((A) >> 16));\
+ } while (0)
+#define int4store(T,A) do { uchar *pT= (uchar*)(T);\
+ *((uint32 *) (pT))= (uint32) (A); \
+ } while (0)
+
+#define int5store(T,A) do { *(T)= (uchar)((A));\
+ *((T)+1)=(uchar) (((A) >> 8));\
+ *((T)+2)=(uchar) (((A) >> 16));\
+ *((T)+3)=(uchar) (((A) >> 24));\
+ *((T)+4)=(uchar) (((A) >> 32));\
+ } while(0)
+#define int6store(T,A) do { *(T)= (uchar)((A)); \
+ *((T)+1)=(uchar) (((A) >> 8)); \
+ *((T)+2)=(uchar) (((A) >> 16)); \
+ *((T)+3)=(uchar) (((A) >> 24)); \
+ *((T)+4)=(uchar) (((A) >> 32)); \
+ *((T)+5)=(uchar) (((A) >> 40)); \
+ } while(0)
+#define int8store(T,A) do { uchar *pT= (uchar*)(T);\
+ *((ulonglong *) (pT))= (ulonglong) (A);\
+ } while(0)
diff --git a/include/decimal.h b/include/decimal.h
index 935d341437d..2adeb824318 100644
--- a/include/decimal.h
+++ b/include/decimal.h
@@ -16,6 +16,10 @@
#ifndef _decimal_h
#define _decimal_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef enum
{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
decimal_round_mode;
@@ -112,5 +116,9 @@ void max_decimal(int precision, int frac, decimal_t *to);
#define E_DEC_ERROR 31
#define E_DEC_FATAL_ERROR 30
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/errmsg.h b/include/errmsg.h
index 5655883466c..be4203b7f75 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -16,8 +16,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
-/* Error messages for MySQL clients */
-/* (Error messages for the daemon are in sql/share/errmsg.txt) */
+/*
+ Error messages numbers for MySQL clients.
+ The error messages itself are in libmysql/errmsg.c
+
+ Error messages for the mysqld daemon are in sql/share/errmsg.txt
+*/
#ifdef __cplusplus
extern "C" {
@@ -104,7 +108,9 @@ extern const char *client_errors[]; /* Error messages */
#define CR_NEW_STMT_METADATA 2057
#define CR_ALREADY_CONNECTED 2058
#define CR_AUTH_PLUGIN_CANNOT_LOAD 2059
-#define CR_ERROR_LAST /*Copy last error nr:*/ 2059
+#define CR_DUPLICATE_CONNECTION_ATTR 2060
+#define CR_AUTH_PLUGIN_ERR 2061
+#define CR_ERROR_LAST /*Copy last error nr:*/ 2061
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
#endif /* ERRMSG_INCLUDED */
diff --git a/include/ft_global.h b/include/ft_global.h
index 73726018d0a..aad3b4cb56e 100644
--- a/include/ft_global.h
+++ b/include/ft_global.h
@@ -43,11 +43,32 @@ struct _ft_vft
void (*reinit_search)(FT_INFO *);
};
+typedef struct st_ft_info_ext FT_INFO_EXT;
+struct _ft_vft_ext
+{
+ uint (*get_version)(); // Extended API version
+ ulonglong (*get_flags)();
+ ulonglong (*get_docid)(FT_INFO_EXT *);
+ ulonglong (*count_matches)(FT_INFO_EXT *);
+};
+
+/* Flags for extended FT API */
+#define FTS_ORDERED_RESULT (1LL << 1)
+#define FTS_DOCID_IN_RESULT (1LL << 2)
+
+#define FTS_DOC_ID_COL_NAME "FTS_DOC_ID"
+
#ifndef FT_CORE
struct st_ft_info
{
struct _ft_vft *please; /* INTERCAL style :-) */
};
+
+struct st_ft_info_ext
+{
+ struct _ft_vft *please; /* INTERCAL style :-) */
+ struct _ft_vft_ext *could_you;
+};
#endif
extern const char *ft_stopword_file;
diff --git a/include/hash.h b/include/hash.h
index 98bcf911db2..fde7fc30d38 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -1,4 +1,5 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+ Copyright (c) 2011, 2013, Monty Program Ab.
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
@@ -39,9 +40,12 @@ extern "C" {
/* flags for hash_init */
#define HASH_UNIQUE 1 /* hash_insert fails on duplicate key */
+#define HASH_THREAD_SPECIFIC 2 /* Mark allocated memory THREAD_SPECIFIC */
typedef uint my_hash_value_type;
typedef uchar *(*my_hash_get_key)(const uchar *,size_t*,my_bool);
+typedef my_hash_value_type (*my_hash_function)(CHARSET_INFO *,
+ const uchar *, size_t);
typedef void (*my_hash_free_key)(void *);
typedef my_bool (*my_hash_walk_action)(void *,void *);
@@ -52,6 +56,7 @@ typedef struct st_hash {
uint flags;
DYNAMIC_ARRAY array; /* Place for hash_keys */
my_hash_get_key get_key;
+ my_hash_function hash_function;
void (*free)(void *);
CHARSET_INFO *charset;
} HASH;
@@ -59,13 +64,11 @@ typedef struct st_hash {
/* A search iterator state */
typedef uint HASH_SEARCH_STATE;
-#define my_hash_init(A,B,C,D,E,F,G,H) \
- _my_hash_init(A,0,B,C,D,E,F,G,H)
-#define my_hash_init2(A,B,C,D,E,F,G,H,I) \
- _my_hash_init(A,B,C,D,E,F,G,H,I)
-my_bool _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
+#define my_hash_init(A,B,C,D,E,F,G,H) my_hash_init2(A,0,B,C,D,E,F,0,G,H)
+my_bool my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
ulong default_array_elements, size_t key_offset,
size_t key_length, my_hash_get_key get_key,
+ my_hash_function hash_function,
void (*free_element)(void*),
uint flags);
void my_hash_free(HASH *tree);
@@ -75,8 +78,9 @@ uchar *my_hash_search(const HASH *info, const uchar *key, size_t length);
uchar *my_hash_search_using_hash_value(const HASH *info,
my_hash_value_type hash_value,
const uchar *key, size_t length);
-my_hash_value_type my_calc_hash(const HASH *info,
+my_hash_value_type my_hash_sort(CHARSET_INFO *cs,
const uchar *key, size_t length);
+#define my_calc_hash(A, B, C) my_hash_sort((A)->charset, B, C)
uchar *my_hash_first(const HASH *info, const uchar *key, size_t length,
HASH_SEARCH_STATE *state);
uchar *my_hash_first_from_hash_value(const HASH *info,
@@ -97,7 +101,7 @@ my_bool my_hash_iterate(HASH *hash, my_hash_walk_action action, void *argument);
#define my_hash_clear(H) bzero((char*) (H), sizeof(*(H)))
#define my_hash_inited(H) ((H)->blength != 0)
#define my_hash_init_opt(A,B,C,D,E,F,G,H) \
- (!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G,H))
+ (!my_hash_inited(A) && my_hash_init(A,B,C,D,E,F,G,H))
#ifdef __cplusplus
}
diff --git a/include/heap.h b/include/heap.h
index eecb7084e66..e92f649b87b 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -155,6 +155,7 @@ typedef struct st_heap_share
THR_LOCK lock;
mysql_mutex_t intern_lock; /* Locking for use with _locking */
my_bool delete_on_close;
+ my_bool internal; /* Internal temporary table */
LIST open_list;
uint auto_key;
uint auto_key_type; /* real type of the auto key segment */
diff --git a/include/keycache.h b/include/keycache.h
index 8fa9bf1cd18..85937ebefb9 100644
--- a/include/keycache.h
+++ b/include/keycache.h
@@ -67,11 +67,13 @@ typedef enum key_cache_type
typedef
int (*INIT_KEY_CACHE)
(void *, uint key_cache_block_size,
- size_t use_mem, uint division_limit, uint age_threshold);
+ size_t use_mem, uint division_limit, uint age_threshold,
+ uint changed_blocks_hash_size);
typedef
int (*RESIZE_KEY_CACHE)
(void *, uint key_cache_block_size,
- size_t use_mem, uint division_limit, uint age_threshold);
+ size_t use_mem, uint division_limit, uint age_threshold,
+ uint changed_blocks_hash_size);
typedef
void (*CHANGE_KEY_CACHE_PARAM)
(void *keycache_cb,
@@ -146,6 +148,7 @@ typedef struct st_key_cache
ulonglong param_division_limit;/* min. percentage of warm blocks */
ulonglong param_age_threshold; /* determines when hot block is downgraded */
ulonglong param_partitions; /* number of the key cache partitions */
+ ulonglong changed_blocks_hash_size; /* number of hash buckets for changed files */
my_bool key_cache_inited; /* <=> key cache has been created */
my_bool can_be_used; /* usage of cache for read/write is allowed */
my_bool in_init; /* set to 1 in MySQL during init/resize */
@@ -160,10 +163,11 @@ extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
size_t use_mem, uint division_limit,
- uint age_threshold, uint partitions);
+ uint age_threshold, uint changed_blocks_hash_size,
+ uint partitions);
extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
size_t use_mem, uint division_limit,
- uint age_threshold);
+ uint age_threshold, uint changed_blocks_hash_size);
extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit,
uint age_threshold);
extern uchar *key_cache_read(KEY_CACHE *keycache,
@@ -202,6 +206,7 @@ extern int repartition_key_cache(KEY_CACHE *keycache,
size_t use_mem,
uint division_limit,
uint age_threshold,
+ uint changed_blocks_hash_size,
uint partitions);
C_MODE_END
#endif /* _keycache_h */
diff --git a/include/lf.h b/include/lf.h
index 07769d10943..21cf65941ff 100644
--- a/include/lf.h
+++ b/include/lf.h
@@ -131,25 +131,12 @@ typedef struct {
#define lf_rwunlock_by_pins(PINS) \
my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinarray.lock)
-/*
- compile-time assert, to require "no less than N" pins
- it's enough if it'll fail on at least one compiler, so
- we'll enable it on GCC only, which supports zero-length arrays.
-*/
-#if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG)
-#define LF_REQUIRE_PINS(N) \
- static const char require_pins[LF_PINBOX_PINS-N] \
- __attribute__ ((unused)); \
- static const int LF_NUM_PINS_IN_THIS_FILE= N;
+/* compile-time assert to make sure we have enough pins. */
#define _lf_pin(PINS, PIN, ADDR) \
- ( \
- assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \
- my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) \
- )
-#else
-#define LF_REQUIRE_PINS(N)
-#define _lf_pin(PINS, PIN, ADDR) my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR))
-#endif
+ do { \
+ compile_time_assert(PIN < LF_PINBOX_PINS); \
+ my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)); \
+ } while(0)
#define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL)
#define lf_pin(PINS, PIN, ADDR) \
diff --git a/include/little_endian.h b/include/little_endian.h
new file mode 100644
index 00000000000..7223fea648f
--- /dev/null
+++ b/include/little_endian.h
@@ -0,0 +1,75 @@
+/* Copyright (c) 2012, 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 02111-1307 USA */
+
+/*
+ Data in little-endian format.
+*/
+
+#ifndef MY_BYTE_ORDER_ARCH_OPTIMIZED
+#define float4get(V,M) memcpy(&V, (M), sizeof(float))
+#define float4store(V,M) memcpy(V, (&M), sizeof(float))
+#define float8get(V,M) doubleget((V),(M))
+#define float8store(V,M) doublestore((V),(M))
+
+/* Bi-endian hardware.... */
+#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
+#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
+ *(((char*)T)+1)=(char) ((uchar *) &V)[5];\
+ *(((char*)T)+2)=(char) ((uchar *) &V)[6];\
+ *(((char*)T)+3)=(char) ((uchar *) &V)[7];\
+ *(((char*)T)+4)=(char) ((uchar *) &V)[0];\
+ *(((char*)T)+5)=(char) ((uchar *) &V)[1];\
+ *(((char*)T)+6)=(char) ((uchar *) &V)[2];\
+ *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
+ while(0)
+#define doubleget(V,M) do { double def_temp;\
+ ((uchar*) &def_temp)[0]=(M)[4];\
+ ((uchar*) &def_temp)[1]=(M)[5];\
+ ((uchar*) &def_temp)[2]=(M)[6];\
+ ((uchar*) &def_temp)[3]=(M)[7];\
+ ((uchar*) &def_temp)[4]=(M)[0];\
+ ((uchar*) &def_temp)[5]=(M)[1];\
+ ((uchar*) &def_temp)[6]=(M)[2];\
+ ((uchar*) &def_temp)[7]=(M)[3];\
+ (V) = def_temp; } while(0)
+#else /* Bi-endian hardware.... */
+
+/* Cast away type qualifiers (necessary as macro takes argument by value). */
+#define doublestore(T,V) memcpy((T), (void*) &V, sizeof(double))
+#define doubleget(V,M) memcpy(&V, (M), sizeof(double))
+
+#endif /* Bi-endian hardware.... */
+
+#endif /* !MY_BYTE_ORDER_ARCH_OPTIMIZED */
+
+#define ushortget(V,M) do { uchar *pM= (uchar*)(M);V = uint2korr(pM);} while(0)
+#define shortget(V,M) do { uchar *pM= (uchar*)(M);V = sint2korr(pM);} while(0)
+#define longget(V,M) do { uchar *pM= (uchar*)(M);V = sint4korr(pM);} while(0)
+#define ulongget(V,M) do { uchar *pM= (uchar*)(M);V = uint4korr(pM);} while(0)
+#define shortstore(T,V) int2store(T,V)
+#define longstore(T,V) int4store(T,V)
+
+#ifndef floatstore
+/* Cast away type qualifiers (necessary as macro takes argument by value). */
+#define floatstore(T,V) memcpy((T), (void*) (&V), sizeof(float))
+#define floatget(V,M) memcpy(&V, (M), sizeof(float))
+#endif
+#ifndef doubleget
+#define doubleget(V,M) memcpy(&V, (M), sizeof(double))
+#define doublestore(T,V) memcpy((T), (void *) &V, sizeof(double))
+#endif /* doubleget */
+
+#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong))
+#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong))
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 001884afe81..8d9838fdde2 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -23,6 +23,12 @@
#include <my_attribute.h>
#include "my_global.h" /* uint16, uchar */
+enum loglevel {
+ ERROR_LEVEL= 0,
+ WARNING_LEVEL= 1,
+ INFORMATION_LEVEL= 2
+};
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -61,24 +67,47 @@ typedef const struct unicase_info_st MY_UNICASE_INFO;
typedef const struct uni_ctype_st MY_UNI_CTYPE;
typedef const struct my_uni_idx_st MY_UNI_IDX;
-struct unicase_info_st
+typedef struct unicase_info_char_st
{
uint32 toupper;
uint32 tolower;
uint32 sort;
+} MY_UNICASE_CHARACTER;
+
+
+struct unicase_info_st
+{
+ my_wc_t maxchar;
+ MY_UNICASE_CHARACTER **page;
};
-extern MY_UNICASE_INFO *const my_unicase_default[256];
-extern MY_UNICASE_INFO *const my_unicase_turkish[256];
-extern MY_UNICASE_INFO *const my_unicase_mysql500[256];
-#define MY_UCA_MAX_CONTRACTION 4
-#define MY_UCA_MAX_WEIGHT_SIZE 8
+extern MY_UNICASE_INFO my_unicase_default;
+extern MY_UNICASE_INFO my_unicase_turkish;
+extern MY_UNICASE_INFO my_unicase_mysql500;
+extern MY_UNICASE_INFO my_unicase_unicode520;
+
+#define MY_UCA_MAX_CONTRACTION 6
+/*
+ The DUCET tables in ctype-uca.c are dumped with a limit of 8 weights
+ per character. cs->strxfrm_multiply is set to 8 for all UCA based collations.
+
+ In language-specific UCA collations (with tailorings) we also do not allow
+ a single character to have more than 8 weights to stay with the same
+ strxfrm_multiply limit. Note, contractions are allowed to have twice longer
+ weight strings (up to 16 weights). As a contraction consists of at
+ least 2 characters, this makes sure that strxfrm_multiply ratio of 8
+ is respected.
+*/
+#define MY_UCA_MAX_WEIGHT_SIZE (8+1) /* Including 0 terminator */
+#define MY_UCA_CONTRACTION_MAX_WEIGHT_SIZE (2*8+1) /* Including 0 terminator */
+#define MY_UCA_WEIGHT_LEVELS 1
typedef struct my_contraction_t
{
my_wc_t ch[MY_UCA_MAX_CONTRACTION]; /* Character sequence */
- uint16 weight[MY_UCA_MAX_WEIGHT_SIZE];/* Its weight string, 0-terminated */
+ uint16 weight[MY_UCA_CONTRACTION_MAX_WEIGHT_SIZE];/* Its weight string, 0-terminated */
+ my_bool with_context;
} MY_CONTRACTION;
@@ -89,6 +118,46 @@ typedef struct my_contraction_list_t
char *flags; /* Character flags, e.g. "is contraction head") */
} MY_CONTRACTIONS;
+my_bool my_uca_can_be_contraction_head(const MY_CONTRACTIONS *c, my_wc_t wc);
+my_bool my_uca_can_be_contraction_tail(const MY_CONTRACTIONS *c, my_wc_t wc);
+uint16 *my_uca_contraction2_weight(const MY_CONTRACTIONS *c,
+ my_wc_t wc1, my_wc_t wc2);
+
+
+/* Collation weights on a single level (e.g. primary, secondary, tertiarty) */
+typedef struct my_uca_level_info_st
+{
+ my_wc_t maxchar;
+ uchar *lengths;
+ uint16 **weights;
+ MY_CONTRACTIONS contractions;
+} MY_UCA_WEIGHT_LEVEL;
+
+
+typedef struct uca_info_st
+{
+ MY_UCA_WEIGHT_LEVEL level[MY_UCA_WEIGHT_LEVELS];
+
+ /* Logical positions */
+ my_wc_t first_non_ignorable;
+ my_wc_t last_non_ignorable;
+ my_wc_t first_primary_ignorable;
+ my_wc_t last_primary_ignorable;
+ my_wc_t first_secondary_ignorable;
+ my_wc_t last_secondary_ignorable;
+ my_wc_t first_tertiary_ignorable;
+ my_wc_t last_tertiary_ignorable;
+ my_wc_t first_trailing;
+ my_wc_t last_trailing;
+ my_wc_t first_variable;
+ my_wc_t last_variable;
+
+} MY_UCA_INFO;
+
+
+
+extern MY_UCA_INFO my_uca_v400;
+
struct uni_ctype_st
{
@@ -111,6 +180,9 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
/* A helper macros for "need at least n bytes" */
#define MY_CS_TOOSMALLN(n) (-100-(n))
+#define MY_CS_IS_TOOSMALL(rc) ((rc) >= MY_CS_TOOSMALL6 && (rc) <= MY_CS_TOOSMALL)
+
+
#define MY_SEQ_INTTAIL 1
#define MY_SEQ_SPACES 2
@@ -122,7 +194,7 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
#define MY_CS_BINSORT 16 /* if binary sort order */
#define MY_CS_PRIMARY 32 /* if primary collation */
#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */
-#define MY_CS_UNICODE 128 /* is a charset is full unicode */
+#define MY_CS_UNICODE 128 /* is a charset is BMP Unicode */
#define MY_CS_READY 256 /* if a charset is initialized */
#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
@@ -130,6 +202,8 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
#define MY_CS_PUREASCII 4096 /* if a charset is pure ascii */
#define MY_CS_NONASCII 8192 /* if not ASCII-compatible */
#define MY_CS_UNICODE_SUPPLEMENT 16384 /* Non-BMP Unicode characters */
+#define MY_CS_LOWER_SORT 32768 /* If use lower case as weight */
+#define MY_CS_STRNXFRM_BAD_NWEIGHTS 0x10000 /* strnxfrm ignores "nweights" */
#define MY_CHARSET_UNDEFINED 0
/* Character repertoire flags */
@@ -137,6 +211,64 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
#define MY_REPERTOIRE_EXTENDED 2 /* Extended characters: U+0080..U+FFFF */
#define MY_REPERTOIRE_UNICODE30 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
+/* Flags for strxfrm */
+#define MY_STRXFRM_LEVEL1 0x00000001 /* for primary weights */
+#define MY_STRXFRM_LEVEL2 0x00000002 /* for secondary weights */
+#define MY_STRXFRM_LEVEL3 0x00000004 /* for tertiary weights */
+#define MY_STRXFRM_LEVEL4 0x00000008 /* fourth level weights */
+#define MY_STRXFRM_LEVEL5 0x00000010 /* fifth level weights */
+#define MY_STRXFRM_LEVEL6 0x00000020 /* sixth level weights */
+#define MY_STRXFRM_LEVEL_ALL 0x0000003F /* Bit OR for the above six */
+#define MY_STRXFRM_NLEVELS 6 /* Number of possible levels*/
+
+#define MY_STRXFRM_PAD_WITH_SPACE 0x00000040 /* if pad result with spaces */
+#define MY_STRXFRM_PAD_TO_MAXLEN 0x00000080 /* if pad tail(for filesort) */
+
+#define MY_STRXFRM_DESC_LEVEL1 0x00000100 /* if desc order for level1 */
+#define MY_STRXFRM_DESC_LEVEL2 0x00000200 /* if desc order for level2 */
+#define MY_STRXFRM_DESC_LEVEL3 0x00000300 /* if desc order for level3 */
+#define MY_STRXFRM_DESC_LEVEL4 0x00000800 /* if desc order for level4 */
+#define MY_STRXFRM_DESC_LEVEL5 0x00001000 /* if desc order for level5 */
+#define MY_STRXFRM_DESC_LEVEL6 0x00002000 /* if desc order for level6 */
+#define MY_STRXFRM_DESC_SHIFT 8
+
+#define MY_STRXFRM_UNUSED_00004000 0x00004000 /* for future extensions */
+#define MY_STRXFRM_UNUSED_00008000 0x00008000 /* for future extensions */
+
+#define MY_STRXFRM_REVERSE_LEVEL1 0x00010000 /* if reverse order for level1 */
+#define MY_STRXFRM_REVERSE_LEVEL2 0x00020000 /* if reverse order for level2 */
+#define MY_STRXFRM_REVERSE_LEVEL3 0x00040000 /* if reverse order for level3 */
+#define MY_STRXFRM_REVERSE_LEVEL4 0x00080000 /* if reverse order for level4 */
+#define MY_STRXFRM_REVERSE_LEVEL5 0x00100000 /* if reverse order for level5 */
+#define MY_STRXFRM_REVERSE_LEVEL6 0x00200000 /* if reverse order for level6 */
+#define MY_STRXFRM_REVERSE_SHIFT 16
+
+/*
+ Collation IDs for MariaDB that should not conflict with MySQL.
+ We reserve 256..511, because MySQL will most likely use this range
+ when the range 0..255 is full.
+
+ We use the next 256 IDs starting from 512 and divide
+ them into 8 chunks, 32 collations each, as follows:
+
+ 512 + (0..31) for single byte collations (e.g. latin9)
+ 512 + (32..63) reserved (e.g. for utf32le, or more single byte collations)
+ 512 + (64..95) for utf8
+ 512 + (96..127) for utf8mb4
+ 512 + (128..159) for ucs2
+ 512 + (160..192) for utf16
+ 512 + (192..223) for utf16le
+ 512 + (224..255) for utf32
+*/
+#define MY_PAGE2_COLLATION_ID_8BIT 0x200
+#define MY_PAGE2_COLLATION_ID_RESERVED 0x220
+#define MY_PAGE2_COLLATION_ID_UTF8 0x240
+#define MY_PAGE2_COLLATION_ID_UTF8MB4 0x260
+#define MY_PAGE2_COLLATION_ID_UCS2 0x280
+#define MY_PAGE2_COLLATION_ID_UTF16 0x2A0
+#define MY_PAGE2_COLLATION_ID_UTF16LE 0x2C0
+#define MY_PAGE2_COLLATION_ID_UTF32 0x2E0
+
struct my_uni_idx_st
{
uint16 from;
@@ -170,13 +302,24 @@ enum my_lex_states
struct charset_info_st;
+typedef struct my_charset_loader_st
+{
+ char error[128];
+ void *(*once_alloc)(size_t);
+ void *(*malloc)(size_t);
+ void *(*realloc)(void *, size_t);
+ void (*free)(void *);
+ void (*reporter)(enum loglevel, const char *format, ...);
+ int (*add_collation)(struct charset_info_st *cs);
+} MY_CHARSET_LOADER;
+
extern int (*my_string_stack_guard)(int);
/* See strings/CHARSET_INFO.txt for information about this structure */
struct my_collation_handler_st
{
- my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t));
+ my_bool (*init)(struct charset_info_st *, MY_CHARSET_LOADER *);
/* Collation routines */
int (*strnncoll)(CHARSET_INFO *,
const uchar *, size_t, const uchar *, size_t, my_bool);
@@ -184,7 +327,8 @@ struct my_collation_handler_st
const uchar *, size_t, const uchar *, size_t,
my_bool diff_if_only_endspace_difference);
size_t (*strnxfrm)(CHARSET_INFO *,
- uchar *, size_t, const uchar *, size_t);
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags);
size_t (*strnxfrmlen)(CHARSET_INFO *, size_t);
my_bool (*like_range)(CHARSET_INFO *,
const char *s, size_t s_length,
@@ -227,7 +371,7 @@ typedef size_t (*my_charset_conv_case)(CHARSET_INFO *,
/* See strings/CHARSET_INFO.txt about information on this structure */
struct my_charset_handler_st
{
- my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t));
+ my_bool (*init)(struct charset_info_st *, MY_CHARSET_LOADER *loader);
/* Multibyte routines */
uint (*ismbchar)(CHARSET_INFO *, const char *, const char *);
uint (*mbcharlen)(CHARSET_INFO *, uint c);
@@ -290,6 +434,13 @@ struct my_charset_handler_st
extern MY_CHARSET_HANDLER my_charset_8bit_handler;
extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
+
+/*
+ We define this CHARSET_INFO_DEFINED here to prevent a repeat of the
+ typedef in hash.c, which will cause a compiler error.
+*/
+#define CHARSET_INFO_DEFINED
+
/* See strings/CHARSET_INFO.txt about information on this structure */
struct charset_info_st
{
@@ -305,11 +456,10 @@ struct charset_info_st
const uchar *to_lower;
const uchar *to_upper;
const uchar *sort_order;
- const MY_CONTRACTIONS *contractions;
- const uint16 *const *sort_order_big;
+ MY_UCA_INFO *uca;
const uint16 *tab_to_uni;
- MY_UNI_IDX *tab_from_uni;
- MY_UNICASE_INFO *const *caseinfo;
+ MY_UNI_IDX *tab_from_uni;
+ MY_UNICASE_INFO *caseinfo;
const uchar *state_map;
const uchar *ident_map;
uint strxfrm_multiply;
@@ -317,10 +467,11 @@ struct charset_info_st
uchar casedn_multiply;
uint mbminlen;
uint mbmaxlen;
- uint16 min_sort_char;
- uint16 max_sort_char; /* For LIKE optimization */
+ my_wc_t min_sort_char;
+ my_wc_t max_sort_char; /* For LIKE optimization */
uchar pad_char;
my_bool escape_with_backslash_is_dangerous;
+ uchar levels_for_order;
MY_CHARSET_HANDLER *cset;
MY_COLLATION_HANDLER *coll;
@@ -363,6 +514,8 @@ extern struct charset_info_st my_charset_ujis_japanese_ci;
extern struct charset_info_st my_charset_utf16_bin;
extern struct charset_info_st my_charset_utf16_general_ci;
extern struct charset_info_st my_charset_utf16_unicode_ci;
+extern struct charset_info_st my_charset_utf16le_bin;
+extern struct charset_info_st my_charset_utf16le_general_ci;
extern struct charset_info_st my_charset_utf32_bin;
extern struct charset_info_st my_charset_utf32_general_ci;
extern struct charset_info_st my_charset_utf32_unicode_ci;
@@ -383,8 +536,9 @@ const uint16 *my_cs_contraction2_weight(CHARSET_INFO *cs, my_wc_t wc1,
my_wc_t wc2);
/* declarations for simple charsets */
-extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t,
- const uchar *, size_t);
+extern size_t my_strnxfrm_simple(CHARSET_INFO *,
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags);
size_t my_strnxfrmlen_simple(CHARSET_INFO *, size_t);
extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, size_t,
const uchar *, size_t, my_bool);
@@ -553,23 +707,28 @@ int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
const uchar *key, size_t len,ulong *nr1, ulong *nr2);
+size_t my_strnxfrm_mb(CHARSET_INFO *,
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags);
+
size_t my_strnxfrm_unicode(CHARSET_INFO *,
- uchar *dst, size_t dstlen,
- const uchar *src, size_t srclen);
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags);
+size_t my_strnxfrmlen_unicode(CHARSET_INFO *, size_t);
size_t my_strnxfrm_unicode_full_bin(CHARSET_INFO *,
- uchar *dst, size_t dstlen,
- const uchar *src, size_t srclen);
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags);
size_t my_strnxfrmlen_unicode_full_bin(CHARSET_INFO *, size_t);
int my_wildcmp_unicode(CHARSET_INFO *cs,
const char *str, const char *str_end,
const char *wildstr, const char *wildend,
int escape, int w_one, int w_many,
- MY_UNICASE_INFO *const *weights);
+ MY_UNICASE_INFO *weights);
-extern my_bool my_parse_charset_xml(const char *bug, size_t len,
- int (*add)(struct charset_info_st *cs));
+extern my_bool my_parse_charset_xml(MY_CHARSET_LOADER *loader,
+ const char *buf, size_t buflen);
extern char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
pchar c);
extern size_t my_strcspn(CHARSET_INFO *cs, const char *str, const char *end,
@@ -579,16 +738,38 @@ my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, size_t len);
my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len);
+typedef struct
+{
+ size_t char_length;
+ uint repertoire;
+} MY_STRING_METADATA;
+
+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);
my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
uint my_charset_repertoire(CHARSET_INFO *cs);
+uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
+void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
+ uint flags, uint level);
+size_t my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs,
+ uchar *str, uchar *frmend, uchar *strend,
+ uint nweights, uint flags, uint level);
+
my_bool my_charset_is_ascii_compatible(CHARSET_INFO *cs);
+const MY_CONTRACTIONS *my_charset_get_contractions(CHARSET_INFO *cs,
+ int level);
+
extern size_t my_vsnprintf_ex(CHARSET_INFO *cs, char *to, size_t n,
const char* fmt, va_list ap);
+uint32 my_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
+ const char *from, uint32 from_length,
+ CHARSET_INFO *from_cs, uint *errors);
+
#define _MY_U 01 /* Upper case */
#define _MY_L 02 /* Lower case */
#define _MY_NMR 04 /* Numeral (digit) */
@@ -623,7 +804,8 @@ extern size_t my_vsnprintf_ex(CHARSET_INFO *cs, char *to, size_t n,
#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT)
#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM)
-#define my_strnxfrm(s, a, b, c, d) ((s)->coll->strnxfrm((s), (a), (b), (c), (d)))
+#define my_strnxfrm(cs, d, dl, s, sl) \
+ ((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
diff --git a/include/m_string.h b/include/m_string.h
index 1f59fd06084..188802bc08b 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -34,14 +34,6 @@
#include <string.h>
#endif
-/* need by my_vsnprintf */
-#include <stdarg.h>
-
-/* This is needed for the definitions of bzero... on solaris */
-#if defined(HAVE_STRINGS_H)
-#include <strings.h>
-#endif
-
/* This is needed for the definitions of memcpy... on solaris */
#if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
#include <memory.h>
@@ -73,10 +65,12 @@ extern "C" {
#endif
/*
- my_str_malloc() and my_str_free() are assigned to implementations in
- strings/alloc.c, but can be overridden in the calling program.
+ my_str_malloc(), my_str_realloc() and my_str_free() are assigned to
+ implementations in strings/alloc.c, but can be overridden in
+ the calling program.
*/
extern void *(*my_str_malloc)(size_t);
+extern void *(*my_str_realloc)(void *, size_t);
extern void (*my_str_free)(void *);
#if defined(HAVE_STPCPY) && MY_GNUC_PREREQ(3, 4) && !defined(__INTEL_COMPILER)
@@ -168,7 +162,7 @@ size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
(DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or
MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
*/
-#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + max(5, MAX_DECPT_FOR_F_FORMAT)) \
+#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + MY_MAX(5, MAX_DECPT_FOR_F_FORMAT)) \
extern char *llstr(longlong value,char *buff);
extern char *ullstr(longlong value,char *buff);
diff --git a/include/ma_dyncol.h b/include/ma_dyncol.h
index 6174328d62a..4f05b425afd 100644
--- a/include/ma_dyncol.h
+++ b/include/ma_dyncol.h
@@ -28,20 +28,50 @@
#ifndef ma_dyncol_h
#define ma_dyncol_h
+#ifdef __cplusplus
+extern "C" {
+#endif
#include <decimal.h>
#include <my_decimal_limits.h>
#include <mysql_time.h>
+#ifndef _my_sys_h
+typedef struct st_dynamic_string
+{
+ char *str;
+ size_t length,max_length,alloc_increment;
+} DYNAMIC_STRING;
+#endif
+
+#ifndef MY_GLOBAL_INCLUDED
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+typedef struct st_mysql_lex_string LEX_STRING;
+#endif
+
/*
- Max length for data in a dynamic colums. This comes from how the
- how the offset are stored.
+ Limits of implementation
*/
-#define MAX_DYNAMIC_COLUMN_LENGTH 0X1FFFFFFFL
+#define MAX_TOTAL_NAME_LENGTH 65535
+#define MAX_NAME_LENGTH (MAX_TOTAL_NAME_LENGTH/4)
/* NO and OK is the same used just to show semantics */
#define ER_DYNCOL_NO ER_DYNCOL_OK
+#ifdef HAVE_CHARSET_utf8mb4
+#define DYNCOL_UTF (&my_charset_utf8mb4_general_ci)
+#else
+#define DYNCOL_UTF (&my_charset_utf8_general_ci)
+#endif
+
+/* escape json strings */
+#define DYNCOL_JSON_ESC ((char)1)
+
enum enum_dyncol_func_result
{
ER_DYNCOL_OK= 0,
@@ -50,7 +80,8 @@ enum enum_dyncol_func_result
ER_DYNCOL_LIMIT= -2, /* Some limit reached */
ER_DYNCOL_RESOURCE= -3, /* Out of resourses */
ER_DYNCOL_DATA= -4, /* Incorrect input data */
- ER_DYNCOL_UNKNOWN_CHARSET= -5 /* Unknown character set */
+ ER_DYNCOL_UNKNOWN_CHARSET= -5, /* Unknown character set */
+ ER_DYNCOL_TRUNCATED= 2 /* OK, but data was truncated */
};
typedef DYNAMIC_STRING DYNAMIC_COLUMN;
@@ -65,7 +96,8 @@ enum enum_dynamic_column_type
DYN_COL_DECIMAL,
DYN_COL_DATETIME,
DYN_COL_DATE,
- DYN_COL_TIME
+ DYN_COL_TIME,
+ DYN_COL_DYNCOL
};
typedef enum enum_dynamic_column_type DYNAMIC_COLUMN_TYPE;
@@ -79,7 +111,7 @@ struct st_dynamic_column_value
unsigned long long ulong_value;
double double_value;
struct {
- LEX_STRING value;
+ MYSQL_LEX_STRING value;
CHARSET_INFO *charset;
} string;
struct {
@@ -92,6 +124,7 @@ struct st_dynamic_column_value
typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE;
+#ifdef MADYNCOL_DEPRECATED
enum enum_dyncol_func_result
dynamic_column_create(DYNAMIC_COLUMN *str,
uint column_nr, DYNAMIC_COLUMN_VALUE *value);
@@ -101,7 +134,6 @@ dynamic_column_create_many(DYNAMIC_COLUMN *str,
uint column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values);
-
enum enum_dyncol_func_result
dynamic_column_update(DYNAMIC_COLUMN *org, uint column_nr,
DYNAMIC_COLUMN_VALUE *value);
@@ -112,36 +144,108 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str,
DYNAMIC_COLUMN_VALUE *values);
enum enum_dyncol_func_result
-dynamic_column_delete(DYNAMIC_COLUMN *org, uint column_nr);
+dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr);
+
+enum enum_dyncol_func_result
+dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint);
enum enum_dyncol_func_result
-dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr);
+dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr,
+ DYNAMIC_COLUMN_VALUE *store_it_here);
+#endif
+
+/* new functions */
+enum enum_dyncol_func_result
+mariadb_dyncol_create_many_num(DYNAMIC_COLUMN *str,
+ uint column_count,
+ uint *column_numbers,
+ DYNAMIC_COLUMN_VALUE *values,
+ my_bool new_string);
+enum enum_dyncol_func_result
+mariadb_dyncol_create_many_named(DYNAMIC_COLUMN *str,
+ uint column_count,
+ MYSQL_LEX_STRING *column_keys,
+ DYNAMIC_COLUMN_VALUE *values,
+ my_bool new_string);
+
+
+enum enum_dyncol_func_result
+mariadb_dyncol_update_many_num(DYNAMIC_COLUMN *str,
+ uint add_column_count,
+ uint *column_keys,
+ DYNAMIC_COLUMN_VALUE *values);
+enum enum_dyncol_func_result
+mariadb_dyncol_update_many_named(DYNAMIC_COLUMN *str,
+ uint add_column_count,
+ MYSQL_LEX_STRING *column_keys,
+ DYNAMIC_COLUMN_VALUE *values);
+
+
+enum enum_dyncol_func_result
+mariadb_dyncol_exists_num(DYNAMIC_COLUMN *org, uint column_nr);
+enum enum_dyncol_func_result
+mariadb_dyncol_exists_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name);
/* List of not NULL columns */
enum enum_dyncol_func_result
-dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint);
+mariadb_dyncol_list_num(DYNAMIC_COLUMN *str, uint *count, uint **nums);
+enum enum_dyncol_func_result
+mariadb_dyncol_list_named(DYNAMIC_COLUMN *str, uint *count,
+ MYSQL_LEX_STRING **names);
/*
if the column do not exists it is NULL
*/
enum enum_dyncol_func_result
-dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr,
- DYNAMIC_COLUMN_VALUE *store_it_here);
+mariadb_dyncol_get_num(DYNAMIC_COLUMN *org, uint column_nr,
+ DYNAMIC_COLUMN_VALUE *store_it_here);
+enum enum_dyncol_func_result
+mariadb_dyncol_get_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name,
+ DYNAMIC_COLUMN_VALUE *store_it_here);
-#define dynamic_column_initialize(A) memset((A), 0, sizeof(*(A)))
-#define dynamic_column_column_free(V) dynstr_free(V)
+my_bool mariadb_dyncol_has_names(DYNAMIC_COLUMN *str);
-/***************************************************************************
- Internal functions, don't use if you don't know what you are doing...
-***************************************************************************/
+enum enum_dyncol_func_result
+mariadb_dyncol_check(DYNAMIC_COLUMN *str);
-#define dynamic_column_reassociate(V,P,L, A) dynstr_reassociate((V),(P),(L),(A))
+enum enum_dyncol_func_result
+mariadb_dyncol_json(DYNAMIC_COLUMN *str, DYNAMIC_STRING *json);
-#define dynamic_column_value_init(V) (V)->type= DYN_COL_NULL
+#define mariadb_dyncol_init(A) memset((A), 0, sizeof(*(A)))
+void mariadb_dyncol_free(DYNAMIC_COLUMN *str);
+
+/* conversion of values to 3 base types */
+enum enum_dyncol_func_result
+mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val,
+ CHARSET_INFO *cs, my_bool quote);
+enum enum_dyncol_func_result
+mariadb_dyncol_val_long(longlong *ll, DYNAMIC_COLUMN_VALUE *val);
+enum enum_dyncol_func_result
+mariadb_dyncol_val_double(double *dbl, DYNAMIC_COLUMN_VALUE *val);
+
+
+enum enum_dyncol_func_result
+mariadb_dyncol_unpack(DYNAMIC_COLUMN *str,
+ uint *count,
+ MYSQL_LEX_STRING **names, DYNAMIC_COLUMN_VALUE **vals);
+
+void mariadb_dyncol_unpack_free(MYSQL_LEX_STRING *names,
+ DYNAMIC_COLUMN_VALUE *vals);
+
+int mariadb_dyncol_column_cmp_named(const MYSQL_LEX_STRING *s1,
+ const MYSQL_LEX_STRING *s2);
+
+enum enum_dyncol_func_result
+mariadb_dyncol_column_count(DYNAMIC_COLUMN *str, uint *column_count);
+
+#define mariadb_dyncol_value_init(V) (V)->type= DYN_COL_NULL
/*
Prepare value for using as decimal
*/
-void dynamic_column_prepare_decimal(DYNAMIC_COLUMN_VALUE *value);
+void mariadb_dyncol_prepare_decimal(DYNAMIC_COLUMN_VALUE *value);
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/include/maria.h b/include/maria.h
index aba5d508070..cdaeadef4de 100644
--- a/include/maria.h
+++ b/include/maria.h
@@ -1,4 +1,5 @@
/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+ Copyright (c) 2009, 2013, Monty Program Ab.
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
@@ -22,12 +23,10 @@
extern "C" {
#endif
#include <my_base.h>
-#include <my_sys.h>
#include <m_ctype.h>
#include "my_compare.h"
#include "ft_global.h"
#include <myisamchk.h>
-#include <mysql/plugin.h>
#define MARIA_CANNOT_ROLLBACK
@@ -44,7 +43,7 @@ extern "C" {
#define MARIA_NAME_IEXT ".MAI"
#define MARIA_NAME_DEXT ".MAD"
/* Max extra space to use when sorting keys */
-#define MARIA_MAX_TEMP_LENGTH 2*1024L*1024L*1024L
+#define MARIA_MAX_TEMP_LENGTH (2*1024L*1024L*1024L)
/* Possible values for maria_block_size (must be power of 2) */
#define MARIA_KEY_BLOCK_LENGTH 8192 /* default key block length */
#define MARIA_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */
@@ -60,34 +59,34 @@ extern "C" {
sets all high keys.
*/
#define MARIA_KEYMAP_BITS (8 * SIZEOF_LONG_LONG)
-#define MARIA_KEYMAP_HIGH_MASK (ULL(1) << (MARIA_KEYMAP_BITS - 1))
+#define MARIA_KEYMAP_HIGH_MASK (1ULL << (MARIA_KEYMAP_BITS - 1))
#define maria_get_mask_all_keys_active(_keys_) \
(((_keys_) < MARIA_KEYMAP_BITS) ? \
- ((ULL(1) << (_keys_)) - ULL(1)) : \
- (~ ULL(0)))
+ ((1ULL << (_keys_)) - 1ULL) : \
+ (~ 0ULL))
#if MARIA_MAX_KEY > MARIA_KEYMAP_BITS
#define maria_is_key_active(_keymap_,_keyno_) \
(((_keyno_) < MARIA_KEYMAP_BITS) ? \
- test((_keymap_) & (ULL(1) << (_keyno_))) : \
- test((_keymap_) & MARIA_KEYMAP_HIGH_MASK))
+ MY_TEST((_keymap_) & (1ULL << (_keyno_))) : \
+ MY_TEST((_keymap_) & MARIA_KEYMAP_HIGH_MASK))
#define maria_set_key_active(_keymap_,_keyno_) \
(_keymap_)|= (((_keyno_) < MARIA_KEYMAP_BITS) ? \
- (ULL(1) << (_keyno_)) : \
+ (1ULL << (_keyno_)) : \
MARIA_KEYMAP_HIGH_MASK)
#define maria_clear_key_active(_keymap_,_keyno_) \
(_keymap_)&= (((_keyno_) < MARIA_KEYMAP_BITS) ? \
- (~ (ULL(1) << (_keyno_))) : \
- (~ (ULL(0))) /*ignore*/ )
+ (~ (1ULL << (_keyno_))) : \
+ (~ (0ULL)) /*ignore*/ )
#else
#define maria_is_key_active(_keymap_,_keyno_) \
- test((_keymap_) & (ULL(1) << (_keyno_)))
+ MY_TEST((_keymap_) & (1ULL << (_keyno_)))
#define maria_set_key_active(_keymap_,_keyno_) \
- (_keymap_)|= (ULL(1) << (_keyno_))
+ (_keymap_)|= (1ULL << (_keyno_))
#define maria_clear_key_active(_keymap_,_keyno_) \
- (_keymap_)&= (~ (ULL(1) << (_keyno_)))
+ (_keymap_)&= (~ (1ULL << (_keyno_)))
#endif
#define maria_is_any_key_active(_keymap_) \
- test((_keymap_))
+ MY_TEST((_keymap_))
#define maria_is_all_keys_active(_keymap_,_keys_) \
((_keymap_) == maria_get_mask_all_keys_active(_keys_))
#define maria_set_all_keys_active(_keymap_,_keys_) \
@@ -383,7 +382,8 @@ int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename);
int maria_disable_indexes(MARIA_HA *info);
int maria_enable_indexes(MARIA_HA *info);
int maria_indexes_are_disabled(MARIA_HA *info);
-void maria_disable_non_unique_index(MARIA_HA *info, ha_rows rows);
+void maria_disable_indexes_for_rebuild(MARIA_HA *info, ha_rows rows,
+ my_bool all_keys);
my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows, ulonglong key_map,
my_bool force);
diff --git a/include/my_alarm.h b/include/my_alarm.h
index c3707cba395..73bb6ab76cc 100644
--- a/include/my_alarm.h
+++ b/include/my_alarm.h
@@ -50,7 +50,7 @@ extern ulong my_time_to_wait_for_lock;
#define ALARM_INIT
#define ALARM_END
#define ALARM_TEST (alarm_pos++ >= alarm_end_pos)
-#define ALARM_REINIT alarm_end_pos+=MY_HOW_OFTEN_TO_WRITE
+#define ALARM_REINIT (alarm_end_pos+=MY_HOW_OFTEN_TO_WRITE)
#endif /* HAVE_ALARM */
#ifdef __cplusplus
diff --git a/include/my_base.h b/include/my_base.h
index 36c97d61cb9..5c3dd8db9d9 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -1,4 +1,5 @@
-/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+ Copyright (c) 1995, 2012 Monty Program Ab
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
@@ -45,7 +46,13 @@
#define HA_OPEN_COPY 256 /* Open copy (for repair) */
/* Internal temp table, used for temporary results */
#define HA_OPEN_INTERNAL_TABLE 512
-#define HA_OPEN_MERGE_TABLE 1024
+#define HA_OPEN_NO_PSI_CALL 1024 /* Don't call/connect PSI */
+#define HA_OPEN_MERGE_TABLE 2048
+/*
+ Allow opening even if table is incompatible as this is for ALTER TABLE which
+ will fix the table structure.
+*/
+#define HA_OPEN_FOR_ALTER 4096
/* The following is parameter to ha_rkey() how to use key */
@@ -252,13 +259,11 @@ enum ha_base_keytype {
#define HA_SPATIAL 1024 /* For spatial search */
#define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */
#define HA_GENERATED_KEY 8192 /* Automaticly generated key */
-#define HA_RTREE_INDEX 16384 /* For RTREE search */
/* The combination of the above can be used for key type comparison. */
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \
- HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY | \
- HA_RTREE_INDEX)
+ HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
/*
Key contains partial segments.
@@ -312,12 +317,29 @@ enum ha_base_keytype {
#define HA_OPTION_CHECKSUM 32
#define HA_OPTION_DELAY_KEY_WRITE 64
#define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */
-#define HA_OPTION_CREATE_FROM_ENGINE 256
+/* unused 256 */
#define HA_OPTION_RELIES_ON_SQL_LAYER 512
#define HA_OPTION_NULL_FIELDS 1024
#define HA_OPTION_PAGE_CHECKSUM 2048
+/*
+ STATS_PERSISTENT=1 has been specified in the SQL command (either CREATE
+ or ALTER TABLE). Table and index statistics that are collected by the
+ storage engine and used by the optimizer for query optimization will be
+ stored on disk and will not change after a server restart.
+*/
+#define HA_OPTION_STATS_PERSISTENT 4096
+/*
+ STATS_PERSISTENT=0 has been specified in CREATE/ALTER TABLE. Statistics
+ for the table will be wiped away on server shutdown and new ones recalculated
+ after the server is started again. If none of HA_OPTION_STATS_PERSISTENT or
+ HA_OPTION_NO_STATS_PERSISTENT is set, this means that the setting is not
+ explicitly set at table level and the corresponding table will use whatever
+ is the global server default.
+*/
+#define HA_OPTION_NO_STATS_PERSISTENT 8192
+
/* .frm has extra create options in linked-list format */
-#define HA_OPTION_TEXT_CREATE_OPTIONS (1L << 14)
+#define HA_OPTION_TEXT_CREATE_OPTIONS_legacy (1L << 14) /* 5.2 to 5.5, unused since 10.0 */
#define HA_OPTION_TEMP_COMPRESS_RECORD (1L << 15) /* set by isamchk */
#define HA_OPTION_READ_ONLY_DATA (1L << 16) /* Set by isamchk */
#define HA_OPTION_NO_CHECKSUM (1L << 17)
@@ -333,6 +355,12 @@ enum ha_base_keytype {
#define HA_CREATE_PAGE_CHECKSUM 32
#define HA_CREATE_DELAY_KEY_WRITE 64
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
+#define HA_CREATE_INTERNAL_TABLE 256
+
+/* Flags used by start_bulk_insert */
+
+#define HA_CREATE_UNIQUE_INDEX_BY_SORT 1
+
/*
The following flags (OR-ed) are passed to handler::info() method.
@@ -398,7 +426,7 @@ enum ha_base_keytype {
#define HA_ERR_WRONG_INDEX 124 /* Wrong index given to function */
#define HA_ERR_CRASHED 126 /* Indexfile is crashed */
#define HA_ERR_WRONG_IN_RECORD 127 /* Record-file is crashed */
-#define HA_ERR_OUT_OF_MEM 128 /* Record-file is crashed */
+#define HA_ERR_OUT_OF_MEM 128 /* Out of memory */
#define HA_ERR_NOT_A_TABLE 130 /* not a MYI file - no signature */
#define HA_ERR_WRONG_COMMAND 131 /* Command not supported */
#define HA_ERR_OLD_FILE 132 /* old databasfile */
@@ -448,26 +476,33 @@ enum ha_base_keytype {
#define HA_ERR_GENERIC 168 /* Generic error */
/* row not actually updated: new values same as the old values */
#define HA_ERR_RECORD_IS_THE_SAME 169
-/* It is not possible to log this statement */
-#define HA_ERR_LOGGING_IMPOSSIBLE 170
-/* The event was corrupt, leading to illegal data being read */
-#define HA_ERR_CORRUPT_EVENT 171
+#define HA_ERR_LOGGING_IMPOSSIBLE 170 /* It is not possible to log this
+ statement */
+#define HA_ERR_CORRUPT_EVENT 171 /* The event was corrupt, leading to
+ illegal data being read */
#define HA_ERR_NEW_FILE 172 /* New file format */
-/* The event could not be processed no other handler error happened */
-#define HA_ERR_ROWS_EVENT_APPLY 173
+#define HA_ERR_ROWS_EVENT_APPLY 173 /* The event could not be processed
+ no other hanlder error happened */
#define HA_ERR_INITIALIZATION 174 /* Error during initialization */
#define HA_ERR_FILE_TOO_SHORT 175 /* File too short */
#define HA_ERR_WRONG_CRC 176 /* Wrong CRC on page */
#define HA_ERR_TOO_MANY_CONCURRENT_TRXS 177 /*Too many active concurrent transactions */
-#define HA_ERR_INDEX_COL_TOO_LONG 178 /* Index column length exceeds limit */
-#define HA_ERR_INDEX_CORRUPT 179 /* Index corrupted */
-#define HA_ERR_UNDO_REC_TOO_BIG 180 /* Undo log record too big */
-#define HA_ERR_TABLE_IN_FK_CHECK 181 /* Table being used in foreign key check */
-#define HA_ERR_ROW_NOT_VISIBLE 182
-#define HA_ERR_ABORTED_BY_USER 183
-#define HA_ERR_DISK_FULL 184
-#define HA_ERR_INCOMPATIBLE_DEFINITION 185
-#define HA_ERR_LAST 185 /* Copy of last error nr */
+/* There's no explicitly listed partition in table for the given value */
+#define HA_ERR_NOT_IN_LOCK_PARTITIONS 178
+#define HA_ERR_INDEX_COL_TOO_LONG 179 /* Index column length exceeds limit */
+#define HA_ERR_INDEX_CORRUPT 180 /* Index corrupted */
+#define HA_ERR_UNDO_REC_TOO_BIG 181 /* Undo log record too big */
+#define HA_FTS_INVALID_DOCID 182 /* Invalid InnoDB Doc ID */
+#define HA_ERR_TABLE_IN_FK_CHECK 183 /* Table being used in foreign key check */
+#define HA_ERR_TABLESPACE_EXISTS 184 /* The tablespace existed in storage engine */
+#define HA_ERR_TOO_MANY_FIELDS 185 /* Table has too many columns */
+#define HA_ERR_ROW_IN_WRONG_PARTITION 186 /* Row in wrong partition */
+#define HA_ERR_ROW_NOT_VISIBLE 187
+#define HA_ERR_ABORTED_BY_USER 188
+#define HA_ERR_DISK_FULL 189
+#define HA_ERR_INCOMPATIBLE_DEFINITION 190
+#define HA_ERR_FTS_TOO_MANY_WORDS_IN_PHRASE 191 /* Too many words in a phrase */
+#define HA_ERR_LAST 191 /* Copy of last error nr */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
@@ -501,13 +536,13 @@ typedef ulong key_part_map;
#define SEARCH_NULL_ARE_EQUAL 32768 /* NULL in keys are equal */
#define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */
/* Use this when inserting a key in position order */
-#define SEARCH_INSERT SEARCH_NULL_ARE_NOT_EQUAL*2
+#define SEARCH_INSERT (SEARCH_NULL_ARE_NOT_EQUAL*2)
/* Only part of the key is specified while reading */
-#define SEARCH_PART_KEY SEARCH_INSERT*2
+#define SEARCH_PART_KEY (SEARCH_INSERT*2)
/* Used when user key (key 2) contains transaction id's */
-#define SEARCH_USER_KEY_HAS_TRANSID SEARCH_PART_KEY*2
+#define SEARCH_USER_KEY_HAS_TRANSID (SEARCH_PART_KEY*2)
/* Used when page key (key 1) contains transaction id's */
-#define SEARCH_PAGE_KEY_HAS_TRANSID SEARCH_USER_KEY_HAS_TRANSID*2
+#define SEARCH_PAGE_KEY_HAS_TRANSID (SEARCH_USER_KEY_HAS_TRANSID*2)
/* bits in opt_flag */
#define QUICK_USED 1
@@ -600,4 +635,17 @@ C_MODE_START
typedef void (* invalidator_by_filename)(const char * filename);
C_MODE_END
+
+enum durability_properties
+{
+ /*
+ Preserves the durability properties defined by the engine */
+ HA_REGULAR_DURABILITY= 0,
+ /*
+ Ignore the durability properties defined by the engine and
+ write only in-memory entries.
+ */
+ HA_IGNORE_DURABILITY= 1
+};
+
#endif /* _my_base_h */
diff --git a/include/my_bitmap.h b/include/my_bitmap.h
index 7bed045bd86..9c9550e3141 100644
--- a/include/my_bitmap.h
+++ b/include/my_bitmap.h
@@ -41,10 +41,14 @@ typedef struct st_bitmap
#ifdef __cplusplus
extern "C" {
#endif
-extern void create_last_word_mask(MY_BITMAP *map);
+
+/* compatibility functions */
#define bitmap_init(A,B,C,D) my_bitmap_init(A,B,C,D)
-extern my_bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
- my_bool thread_safe);
+#define bitmap_free(A) my_bitmap_free(A)
+
+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,
+ my_bool thread_safe);
extern my_bool bitmap_is_clear_all(const MY_BITMAP *map);
extern my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size);
extern my_bool bitmap_is_set_all(const MY_BITMAP *map);
@@ -64,7 +68,8 @@ extern uint bitmap_set_next(MY_BITMAP *map);
extern uint bitmap_get_first(const MY_BITMAP *map);
extern uint bitmap_get_first_set(const MY_BITMAP *map);
extern uint bitmap_bits_set(const MY_BITMAP *map);
-extern void bitmap_free(MY_BITMAP *map);
+extern uint bitmap_get_next_set(const MY_BITMAP *map, uint bitmap_bit);
+extern void my_bitmap_free(MY_BITMAP *map);
extern void bitmap_set_above(MY_BITMAP *map, uint from_byte, uint use_bit);
extern void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size);
extern void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2);
diff --git a/include/my_byteorder.h b/include/my_byteorder.h
new file mode 100644
index 00000000000..1f29248bfb2
--- /dev/null
+++ b/include/my_byteorder.h
@@ -0,0 +1,54 @@
+#ifndef MY_BYTEORDER_INCLUDED
+#define MY_BYTEORDER_INCLUDED
+
+/* Copyright (c) 2001, 2012, 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 */
+
+
+/*
+ Macro for reading 32-bit integer from network byte order (big-endian)
+ from an unaligned memory location.
+*/
+#define int4net(A) (int32) (((uint32) ((uchar) (A)[3])) | \
+ (((uint32) ((uchar) (A)[2])) << 8) | \
+ (((uint32) ((uchar) (A)[1])) << 16) | \
+ (((uint32) ((uchar) (A)[0])) << 24))
+
+/*
+ Function-like macros for reading and storing in machine independent
+ format (low byte first). There are 'korr' (assume 'corrector') variants
+ for integer types, but 'get' (assume 'getter') for floating point types.
+*/
+#if defined(__i386__) || defined(_WIN32)
+#define MY_BYTE_ORDER_ARCH_OPTIMIZED
+#include "byte_order_generic_x86.h"
+#elif defined(__x86_64__)
+#include "byte_order_generic_x86_64.h"
+#else
+#include "byte_order_generic.h"
+#endif
+
+/*
+ Function-like macros for reading and storing in machine format from/to
+ short/long to/from some place in memory V should be a variable (not on
+ a register) and M a pointer to byte.
+*/
+#ifdef WORDS_BIGENDIAN
+#include "big_endian.h"
+#else
+#include "little_endian.h"
+#endif
+
+#endif /* MY_BYTEORDER_INCLUDED */
diff --git a/include/my_check_opt.h b/include/my_check_opt.h
index f952792d2c8..ccf003decab 100644
--- a/include/my_check_opt.h
+++ b/include/my_check_opt.h
@@ -66,6 +66,9 @@ extern "C" {
#define T_NO_CREATE_RENAME_LSN (1ULL << 34)
/** If repair shouldn't do any locks */
#define T_NO_LOCKS (1ULL << 35)
+#define T_CREATE_UNIQUE_BY_SORT (1ULL << 36)
+#define T_SUPPRESS_ERR_HANDLING (1ULL << 37)
+#define T_FORCE_SORT_MEMORY (1ULL << 38)
#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL)
diff --git a/include/my_context.h b/include/my_context.h
index dd44103d3b2..c59d6ce3577 100644
--- a/include/my_context.h
+++ b/include/my_context.h
@@ -178,7 +178,7 @@ struct mysql_async_context {
resumed, eg. whether we woke up due to connection completed or timeout
in mysql_real_connect_cont().
*/
- unsigned int events_occured;
+ unsigned int events_occurred;
/*
This is set to the result of the whole asynchronous operation when it
completes. It uses a union, as different calls have different return
@@ -191,8 +191,8 @@ struct mysql_async_context {
my_bool r_my_bool;
} ret_result;
/*
- The timeout value, for suspended calls that need to wake up on a timeout
- (eg. mysql_real_connect_start().
+ The timeout value (in millisecods), for suspended calls that need to wake
+ up on a timeout (eg. mysql_real_connect_start().
*/
unsigned int timeout_value;
/*
diff --git a/include/my_dbug.h b/include/my_dbug.h
index a7ada40f8bc..f4c854bc10c 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -58,7 +58,7 @@ extern void _db_end_(void);
extern void _db_lock_file_(void);
extern void _db_unlock_file_(void);
extern FILE *_db_fp_(void);
-extern void _db_flush_();
+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);
@@ -89,7 +89,7 @@ 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) do { _db_flush_(); assert(A); } while(0)
+#define DBUG_ASSERT(A) assert(A)
#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)
@@ -123,7 +123,7 @@ extern const char* _db_get_func_(void);
#ifdef __WIN__
#define DBUG_SUICIDE() DBUG_ABORT()
#else
-extern void _db_suicide_();
+extern void _db_suicide_(void);
#define DBUG_SUICIDE() (_db_flush_(), _db_suicide_())
#endif
diff --git a/include/my_default.h b/include/my_default.h
new file mode 100644
index 00000000000..1d556de69ee
--- /dev/null
+++ b/include/my_default.h
@@ -0,0 +1,50 @@
+/* Copyright (C) 2013 Monty Program Ab
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/* Definitions for mysys/my_default.c */
+
+#ifndef MY_DEFAULT_INCLUDED
+#define MY_DEFAULT_INCLUDED
+
+C_MODE_START
+
+extern const char *my_defaults_extra_file;
+extern const char *my_defaults_group_suffix;
+extern const char *my_defaults_file;
+extern my_bool my_getopt_use_args_separator;
+extern my_bool my_getopt_is_args_separator(const char* arg);
+
+/* Define the type of function to be passed to process_default_option_files */
+typedef int (*Process_option_func)(void *ctx, const char *group_name,
+ const char *option);
+
+extern int get_defaults_options(int argc, char **argv,
+ char **defaults, char **extra_defaults,
+ char **group_suffix);
+extern int my_load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv, const char ***);
+extern int load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv);
+extern int my_search_option_files(const char *conf_file, int *argc,
+ char ***argv, uint *args_used,
+ Process_option_func func, void *func_ctx,
+ const char **default_directories);
+extern void free_defaults(char **argv);
+extern void my_print_default_files(const char *conf_file);
+extern void print_defaults(const char *conf_file, const char **groups);
+
+C_MODE_END
+
+#endif /* MY_DEFAULT_INCLUDED */
diff --git a/include/my_dir.h b/include/my_dir.h
index 1ee002cc380..be988ae790c 100644
--- a/include/my_dir.h
+++ b/include/my_dir.h
@@ -45,8 +45,10 @@ 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)
-#define MY_DONT_SORT 512 /* my_lib; Don't sort files */
-#define MY_WANT_STAT 1024 /* my_lib; stat files */
+/* Ensure these dosn'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
/* typedefs for my_dir & my_stat */
@@ -93,7 +95,7 @@ typedef struct st_my_dir /* Struct returned from my_dir */
we don't want to change code that uses my_dir.
*/
struct fileinfo *dir_entry;
- uint number_off_files;
+ uint number_of_files;
} MY_DIR;
extern MY_DIR *my_dir(const char *path,myf MyFlags);
diff --git a/include/my_getopt.h b/include/my_getopt.h
index e3318661c83..18b4bf10698 100644
--- a/include/my_getopt.h
+++ b/include/my_getopt.h
@@ -17,7 +17,9 @@
#ifndef _my_getopt_h
#define _my_getopt_h
-#include "my_sys.h" /* loglevel */
+#include "my_sys.h" /* loglevel */
+/* my_getopt and my_default are almost always used together */
+#include <my_default.h>
C_MODE_START
@@ -85,10 +87,7 @@ struct my_option
void *app_type; /**< To be used by an application */
};
-
typedef my_bool (*my_get_one_option)(int, const struct my_option *, char *);
-typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
- ATTRIBUTE_FORMAT_FPTR(printf, 2, 3);
/**
Used to retrieve a reference to the object (variable) that holds the value
diff --git a/include/my_global.h b/include/my_global.h
index 194e1039c60..816c9dd87c6 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -17,8 +17,8 @@
/* This is the include file that should be included 'first' in every C file. */
-#ifndef _global_h
-#define _global_h
+#ifndef MY_GLOBAL_INCLUDED
+#define MY_GLOBAL_INCLUDED
/* Client library users on Windows need this macro defined here. */
#if !defined(__WIN__) && defined(_WIN32)
@@ -50,11 +50,6 @@
#define _POSIX_THREAD_CPUTIME
#endif /* __CYGWIN__ */
-/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */
-#ifdef USE_PRAGMA_IMPLEMENTATION
-#define USE_PRAGMA_INTERFACE
-#endif
-
#if defined(__OpenBSD__) && (OpenBSD >= 200411)
#define HAVE_ERRNO_AS_DEFINE
#endif
@@ -90,23 +85,18 @@
#define IF_WIN(A,B) B
#endif
+#ifdef EMBEDDED_LIBRARY
+#define IF_EMBEDDED(A,B) A
+#else
+#define IF_EMBEDDED(A,B) B
+#endif
+
#ifdef WITH_PARTITION_STORAGE_ENGINE
#define IF_PARTITIONING(A,B) A
#else
#define IF_PARTITIONING(A,B) B
#endif
-#ifndef EMBEDDED_LIBRARY
-#ifdef WITH_NDB_BINLOG
-#define HAVE_NDB_BINLOG 1
-#endif
-#endif /* !EMBEDDED_LIBRARY */
-
-#ifndef EMBEDDED_LIBRARY
-#define HAVE_REPLICATION
-#define HAVE_EXTERNAL_CLIENT
-#endif
-
#if defined (_WIN32)
/*
off_t is 32 bit long. We do not use C runtime functions
@@ -135,6 +125,7 @@
/* Define missing access() modes. */
#define F_OK 0
#define W_OK 2
+#define R_OK 4 /* Test for read permission. */
/* Define missing file locking constants. */
#define F_RDLCK 1
@@ -153,6 +144,7 @@
/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
#if defined(_AIX) && defined(_LARGE_FILE_API)
#undef _LARGE_FILE_API
+#undef __GNUG__
#endif
/*
@@ -259,6 +251,16 @@
#endif
#endif
+
+#ifdef _AIX
+/*
+ AIX includes inttypes.h from sys/types.h
+ Explicitly request format macros before the first inclusion of inttypes.h
+*/
+#define __STDC_FORMAT_MACROS
+#endif
+
+
#if !defined(__WIN__)
#ifndef _POSIX_PTHREAD_SEMANTICS
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
@@ -311,6 +313,13 @@ C_MODE_END
#define _LONG_LONG 1 /* For AIX string library */
#endif
+/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
+#if defined(_AIX) && defined(_LARGE_FILE_API)
+#undef _LARGE_FILE_API
+#undef __GNUG__
+#endif
+
+
#ifndef stdin
#include <stdio.h>
#endif
@@ -336,6 +345,14 @@ C_MODE_END
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
+
+/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
+#if defined(_AIX) && defined(_LARGE_FILE_API)
+#undef _LARGE_FILE_API
+#undef __GNUG__
+#endif
+
+
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
@@ -467,8 +484,7 @@ typedef unsigned int uint;
typedef unsigned short ushort;
#endif
-#define swap_variables(t, a, b) { t dummy; dummy= a; a= b; b= dummy; }
-#define test(a) ((a) ? 1 : 0)
+#define swap_variables(t, a, b) do { t dummy; dummy= a; a= b; b= dummy; } while(0)
#define MY_TEST(a) ((a) ? 1 : 0)
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
@@ -524,7 +540,11 @@ typedef int my_socket; /* File descriptor for sockets */
/* Type for fuctions that handles signals */
#define sig_handler RETSIGTYPE
C_MODE_START
-typedef void (*sig_return)();/* Returns type from signal */
+#ifdef HAVE_SIGHANDLER_T
+#define sig_return sighandler_t
+#else
+typedef void (*sig_return)(void); /* Returns type from signal */
+#endif
C_MODE_END
#if defined(__GNUC__) && !defined(_lint)
typedef char pchar; /* Mixed prototypes can take char */
@@ -792,6 +812,9 @@ inline unsigned long long my_double2ulonglong(double d)
#else
#define finite(x) (1.0 / fabs(x) > 0.0)
#endif /* HAVE_FINITE */
+#elif (__cplusplus >= 201103L)
+#include <cmath>
+static inline bool isfinite(double x) { return std::isfinite(x); }
#endif /* isfinite */
#ifndef HAVE_ISNAN
@@ -836,7 +859,8 @@ typedef long my_ptrdiff_t;
typedef long long my_ptrdiff_t;
#endif
-#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
+#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
+#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. */
@@ -981,6 +1005,7 @@ typedef struct st_mysql_lex_string LEX_STRING;
#define SOCKET_ETIMEDOUT WSAETIMEDOUT
#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
#define SOCKET_EADDRINUSE WSAEADDRINUSE
+#define SOCKET_ECONNRESET WSAECONNRESET
#define SOCKET_ENFILE ENFILE
#define SOCKET_EMFILE EMFILE
#else /* Unix */
@@ -988,34 +1013,19 @@ typedef struct st_mysql_lex_string LEX_STRING;
#define closesocket(A) close(A)
#define SOCKET_EINTR EINTR
#define SOCKET_EAGAIN EAGAIN
-#define SOCKET_ETIMEDOUT SOCKET_EINTR
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
#define SOCKET_EADDRINUSE EADDRINUSE
+#define SOCKET_ETIMEDOUT ETIMEDOUT
+#define SOCKET_ECONNRESET ECONNRESET
#define SOCKET_ENFILE ENFILE
#define SOCKET_EMFILE EMFILE
#endif
-typedef int myf; /* Type of MyFlags in my_funcs */
-typedef char my_bool; /* Small bool */
+#include <mysql/plugin.h> /* my_bool */
-/* Macros for converting *constants* to the right type */
-#define MYF(v) (myf) (v)
+typedef ulong myf; /* Type of MyFlags in my_funcs */
-#ifndef LL
-#ifdef HAVE_LONG_LONG
-#define LL(A) A ## LL
-#else
-#define LL(A) A ## L
-#endif
-#endif
-
-#ifndef ULL
-#ifdef HAVE_LONG_LONG
-#define ULL(A) A ## ULL
-#else
-#define ULL(A) A ## UL
-#endif
-#endif
+#define MYF(v) (myf) (v)
/*
Defines to make it possible to prioritize register assignments. No
@@ -1048,296 +1058,7 @@ typedef char my_bool; /* Small bool */
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
#define MY_HOW_OFTEN_TO_WRITE 10000 /* How often we want info on screen */
-/*
- Define-funktions for reading and storing in machine independent format
- (low byte first)
-*/
-
-/* Optimized store functions for Intel x86 */
-#if defined(__i386__) || defined(_WIN32)
-#define sint2korr(A) (*((const int16 *) (A)))
-#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
- (((uint32) 255L << 24) | \
- (((uint32) (uchar) (A)[2]) << 16) |\
- (((uint32) (uchar) (A)[1]) << 8) | \
- ((uint32) (uchar) (A)[0])) : \
- (((uint32) (uchar) (A)[2]) << 16) |\
- (((uint32) (uchar) (A)[1]) << 8) | \
- ((uint32) (uchar) (A)[0])))
-#define sint4korr(A) (*((const long *) (A)))
-#define uint2korr(A) (*((const uint16 *) (A)))
-#if defined(HAVE_valgrind) && !defined(_WIN32)
-#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
- (((uint32) ((uchar) (A)[1])) << 8) +\
- (((uint32) ((uchar) (A)[2])) << 16))
-#else
-/*
- ATTENTION !
-
- Please, note, uint3korr reads 4 bytes (not 3) !
- It means, that you have to provide enough allocated space !
-*/
-#define uint3korr(A) (long) (*((const unsigned int *) (A)) & 0xFFFFFF)
-#endif /* HAVE_valgrind && !_WIN32 */
-#define uint4korr(A) (*((const uint32 *) (A)))
-#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
- (((uint32) ((uchar) (A)[1])) << 8) +\
- (((uint32) ((uchar) (A)[2])) << 16) +\
- (((uint32) ((uchar) (A)[3])) << 24)) +\
- (((ulonglong) ((uchar) (A)[4])) << 32))
-#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) + \
- (((uint32) ((uchar) (A)[1])) << 8) + \
- (((uint32) ((uchar) (A)[2])) << 16) + \
- (((uint32) ((uchar) (A)[3])) << 24)) + \
- (((ulonglong) ((uchar) (A)[4])) << 32) + \
- (((ulonglong) ((uchar) (A)[5])) << 40))
-#define uint8korr(A) (*((const ulonglong *) (A)))
-#define sint8korr(A) (*((const longlong *) (A)))
-#define int2store(T,A) *((uint16*) (T))= (uint16) (A)
-#define int3store(T,A) do { *(T)= (uchar) ((A));\
- *(T+1)=(uchar) (((uint) (A) >> 8));\
- *(T+2)=(uchar) (((A) >> 16)); } while (0)
-#define int4store(T,A) *((long *) (T))= (long) (A)
-#define int5store(T,A) do { *(T)= (uchar)((A));\
- *((T)+1)=(uchar) (((A) >> 8));\
- *((T)+2)=(uchar) (((A) >> 16));\
- *((T)+3)=(uchar) (((A) >> 24)); \
- *((T)+4)=(uchar) (((A) >> 32)); } while(0)
-#define int6store(T,A) do { *(T)= (uchar)((A)); \
- *((T)+1)=(uchar) (((A) >> 8)); \
- *((T)+2)=(uchar) (((A) >> 16)); \
- *((T)+3)=(uchar) (((A) >> 24)); \
- *((T)+4)=(uchar) (((A) >> 32)); \
- *((T)+5)=(uchar) (((A) >> 40)); } while(0)
-#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
-
-typedef union {
- double v;
- long m[2];
-} doubleget_union;
-#define doubleget(V,M) \
-do { doubleget_union _tmp; \
- _tmp.m[0] = *((const long*)(M)); \
- _tmp.m[1] = *(((const long*) (M))+1); \
- (V) = _tmp.v; } while(0)
-#define doublestore(T,V) do { *((long *) T) = ((const doubleget_union *)&V)->m[0]; \
- *(((long *) T)+1) = ((const doubleget_union *)&V)->m[1]; \
- } while (0)
-#define float4get(V,M) do { *((float *) &(V)) = *((const float*) (M)); } while(0)
-#define float8get(V,M) doubleget((V),(M))
-#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float))
-#define floatstore(T,V) memcpy((uchar*)(T), (uchar*)(&V),sizeof(float))
-#define floatget(V,M) memcpy((uchar*) &V,(uchar*) (M),sizeof(float))
-#define float8store(V,M) doublestore((V),(M))
-#else
-
-/*
- We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
- were done before)
-*/
-#define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\
- ((int16) ((int16) (A)[1]) << 8))
-#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
- (((uint32) 255L << 24) | \
- (((uint32) (uchar) (A)[2]) << 16) |\
- (((uint32) (uchar) (A)[1]) << 8) | \
- ((uint32) (uchar) (A)[0])) : \
- (((uint32) (uchar) (A)[2]) << 16) |\
- (((uint32) (uchar) (A)[1]) << 8) | \
- ((uint32) (uchar) (A)[0])))
-#define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\
- (((int32) ((uchar) (A)[1]) << 8)) +\
- (((int32) ((uchar) (A)[2]) << 16)) +\
- (((int32) ((int16) (A)[3]) << 24)))
-#define sint8korr(A) (longlong) uint8korr(A)
-#define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\
- ((uint16) ((uchar) (A)[1]) << 8))
-#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
- (((uint32) ((uchar) (A)[1])) << 8) +\
- (((uint32) ((uchar) (A)[2])) << 16))
-#define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\
- (((uint32) ((uchar) (A)[1])) << 8) +\
- (((uint32) ((uchar) (A)[2])) << 16) +\
- (((uint32) ((uchar) (A)[3])) << 24))
-#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
- (((uint32) ((uchar) (A)[1])) << 8) +\
- (((uint32) ((uchar) (A)[2])) << 16) +\
- (((uint32) ((uchar) (A)[3])) << 24)) +\
- (((ulonglong) ((uchar) (A)[4])) << 32))
-#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) + \
- (((uint32) ((uchar) (A)[1])) << 8) + \
- (((uint32) ((uchar) (A)[2])) << 16) + \
- (((uint32) ((uchar) (A)[3])) << 24)) + \
- (((ulonglong) ((uchar) (A)[4])) << 32) + \
- (((ulonglong) ((uchar) (A)[5])) << 40))
-#define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
- (((uint32) ((uchar) (A)[1])) << 8) +\
- (((uint32) ((uchar) (A)[2])) << 16) +\
- (((uint32) ((uchar) (A)[3])) << 24)) +\
- (((ulonglong) (((uint32) ((uchar) (A)[4])) +\
- (((uint32) ((uchar) (A)[5])) << 8) +\
- (((uint32) ((uchar) (A)[6])) << 16) +\
- (((uint32) ((uchar) (A)[7])) << 24))) <<\
- 32))
-#define int2store(T,A) do { uint def_temp= (uint) (A) ;\
- *((uchar*) (T))= (uchar)(def_temp); \
- *((uchar*) (T)+1)=(uchar)((def_temp >> 8)); \
- } while(0)
-#define int3store(T,A) do { /*lint -save -e734 */\
- *((uchar*)(T))=(uchar) ((A));\
- *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
- *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
- /*lint -restore */} while(0)
-#define int4store(T,A) do { *((char *)(T))=(char) ((A));\
- *(((char *)(T))+1)=(char) (((A) >> 8));\
- *(((char *)(T))+2)=(char) (((A) >> 16));\
- *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
-#define int5store(T,A) do { *((char *)(T))= (char)((A)); \
- *(((char *)(T))+1)= (char)(((A) >> 8)); \
- *(((char *)(T))+2)= (char)(((A) >> 16)); \
- *(((char *)(T))+3)= (char)(((A) >> 24)); \
- *(((char *)(T))+4)= (char)(((A) >> 32)); \
- } while(0)
-#define int6store(T,A) do { *((char *)(T))= (char)((A)); \
- *(((char *)(T))+1)= (char)(((A) >> 8)); \
- *(((char *)(T))+2)= (char)(((A) >> 16)); \
- *(((char *)(T))+3)= (char)(((A) >> 24)); \
- *(((char *)(T))+4)= (char)(((A) >> 32)); \
- *(((char *)(T))+5)= (char)(((A) >> 40)); \
- } while(0)
-#define int8store(T,A) do { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
- int4store((T),def_temp); \
- int4store((T+4),def_temp2); } while(0)
-#ifdef WORDS_BIGENDIAN
-#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\
- *((T)+1)=(char) ((uchar *) &A)[2];\
- *((T)+2)=(char) ((uchar *) &A)[1];\
- *((T)+3)=(char) ((uchar *) &A)[0]; } while(0)
-
-#define float4get(V,M) do { float def_temp;\
- ((uchar*) &def_temp)[0]=(M)[3];\
- ((uchar*) &def_temp)[1]=(M)[2];\
- ((uchar*) &def_temp)[2]=(M)[1];\
- ((uchar*) &def_temp)[3]=(M)[0];\
- (V)=def_temp; } while(0)
-#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\
- *((T)+1)=(char) ((uchar *) &V)[6];\
- *((T)+2)=(char) ((uchar *) &V)[5];\
- *((T)+3)=(char) ((uchar *) &V)[4];\
- *((T)+4)=(char) ((uchar *) &V)[3];\
- *((T)+5)=(char) ((uchar *) &V)[2];\
- *((T)+6)=(char) ((uchar *) &V)[1];\
- *((T)+7)=(char) ((uchar *) &V)[0]; } while(0)
-
-#define float8get(V,M) do { double def_temp;\
- ((uchar*) &def_temp)[0]=(M)[7];\
- ((uchar*) &def_temp)[1]=(M)[6];\
- ((uchar*) &def_temp)[2]=(M)[5];\
- ((uchar*) &def_temp)[3]=(M)[4];\
- ((uchar*) &def_temp)[4]=(M)[3];\
- ((uchar*) &def_temp)[5]=(M)[2];\
- ((uchar*) &def_temp)[6]=(M)[1];\
- ((uchar*) &def_temp)[7]=(M)[0];\
- (V) = def_temp; } while(0)
-#else
-#define float4get(V,M) memcpy(&V, (M), sizeof(float))
-#define float4store(V,M) memcpy(V, (&M), sizeof(float))
-
-#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
-#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\
- *(((char*)T)+1)=(char) ((uchar *) &V)[5];\
- *(((char*)T)+2)=(char) ((uchar *) &V)[6];\
- *(((char*)T)+3)=(char) ((uchar *) &V)[7];\
- *(((char*)T)+4)=(char) ((uchar *) &V)[0];\
- *(((char*)T)+5)=(char) ((uchar *) &V)[1];\
- *(((char*)T)+6)=(char) ((uchar *) &V)[2];\
- *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\
- while(0)
-#define doubleget(V,M) do { double def_temp;\
- ((uchar*) &def_temp)[0]=(M)[4];\
- ((uchar*) &def_temp)[1]=(M)[5];\
- ((uchar*) &def_temp)[2]=(M)[6];\
- ((uchar*) &def_temp)[3]=(M)[7];\
- ((uchar*) &def_temp)[4]=(M)[0];\
- ((uchar*) &def_temp)[5]=(M)[1];\
- ((uchar*) &def_temp)[6]=(M)[2];\
- ((uchar*) &def_temp)[7]=(M)[3];\
- (V) = def_temp; } while(0)
-#endif /* __FLOAT_WORD_ORDER */
-
-#define float8get(V,M) doubleget((V),(M))
-#define float8store(V,M) doublestore((V),(M))
-#endif /* WORDS_BIGENDIAN */
-
-#endif /* __i386__ OR _WIN32 */
-
-/*
- Macro for reading 32-bit integer from network byte order (big-endian)
- from unaligned memory location.
-*/
-#define int4net(A) (int32) (((uint32) ((uchar) (A)[3])) |\
- (((uint32) ((uchar) (A)[2])) << 8) |\
- (((uint32) ((uchar) (A)[1])) << 16) |\
- (((uint32) ((uchar) (A)[0])) << 24))
-/*
- Define-funktions for reading and storing in machine format from/to
- short/long to/from some place in memory V should be a (not
- register) variable, M is a pointer to byte
-*/
-
-#ifdef WORDS_BIGENDIAN
-
-#define ushortget(V,M) do { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
- ((uint16) ((uint16) (M)[0]) << 8)); } while(0)
-#define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\
- ((short) ((short) (M)[0]) << 8)); } while(0)
-#define longget(V,M) do { int32 def_temp;\
- ((uchar*) &def_temp)[0]=(M)[0];\
- ((uchar*) &def_temp)[1]=(M)[1];\
- ((uchar*) &def_temp)[2]=(M)[2];\
- ((uchar*) &def_temp)[3]=(M)[3];\
- (V)=def_temp; } while(0)
-#define ulongget(V,M) do { uint32 def_temp;\
- ((uchar*) &def_temp)[0]=(M)[0];\
- ((uchar*) &def_temp)[1]=(M)[1];\
- ((uchar*) &def_temp)[2]=(M)[2];\
- ((uchar*) &def_temp)[3]=(M)[3];\
- (V)=def_temp; } while(0)
-#define shortstore(T,A) do { uint def_temp=(uint) (A) ;\
- *(((char*)T)+1)=(char)(def_temp); \
- *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
-#define longstore(T,A) do { *(((char*)T)+3)=((A));\
- *(((char*)T)+2)=(((A) >> 8));\
- *(((char*)T)+1)=(((A) >> 16));\
- *(((char*)T)+0)=(((A) >> 24)); } while(0)
-
-#define floatget(V,M) memcpy(&V, (M), sizeof(float))
-#define floatstore(T,V) memcpy((T), (void*) (&V), sizeof(float))
-#define doubleget(V,M) memcpy(&V, (M), sizeof(double))
-#define doublestore(T,V) memcpy((T), (void *) &V, sizeof(double))
-#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong))
-#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong))
-
-#else
-
-#define ushortget(V,M) do { V = uint2korr(M); } while(0)
-#define shortget(V,M) do { V = sint2korr(M); } while(0)
-#define longget(V,M) do { V = sint4korr(M); } while(0)
-#define ulongget(V,M) do { V = uint4korr(M); } while(0)
-#define shortstore(T,V) int2store(T,V)
-#define longstore(T,V) int4store(T,V)
-#ifndef floatstore
-#define floatstore(T,V) memcpy((T), (void *) (&V), sizeof(float))
-#define floatget(V,M) memcpy(&V, (M), sizeof(float))
-#endif
-#ifndef doubleget
-#define doubleget(V,M) memcpy(&V, (M), sizeof(double))
-#define doublestore(T,V) memcpy((T), (void *) &V, sizeof(double))
-#endif /* doubleget */
-#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong))
-#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong))
-
-#endif /* WORDS_BIGENDIAN */
+#include <my_byteorder.h>
#ifdef HAVE_CHARSET_utf8
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
@@ -1356,10 +1077,9 @@ do { doubleget_union _tmp; \
static inline char *dlerror(void)
{
static char win_errormsg[2048];
- if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
- 0, GetLastError(), 0, win_errormsg, 2048, NULL))
- return win_errormsg;
- return "";
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
+ 0, GetLastError(), 0, win_errormsg, 2048, NULL);
+ return win_errormsg;
}
#define HAVE_DLOPEN 1
#define HAVE_DLERROR 1
@@ -1406,10 +1126,8 @@ typedef struct { const char *dli_fname, dli_fbase; } Dl_info;
#endif
/* Define some useful general macros (should be done after all headers). */
-#if !defined(max)
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
+#define MY_MAX(a, b) ((a) > (b) ? (a) : (b))
+#define MY_MIN(a, b) ((a) < (b) ? (a) : (b))
#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
@@ -1512,6 +1230,18 @@ static inline double rint(double x)
#undef HAVE_SMEM /* No shared memory */
+#else
+#ifdef WITH_NDB_BINLOG
+#define HAVE_NDB_BINLOG 1
+#endif
+#define HAVE_REPLICATION
+#define HAVE_EXTERNAL_CLIENT
#endif /* EMBEDDED_LIBRARY */
+/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
+#if defined(_AIX) && defined(_LARGE_FILE_API)
+#undef _LARGE_FILE_API
+#undef __GNUG__
+#endif
+
#endif /* my_global_h */
diff --git a/include/my_handler_errors.h b/include/my_handler_errors.h
new file mode 100644
index 00000000000..a7afcfe93a3
--- /dev/null
+++ b/include/my_handler_errors.h
@@ -0,0 +1,100 @@
+#ifndef MYSYS_MY_HANDLER_ERRORS_INCLUDED
+#define MYSYS_MY_HANDLER_ERRORS_INCLUDED
+
+/* Copyright (c) 2008, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2011, 2013, SkySQL Ab.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+/*
+ Errors a handler can give you
+*/
+
+static const char *handler_error_messages[]=
+{
+ "Didn't find key on read or update",
+ "Duplicate key on write or update",
+ "Internal (unspecified) error in handler",
+ "Someone has changed the row since it was read (while the table was locked to prevent it)",
+ "Wrong index given to function",
+ "Undefined handler error 125",
+ "Index file is crashed",
+ "Record file is crashed",
+ "Out of memory in engine",
+ "Undefined handler error 129",
+ "Incorrect file format",
+ "Command not supported by database",
+ "Old database file",
+ "No record read before update",
+ "Record was already deleted (or record file crashed)",
+ "No more room in record file",
+ "No more room in index file",
+ "No more records (read after end of file)",
+ "Unsupported extension used for table",
+ "Too big row",
+ "Wrong create options",
+ "Duplicate unique key or constraint on write or update",
+ "Unknown character set used in table",
+ "Conflicting table definitions in sub-tables of MERGE table",
+ "Table is crashed and last repair failed",
+ "Table was marked as crashed and should be repaired",
+ "Lock timed out; Retry transaction",
+ "Lock table is full; Restart program with a larger lock table",
+ "Updates are not allowed under a read only transactions",
+ "Lock deadlock; Retry transaction",
+ "Foreign key constraint is incorrectly formed",
+ "Cannot add a child row",
+ "Cannot delete a parent row",
+ "No savepoint with that name",
+ "Non unique key block size",
+ "The table does not exist in engine",
+ "The table already existed in storage engine",
+ "Could not connect to storage engine",
+ "Unexpected null pointer found when using spatial index",
+ "The table changed in storage engine",
+ "There's no partition in table for the given value",
+ "Row-based binary logging of row failed",
+ "Index needed in foreign key constraint",
+ "Upholding foreign key constraints would lead to a duplicate key error in some other table",
+ "Table needs to be upgraded before it can be used",
+ "Table is read only",
+ "Failed to get next auto increment value",
+ "Failed to set row auto increment value",
+ "Unknown (generic) error from engine",
+ "Record was not update. Original values was same as new values",
+ "It is not possible to log this statement",
+ "The event was corrupt, leading to illegal data being read",
+ "The table is of a new format not supported by this version",
+ "The event could not be processed. No other handler error happened",
+ "Got a fatal error during initialization of handler",
+ "File too short; Expected more data in file",
+ "Read page with wrong checksum",
+ "Too many active concurrent transactions",
+ "Record not matching the given partition set",
+ "Index column length exceeds limit",
+ "Index corrupted",
+ "Undo record too big",
+ "Invalid InnoDB FTS Doc ID",
+ "Table is being used in foreign key check",
+ "Tablespace already exists",
+ "Too many columns",
+ "Row in wrong partition",
+ "Row is not visible by the current transaction",
+ "Operation was interrupted by end user (probably kill command?)",
+ "Disk full",
+ "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump and restore the table to fix this",
+ "Too many words in a FTS phrase or proximity search"
+};
+
+#endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */
diff --git a/include/my_md5.h b/include/my_md5.h
index f8838aa72f7..77557fb9346 100644
--- a/include/my_md5.h
+++ b/include/my_md5.h
@@ -1,8 +1,8 @@
#ifndef MY_MD5_INCLUDED
#define MY_MD5_INCLUDED
-/* Copyright (c) 2000, 2001, 2007 MySQL AB, 2009 Sun Microsystems, Inc.
- Use is subject to license terms
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+ Copyright (c) 2013 Monty Program Ab
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,44 +17,36 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
-/* See md5.c for explanation and copyright information. */
+#include "m_string.h"
-/*
- * $FreeBSD: src/contrib/cvs/lib/md5.h,v 1.2 1999/12/11 15:10:02 peter Exp $
- */
-
-/* Unlike previous versions of this code, uint32 need not be exactly
- 32 bits, merely 32 bits or more. Choosing a data type which is 32
- bits instead of 64 is not important; speed is considerably more
- important. ANSI guarantees that "unsigned long" will be big enough,
- and always using it seems to have few disadvantages. */
-typedef uint32 cvs_uint32;
-
-typedef struct {
- cvs_uint32 buf[4];
- cvs_uint32 bits[2];
- unsigned char in[64];
-} my_MD5Context;
+#define MD5_HASH_SIZE 16 /* Hash size in bytes */
+/*
+ Wrapper function for MD5 implementation.
+*/
#ifdef __cplusplus
extern "C" {
#endif
-void my_MD5Init (my_MD5Context *context);
-void my_MD5Update (my_MD5Context *context,
- unsigned char const *buf, unsigned len);
-void my_MD5Final (unsigned char digest[16],
- my_MD5Context *context);
+
+void compute_md5_hash(char *digest, const char *buf, int len);
+
+/*
+ Convert an array of bytes to a hexadecimal representation.
+
+ Used to generate a hexadecimal representation of a message digest.
+*/
+static inline void array_to_hex(char *to, const unsigned char *str, uint len)
+{
+ const unsigned char *str_end= str + len;
+ for (; str != str_end; ++str)
+ {
+ *to++= _dig_vec_lower[((uchar) *str) >> 4];
+ *to++= _dig_vec_lower[((uchar) *str) & 0x0F];
+ }
+}
#ifdef __cplusplus
}
#endif
-#define MY_MD5_HASH(digest,buf,len) \
-do { \
- my_MD5Context ctx; \
- my_MD5Init (&ctx); \
- my_MD5Update (&ctx, buf, len); \
- my_MD5Final (digest, &ctx); \
-} while (0)
-
-#endif /* MY_MD__INCLUDED */
+#endif /* MY_MD5_INCLUDED */
diff --git a/include/my_net.h b/include/my_net.h
index f8c4f99bae7..1ebb71ead23 100644
--- a/include/my_net.h
+++ b/include/my_net.h
@@ -61,13 +61,15 @@ C_MODE_START
#define SD_BOTH 0x02
*/
#define SHUT_RDWR 0x02
-
+#else
+#include <netdb.h> /* getaddrinfo() & co */
#endif
/*
- On OSes which don't have the in_addr_t, we guess that using uint32 is the best
- possible choice. We guess this from the fact that on HP-UX64bit & FreeBSD64bit
- & Solaris64bit, in_addr_t is equivalent to uint32. And on Linux32bit too.
+ On OSes which don't have the in_addr_t, we guess that using uint32
+ is the best possible choice. We guess this from the fact that on
+ HP-UX64bit & FreeBSD64bit & Solaris64bit, in_addr_t is equivalent to
+ uint32. And on Linux32bit too.
*/
#ifndef HAVE_IN_ADDR_T
#define in_addr_t uint32
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 9b5703dedb7..cff6416904a 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -150,6 +150,7 @@ int pthread_cancel(pthread_t thread);
#define pthread_mutex_destroy(A) (DeleteCriticalSection(A), 0)
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
+
/* Dummy defines for easier code */
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
#define pthread_attr_setscope(A,B)
@@ -325,7 +326,6 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
for calculating an absolute time at which
pthread_cond_timedwait should timeout
*/
-
#define set_timespec(ABSTIME,SEC) set_timespec_nsec((ABSTIME),(SEC)*1000000000ULL)
#ifndef set_timespec_nsec
@@ -430,24 +430,6 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp);
#define MYF_NO_DEADLOCK_DETECTION 2
#ifdef SAFE_MUTEX
-#undef pthread_mutex_init
-#undef pthread_mutex_lock
-#undef pthread_mutex_unlock
-#undef pthread_mutex_destroy
-#undef pthread_mutex_wait
-#undef pthread_mutex_timedwait
-#undef pthread_mutex_t
-#undef pthread_cond_wait
-#undef pthread_cond_timedwait
-#undef pthread_mutex_trylock
-#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),#A,__FILE__,__LINE__)
-#define pthread_mutex_lock(A) safe_mutex_lock((A),0,__FILE__, __LINE__)
-#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
-#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)
-#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__)
-#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
-#define pthread_mutex_trylock(A) safe_mutex_lock((A), MYF_TRY_LOCK, __FILE__, __LINE__)
-#define pthread_mutex_t safe_mutex_t
#define safe_mutex_assert_owner(mp) \
DBUG_ASSERT((mp)->count > 0 && \
pthread_equal(pthread_self(), (mp)->thread))
@@ -455,13 +437,22 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp);
DBUG_ASSERT(! (mp)->count || \
! pthread_equal(pthread_self(), (mp)->thread))
#define safe_mutex_setflags(mp, F) do { (mp)->create_flags|= (F); } while (0)
+#define my_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
+#define my_cond_wait(A,B) safe_cond_wait((A), (B), __FILE__, __LINE__)
#else
-#define my_pthread_mutex_init(A,B,C,D) pthread_mutex_init((A),(B))
-#define safe_mutex_assert_owner(mp) do {} while(0)
-#define safe_mutex_assert_not_owner(mp) do {} while(0)
-#define safe_mutex_free_deadlock_data(mp) do {} while(0)
+
+#define safe_mutex_assert_owner(mp) do {} while (0)
+#define safe_mutex_assert_not_owner(mp) do {} while (0)
#define safe_mutex_setflags(mp, F) do {} while (0)
-#endif /* SAFE_MUTEX */
+
+#if defined(MY_PTHREAD_FASTMUTEX)
+#define my_cond_timedwait(A,B,C) pthread_cond_timedwait((A), &(B)->mutex, (C))
+#define my_cond_wait(A,B) pthread_cond_wait((A), &(B)->mutex)
+#else
+#define my_cond_timedwait(A,B,C) pthread_cond_timedwait((A),(B),(C))
+#define my_cond_wait(A,B) pthread_cond_wait((A), (B))
+#endif /* MY_PTHREAD_FASTMUTEX */
+#endif /* !SAFE_MUTEX */
#if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
typedef struct st_my_pthread_fastmutex_t
@@ -476,24 +467,6 @@ int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp,
const pthread_mutexattr_t *attr);
int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp);
-#undef pthread_mutex_init
-#undef pthread_mutex_lock
-#undef pthread_mutex_unlock
-#undef pthread_mutex_destroy
-#undef pthread_mutex_wait
-#undef pthread_mutex_timedwait
-#undef pthread_mutex_t
-#undef pthread_cond_wait
-#undef pthread_cond_timedwait
-#undef pthread_mutex_trylock
-#define pthread_mutex_init(A,B) my_pthread_fastmutex_init((A),(B))
-#define pthread_mutex_lock(A) my_pthread_fastmutex_lock(A)
-#define pthread_mutex_unlock(A) pthread_mutex_unlock(&(A)->mutex)
-#define pthread_mutex_destroy(A) pthread_mutex_destroy(&(A)->mutex)
-#define pthread_cond_wait(A,B) pthread_cond_wait((A),&(B)->mutex)
-#define pthread_cond_timedwait(A,B,C) pthread_cond_timedwait((A),&(B)->mutex,(C))
-#define pthread_mutex_trylock(A) pthread_mutex_trylock(&(A)->mutex)
-#define pthread_mutex_t my_pthread_fastmutex_t
#endif /* defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) */
/* READ-WRITE thread locking */
@@ -730,8 +703,8 @@ extern void my_thread_end(void);
extern const char *my_thread_name(void);
extern my_thread_id my_thread_dbug_id(void);
extern int pthread_dummy(int);
-extern void my_mutex_init();
-extern void my_mutex_end();
+extern void my_mutex_init(void);
+extern void my_mutex_end(void);
/* All thread specific variables are in the following struct */
@@ -760,11 +733,10 @@ struct st_my_thread_var
mysql_cond_t * volatile current_cond;
pthread_t pthread_self;
my_thread_id id;
- int cmp_length;
int volatile abort;
my_bool init;
struct st_my_thread_var *next,**prev;
- void *opt_info;
+ void *keycache_link;
uint lock_type; /* used by conditional release the queue */
void *stack_ends_here;
safe_mutex_t *mutex_in_use;
@@ -775,8 +747,8 @@ struct st_my_thread_var
};
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
-extern void **my_thread_var_dbug();
-extern safe_mutex_t **my_thread_var_mutex_in_use();
+extern void **my_thread_var_dbug(void);
+extern safe_mutex_t **my_thread_var_mutex_in_use(void);
extern uint my_thread_end_wait_time;
extern my_bool safe_mutex_deadlock_detector;
#define my_thread_var (_my_thread_var())
diff --git a/include/my_rnd.h b/include/my_rnd.h
new file mode 100644
index 00000000000..b4a5d735811
--- /dev/null
+++ b/include/my_rnd.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2013 Monty Program Ab
+
+ 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 or later 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef _my_rnd_h
+#define _my_rnd_h
+
+C_MODE_START
+
+struct my_rnd_struct {
+ unsigned long seed1,seed2,max_value;
+ double max_value_dbl;
+};
+
+void my_rnd_init(struct my_rnd_struct *rand_st, ulong seed1, ulong seed2);
+double my_rnd(struct my_rnd_struct *rand_st);
+double my_rnd_ssl(struct my_rnd_struct *rand_st);
+
+C_MODE_END
+
+#endif /* _my_rnd_h */
diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h
index ad05a7df9ab..fad6e532de9 100644
--- a/include/my_stacktrace.h
+++ b/include/my_stacktrace.h
@@ -35,8 +35,7 @@
#define HAVE_WRITE_CORE
-#if HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS && \
- HAVE_CXXABI_H && HAVE_ABI_CXA_DEMANGLE && \
+#if HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS && HAVE_ABI_CXA_DEMANGLE && \
HAVE_WEAK_SYMBOL
#define BACKTRACE_DEMANGLE 1
#endif
@@ -46,7 +45,7 @@ C_MODE_START
#if defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)
void my_init_stacktrace();
void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack);
-void my_safe_print_str(const char* val, int max_len);
+int my_safe_print_str(const char* val, int 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 7b229bb52b0..69daf09311e 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -53,6 +53,7 @@ typedef struct my_aio_result {
area, and we would like to avoid unexpected truncation.
*/
#define MYSYS_ERRMSG_SIZE (512)
+#define MYSYS_STRERROR_SIZE (128)
#define MY_FILE_ERROR ((size_t) -1)
@@ -86,6 +87,10 @@ typedef struct my_aio_result {
#define MY_SYNC 4096 /* my_copy(): sync dst file */
#define MY_SYNC_DIR 32768 /* my_create/delete/rename: sync directory */
#define MY_SYNC_FILESIZE 65536 /* my_sync(): safe sync when file is extended */
+#define MY_THREAD_SPECIFIC 0x10000 /* my_malloc(): thread specific */
+#define MY_THREAD_MOVE 0x20000 /* realloc(); Memory can move */
+/* Tree that should delete things automaticly */
+#define MY_TREE_WITH_DELETE 0x40000
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
#define MY_GIVE_INFO 2 /* Give time info about process*/
@@ -148,17 +153,28 @@ typedef struct my_aio_result {
/* Extra length needed for filename if one calls my_create_backup_name */
#define MY_BACKUP_NAME_EXTRA_LENGTH 17
+/* If we have our own safemalloc (for debugging) */
+#if defined(SAFEMALLOC)
+void sf_report_leaked_memory(my_thread_id id);
+extern my_thread_id (*sf_malloc_dbug_id)(void);
+#define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X)
+#else
+#define SAFEMALLOC_REPORT_MEMORY(X) do {} while(0)
+#endif
+
+typedef void (*MALLOC_SIZE_CB) (long long size, my_bool is_thread_specific);
+extern void set_malloc_size_cb(MALLOC_SIZE_CB func);
+
/* defines when allocating data */
extern void *my_malloc(size_t Size,myf MyFlags);
extern void *my_multi_malloc(myf MyFlags, ...);
+extern void *my_multi_malloc_large(myf MyFlags, ...);
extern void *my_realloc(void *oldpoint, size_t Size, myf MyFlags);
extern void my_free(void *ptr);
extern void *my_memdup(const void *from,size_t length,myf MyFlags);
extern char *my_strdup(const char *from,myf MyFlags);
extern char *my_strndup(const char *from, size_t length, myf MyFlags);
-extern int sf_leaking_memory; /* set to 1 to disable memleak detection */
-
#ifdef HAVE_LARGE_PAGES
extern uint my_get_large_page_size(void);
extern uchar * my_large_malloc(size_t size, myf my_flags);
@@ -182,14 +198,18 @@ extern void my_large_free(uchar *ptr);
#endif /* GNUC */
#define my_alloca(SZ) alloca((size_t) (SZ))
#define my_afree(PTR) ((void)0)
+#define my_safe_alloca(size, max_alloca_sz) ((size <= max_alloca_sz) ? \
+ my_alloca(size) : \
+ my_malloc(size, MYF(0)))
+#define my_safe_afree(ptr, size, max_alloca_sz) if (size > max_alloca_sz) \
+ my_free(ptr)
#else
#define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE))
#define my_afree(PTR) my_free(PTR)
+#define my_safe_alloca(size, max_alloca_sz) my_alloca(size)
+#define my_safe_afree(ptr, size, max_alloca_sz) my_afree(ptr)
#endif /* HAVE_ALLOCA */
-#define my_safe_alloca(size, min_length) ((size <= min_length) ? my_alloca(size) : my_malloc(size,MYF(MY_FAE)))
-#define my_safe_afree(ptr, size, min_length) ((size <= min_length) ? my_afree(ptr) : my_free(ptr))
-
#ifndef errno /* did we already get it? */
#ifdef HAVE_ERRNO_AS_DEFINE
#include <errno.h> /* errno is a define */
@@ -207,9 +227,10 @@ extern void (*fatal_error_handler_hook)(uint my_err, const char *str,
myf MyFlags);
extern uint my_file_limit;
extern ulonglong my_thread_stack_size;
+extern int sf_leaking_memory; /* set to 1 to disable memleak detection */
-extern const char *(*proc_info_hook)(MYSQL_THD, const char *, const char *,
- const char *, const unsigned int);
+extern void (*proc_info_hook)(void *, const PSI_stage_info *, PSI_stage_info *,
+ const char *, const char *, const unsigned int);
#ifdef HAVE_LARGE_PAGES
extern my_bool my_use_large_pages;
@@ -222,6 +243,11 @@ extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *default_charset_info;
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *all_charsets[MY_ALL_CHARSETS_SIZE];
extern struct charset_info_st compiled_charsets[];
+/* Collation properties and use statistics */
+extern my_bool my_collation_is_known_id(uint id);
+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_file_total_opened;
@@ -233,8 +259,7 @@ 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),
- (*my_abort_hook)(int);
+ (*my_sigtstp_restart)(void);
/* Executed when comming from shell */
extern MYSQL_PLUGIN_IMPORT int my_umask; /* Default creation mask */
extern int my_umask_dir,
@@ -249,19 +274,8 @@ extern my_bool my_disable_locking, my_disable_async_io,
extern my_bool my_disable_sync, my_disable_copystat_in_redel;
extern char wild_many,wild_one,wild_prefix;
extern const char *charsets_dir;
-/* from default.c */
-extern const char *my_defaults_extra_file;
-extern const char *my_defaults_group_suffix;
-extern const char *my_defaults_file;
-
extern my_bool timed_mutexes;
-enum loglevel {
- ERROR_LEVEL,
- WARNING_LEVEL,
- INFORMATION_LEVEL
-};
-
enum cache_type
{
TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE,
@@ -318,12 +332,16 @@ struct st_my_file_info
extern struct st_my_file_info *my_file_info;
+/* Free function pointer */
+typedef void (*FREE_FUNC)(void *);
+
typedef struct st_dynamic_array
{
uchar *buffer;
uint elements,max_element;
uint alloc_increment;
uint size_of_element;
+ myf malloc_flags;
} DYNAMIC_ARRAY;
typedef struct st_my_tmpdir
@@ -490,6 +508,11 @@ typedef struct st_io_cache /* Used when cacheing files */
typedef int (*qsort2_cmp)(const void *, const void *, const void *);
+typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
+ ATTRIBUTE_FORMAT_FPTR(printf, 2, 3);
+
+extern my_error_reporter my_charset_error_reporter;
+
/* defines for mf_iocache */
/* Test if buffer is inited */
@@ -544,15 +567,9 @@ my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
typedef uint32 ha_checksum;
extern ulong my_crc_dbug_check;
-/* Define the type of function to be passed to process_default_option_files */
-typedef int (*Process_option_func)(void *ctx, const char *group_name,
- const char *option);
-
extern int (*mysys_test_invalid_symlink)(const char *filename);
-
#include <my_alloc.h>
-
/* Prototypes for mysys and my_func functions */
extern int my_copy(const char *from,const char *to,myf MyFlags);
@@ -616,6 +633,13 @@ int my_set_user(const char *user, struct passwd *user_info, myf MyFlags);
extern int check_if_legal_filename(const char *path);
extern int check_if_legal_tablename(const char *path);
+#ifdef __WIN__
+extern my_bool is_filename_allowed(const char *name, size_t length,
+ my_bool allow_current_dir);
+#else /* __WIN__ */
+# define is_filename_allowed(name, length, allow_cwd) (TRUE)
+#endif /* __WIN__ */
+
#ifdef _WIN32
/* Windows-only functions (CRT equivalents)*/
extern HANDLE my_get_osfhandle(File fd);
@@ -623,13 +647,14 @@ extern void my_osmaperr(unsigned long last_error);
#endif
extern void init_glob_errs(void);
-extern const char** get_global_errmsgs();
+extern const char** get_global_errmsgs(void);
extern void wait_for_free_space(const char *filename, int errors);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern FILE *my_freopen(const char *path, const char *mode, FILE *stream);
extern int my_fclose(FILE *fd,myf MyFlags);
extern int my_vfprintf(FILE *stream, const char* format, va_list args);
+extern void my_strerror(char *buf, size_t len, int nr);
extern int my_fprintf(FILE *stream, const char* format, ...);
extern File my_fileno(FILE *fd);
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
@@ -640,13 +665,14 @@ extern void thr_set_sync_wait_callback(void (*before_sync)(void),
extern int my_sync(File fd, myf my_flags);
extern int my_sync_dir(const char *dir_name, myf my_flags);
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
-extern void my_error(int nr,myf MyFlags, ...);
+extern const char *my_get_err_msg(uint nr);
+extern void my_error(uint nr,myf MyFlags, ...);
extern void my_printf_error(uint my_err, const char *format, myf MyFlags, ...);
extern void my_printv_error(uint error, const char *format, myf MyFlags,
va_list ap);
-extern int my_error_register(const char** (*get_errmsgs) (),
- int first, int last);
-extern const char **my_error_unregister(int first, int last);
+extern int my_error_register(const char** (*get_errmsgs) (void),
+ uint first, uint last);
+extern const char **my_error_unregister(uint first, uint last);
extern void my_message(uint my_err, const char *str,myf MyFlags);
extern void my_message_stderr(uint my_err, const char *str, myf MyFlags);
extern my_bool my_init(void);
@@ -689,7 +715,6 @@ extern size_t cleanup_dirname(char * to,const char *from);
extern size_t system_filename(char * to,const char *from);
extern size_t unpack_filename(char * to,const char *from);
extern char * intern_filename(char * to,const char *from);
-extern char * directory_file_name(char * dst, const char *src);
extern int pack_filename(char * to, const char *name, size_t max_length);
extern char * my_path(char * to,const char *progname,
const char *own_pathname_part);
@@ -713,6 +738,7 @@ extern int flush_write_cache(RECORD_CACHE *info);
extern void handle_recived_signals(void);
extern sig_handler my_set_alarm_variable(int signo);
+extern my_bool radixsort_is_appliccable(uint n_items, size_t size_of_element);
extern void my_string_ptr_sort(uchar *base,uint items,size_t size);
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
size_t size_of_element,uchar *buffer[]);
@@ -765,26 +791,23 @@ extern my_bool real_open_cached_file(IO_CACHE *cache);
extern void close_cached_file(IO_CACHE *cache);
File create_temp_file(char *to, const char *dir, const char *pfx,
int mode, myf MyFlags);
-#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
-#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
-#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
-#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
+#define my_init_dynamic_array(A,B,C,D,E) init_dynamic_array2(A,B,NULL,C,D,E)
+#define my_init_dynamic_array2(A,B,C,D,E,F) init_dynamic_array2(A,B,C,D,E,F)
extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
void *init_buffer, uint init_alloc,
- uint alloc_increment);
-/* init_dynamic_array() function is deprecated */
-extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
- uint init_alloc, uint alloc_increment);
-extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const uchar * element);
-extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array);
-extern uchar *pop_dynamic(DYNAMIC_ARRAY*);
-extern my_bool set_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index);
+ uint alloc_increment, myf my_flags);
+extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void* element);
+extern void *alloc_dynamic(DYNAMIC_ARRAY *array);
+extern void *pop_dynamic(DYNAMIC_ARRAY*);
+extern my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element,
+ uint array_index);
extern my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements);
-extern void get_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index);
+extern void get_dynamic(DYNAMIC_ARRAY *array, void *element, uint array_index);
extern void delete_dynamic(DYNAMIC_ARRAY *array);
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
+extern void delete_dynamic_with_callback(DYNAMIC_ARRAY *array, FREE_FUNC f);
extern void freeze_size(DYNAMIC_ARRAY *array);
-extern int get_index_dynamic(DYNAMIC_ARRAY *array, uchar * element);
+extern int get_index_dynamic(DYNAMIC_ARRAY *array, void *element);
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
#define push_dynamic(A,B) insert_dynamic((A),(B))
@@ -798,12 +821,23 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
size_t length);
extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append,
...);
+extern my_bool dynstr_append_quoted(DYNAMIC_STRING *str,
+ const char *append, size_t len,
+ char quote);
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
extern void dynstr_free(DYNAMIC_STRING *str);
+extern uint32 copy_and_convert_extended(char *to, uint32 to_length,
+ CHARSET_INFO *to_cs,
+ const char *from, uint32 from_length,
+ CHARSET_INFO *from_cs, uint *errors);
extern void dynstr_reassociate(DYNAMIC_STRING *str, char **res, size_t *length,
size_t *alloc_length);
+extern uint32 copy_and_convert_extended(char *to, uint32 to_length,
+ CHARSET_INFO *to_cs,
+ const char *from, uint32 from_length,
+ CHARSET_INFO *from_cs, uint *errors);
#ifdef HAVE_MLOCK
extern void *my_malloc_lock(size_t length,myf flags);
extern void my_free_lock(void *ptr);
@@ -815,7 +849,7 @@ extern void my_free_lock(void *ptr);
#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);
+ 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);
@@ -829,22 +863,6 @@ static inline char *safe_strdup_root(MEM_ROOT *root, const char *str)
}
extern char *strmake_root(MEM_ROOT *root,const char *str,size_t len);
extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
-extern int get_defaults_options(int argc, char **argv,
- char **defaults, char **extra_defaults,
- char **group_suffix);
-extern my_bool my_getopt_use_args_separator;
-extern my_bool my_getopt_is_args_separator(const char* arg);
-extern int my_load_defaults(const char *conf_file, const char **groups,
- int *argc, char ***argv, const char ***);
-extern int load_defaults(const char *conf_file, const char **groups,
- int *argc, char ***argv);
-extern int my_search_option_files(const char *conf_file, int *argc,
- char ***argv, uint *args_used,
- Process_option_func func, void *func_ctx,
- const char **default_directories);
-extern void free_defaults(char **argv);
-extern void my_print_default_files(const char *conf_file);
-extern void print_defaults(const char *conf_file, const char **groups);
extern my_bool my_compress(uchar *, size_t *, size_t *);
extern my_bool my_uncompress(uchar *, size_t , size_t *);
extern uchar *my_compress_alloc(const uchar *packet, size_t *len,
@@ -853,7 +871,7 @@ extern void *my_az_allocator(void *dummy, unsigned int items, unsigned int size)
extern void my_az_free(void *dummy, void *address);
extern int my_compress_buffer(uchar *dest, size_t *destLen,
const uchar *source, size_t sourceLen);
-extern int packfrm(uchar *, size_t, uchar **, size_t *);
+extern int packfrm(const uchar *, size_t, uchar **, size_t *);
extern int unpackfrm(uchar **, size_t *, const uchar *);
extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem,
@@ -870,12 +888,12 @@ extern uint my_set_max_open_files(uint files);
void my_free_open_file_info(void);
extern my_bool my_gethwaddr(uchar *to);
-extern int my_getncpus();
+extern int my_getncpus(void);
#define HRTIME_RESOLUTION 1000000ULL /* microseconds */
typedef struct {ulonglong val;} my_hrtime_t;
-void my_time_init();
-extern my_hrtime_t my_hrtime();
+void my_time_init(void);
+extern my_hrtime_t my_hrtime(void);
extern ulonglong my_interval_timer(void);
extern ulonglong my_getcputime(void);
@@ -886,6 +904,12 @@ extern ulonglong my_getcputime(void);
#define hrtime_sec_part(X) ((ulong)((X).val % HRTIME_RESOLUTION))
#define my_time(X) hrtime_to_time(my_hrtime())
+#if STACK_DIRECTION < 0
+#define available_stack_size(CUR,END) (long) ((char*)(CUR) - (char*)(END))
+#else
+#define available_stack_size(CUR,END) (long) ((char*)(END) - (char*)(CUR))
+#endif
+
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
@@ -934,26 +958,23 @@ int my_msync(int, void *, size_t, int);
void my_uuid_init(ulong seed1, ulong seed2);
void my_uuid(uchar *guid);
void my_uuid2str(const uchar *guid, char *s);
-void my_uuid_end();
-
-struct my_rnd_struct {
- unsigned long seed1,seed2,max_value;
- double max_value_dbl;
-};
-
-void my_rnd_init(struct my_rnd_struct *rand_st, ulong seed1, ulong seed2);
-double my_rnd(struct my_rnd_struct *rand_st);
+void my_uuid_end(void);
/* character sets */
+extern void my_charset_loader_init_mysys(MY_CHARSET_LOADER *loader);
extern uint get_charset_number(const char *cs_name, uint cs_flags);
extern uint get_collation_number(const char *name);
extern const char *get_charset_name(uint cs_number);
extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
+extern CHARSET_INFO *my_collation_get_by_name(MY_CHARSET_LOADER *loader,
+ const char *name, myf flags);
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
uint cs_flags, myf my_flags);
-
+extern CHARSET_INFO *my_charset_get_by_name(MY_CHARSET_LOADER *loader,
+ const char *name,
+ uint cs_flags, myf my_flags);
extern my_bool resolve_charset(const char *cs_name,
CHARSET_INFO *default_cs,
CHARSET_INFO **cs);
@@ -1000,11 +1021,11 @@ char* my_cgets(char *string, size_t clen, size_t* plen);
#ifdef HAVE_PSI_INTERFACE
extern MYSQL_PLUGIN_IMPORT struct PSI_bootstrap *PSI_hook;
+extern void set_psi_server(PSI *psi);
void my_init_mysys_psi_keys(void);
#endif
struct st_mysql_file;
extern struct st_mysql_file *mysql_stdin;
-
C_MODE_END
#endif /* _my_sys_h */
diff --git a/include/my_time.h b/include/my_time.h
index bcf1a8cb215..557dcdd5670 100644
--- a/include/my_time.h
+++ b/include/my_time.h
@@ -29,16 +29,6 @@ C_MODE_START
extern ulonglong log_10_int[20];
extern uchar days_in_month[];
-/*
- Portable time_t replacement.
- Should be signed and hold seconds for 1902 -- 2038-01-19 range
- i.e at least a 32bit variable
-
- Using the system built in time_t is not an option as
- we rely on the above requirements in the time functions
-*/
-typedef long my_time_t;
-
#define MY_TIME_T_MAX LONG_MAX
#define MY_TIME_T_MIN LONG_MIN
@@ -87,6 +77,9 @@ typedef long my_time_t;
#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 */
+#define SECONDS_IN_24H 86400L
+
/* Limits for the TIME data type */
#define TIME_MAX_HOUR 838
#define TIME_MAX_MINUTE 59
@@ -98,14 +91,27 @@ typedef long my_time_t;
#define TIME_MAX_VALUE_SECONDS (TIME_MAX_HOUR * 3600L + \
TIME_MAX_MINUTE * 60L + TIME_MAX_SECOND)
+/*
+ Structure to return status from
+ str_to_datetime(), str_to_time().
+*/
+typedef struct st_mysql_time_status
+{
+ int warnings;
+ uint precision;
+} MYSQL_TIME_STATUS;
+
+static inline void my_time_status_init(MYSQL_TIME_STATUS *status)
+{
+ status->warnings= status->precision= 0;
+}
+
my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
ulonglong flags, int *was_cut);
-enum enum_mysql_timestamp_type
-str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
- ulonglong flag, int *warning);
-enum enum_mysql_timestamp_type
-str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
- ulonglong flags, int *was_cut);
+my_bool str_to_time(const char *str, uint 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,
+ ulonglong flags, MYSQL_TIME_STATUS *status);
longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res,
ulonglong flags, int *was_cut);
@@ -127,10 +133,12 @@ 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(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);
+
long calc_daynr(uint year,uint month,uint day);
uint calc_days_in_year(uint year);
@@ -148,8 +156,8 @@ void my_init_time(void);
estimate.
RETURN VALUES
- FALSE The value seems sane
- TRUE The MYSQL_TIME value is definitely out of range
+ TRUE The value seems sane
+ FALSE The MYSQL_TIME value is definitely out of range
*/
static inline my_bool validate_timestamp_range(const MYSQL_TIME *t)
@@ -183,6 +191,8 @@ int my_date_to_str(const MYSQL_TIME *l_time, char *to);
int my_datetime_to_str(const MYSQL_TIME *l_time, char *to, uint digits);
int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, uint digits);
+int my_timeval_to_str(const struct timeval *tm, char *to, uint dec);
+
static inline longlong sec_part_shift(longlong second_part, uint digits)
{
return second_part / (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits];
@@ -191,11 +201,22 @@ static inline longlong sec_part_unshift(longlong second_part, uint digits)
{
return second_part * (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits];
}
-static inline ulong sec_part_truncate(ulong second_part, uint digits)
+
+/* Date/time rounding and truncation functions */
+static inline long my_time_fraction_remainder(long nr, uint decimals)
+{
+ DBUG_ASSERT(decimals <= TIME_SECOND_PART_DIGITS);
+ return nr % (long) log_10_int[TIME_SECOND_PART_DIGITS - decimals];
+}
+static inline void my_time_trunc(MYSQL_TIME *ltime, uint decimals)
{
- /* the cast here should be unnecessary! */
- return second_part - second_part % (ulong)log_10_int[TIME_SECOND_PART_DIGITS - digits];
+ ltime->second_part-= my_time_fraction_remainder(ltime->second_part, decimals);
}
+static inline void my_timeval_trunc(struct timeval *tv, uint decimals)
+{
+ tv->tv_usec-= my_time_fraction_remainder(tv->tv_usec, decimals);
+}
+
#define hrtime_to_my_time(X) ((my_time_t)hrtime_to_time(X))
diff --git a/include/my_tree.h b/include/my_tree.h
index 1069b232360..02cab02b52e 100644
--- a/include/my_tree.h
+++ b/include/my_tree.h
@@ -68,13 +68,15 @@ typedef struct st_tree {
MEM_ROOT mem_root;
my_bool with_delete;
tree_element_free free;
+ myf my_flags;
uint flag;
} TREE;
/* Functions on whole tree */
void init_tree(TREE *tree, size_t default_alloc_size, size_t memory_limit,
- int size, qsort_cmp2 compare, my_bool with_delete,
- tree_element_free free_element, void *custom_arg);
+ int size, qsort_cmp2 compare,
+ tree_element_free free_element, void *custom_arg,
+ myf my_flags);
void delete_tree(TREE*);
void reset_tree(TREE*);
diff --git a/include/my_user.h b/include/my_user.h
index 46eb11a500d..404996e996c 100644
--- a/include/my_user.h
+++ b/include/my_user.h
@@ -26,9 +26,9 @@
C_MODE_START
-void parse_user(const char *user_id_str, size_t user_id_len,
- char *user_name_str, size_t *user_name_len,
- char *host_name_str, size_t *host_name_len);
+int parse_user(const char *user_id_str, size_t user_id_len,
+ char *user_name_str, size_t *user_name_len,
+ char *host_name_str, size_t *host_name_len);
C_MODE_END
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index 8dde079b976..5d08a271d4a 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -49,9 +49,9 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
#endif /* HAVE_VALGRIND */
#ifndef DBUG_OFF
-#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED(A,B); memset(A,C,B); } while(0)
+#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)
#else
-#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED(A,B); } while(0)
+#define TRASH_FILL(A,B,C) do { const size_t trash_tmp __attribute__((unused))= (B); MEM_UNDEFINED(A,trash_tmp); } while (0)
#endif
#define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0)
#define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
diff --git a/include/my_xml.h b/include/my_xml.h
index aee301167ff..cd7665df9da 100644
--- a/include/my_xml.h
+++ b/include/my_xml.h
@@ -52,8 +52,15 @@ typedef struct xml_stack_st
int flags;
enum my_xml_node_type current_node_type;
char errstr[128];
- char attr[128];
- char *attrend;
+
+ struct {
+ char static_buffer[128];
+ char *buffer;
+ size_t buffer_size;
+ char *start;
+ char *end;
+ } attr;
+
const char *beg;
const char *cur;
const char *end;
diff --git a/include/myisam.h b/include/myisam.h
index 186b049b32e..f7a3ae8cc8a 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -1,5 +1,6 @@
/*
Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2013, Monty Program Ab.
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
@@ -63,40 +64,40 @@ extern "C" {
sets all high keys.
*/
#define MI_KEYMAP_BITS (8 * SIZEOF_LONG_LONG)
-#define MI_KEYMAP_HIGH_MASK (ULL(1) << (MI_KEYMAP_BITS - 1))
+#define MI_KEYMAP_HIGH_MASK (1ULL << (MI_KEYMAP_BITS - 1))
#define mi_get_mask_all_keys_active(_keys_) \
(((_keys_) < MI_KEYMAP_BITS) ? \
- ((ULL(1) << (_keys_)) - ULL(1)) : \
- (~ ULL(0)))
+ ((1ULL << (_keys_)) - 1ULL) : \
+ (~ 0ULL))
#if MI_MAX_KEY > MI_KEYMAP_BITS
#define mi_is_key_active(_keymap_,_keyno_) \
(((_keyno_) < MI_KEYMAP_BITS) ? \
- test((_keymap_) & (ULL(1) << (_keyno_))) : \
- test((_keymap_) & MI_KEYMAP_HIGH_MASK))
+ MY_TEST((_keymap_) & (1ULL << (_keyno_))) : \
+ MY_TEST((_keymap_) & MI_KEYMAP_HIGH_MASK))
#define mi_set_key_active(_keymap_,_keyno_) \
(_keymap_)|= (((_keyno_) < MI_KEYMAP_BITS) ? \
- (ULL(1) << (_keyno_)) : \
+ (1ULL << (_keyno_)) : \
MI_KEYMAP_HIGH_MASK)
#define mi_clear_key_active(_keymap_,_keyno_) \
(_keymap_)&= (((_keyno_) < MI_KEYMAP_BITS) ? \
- (~ (ULL(1) << (_keyno_))) : \
- (~ (ULL(0))) /*ignore*/ )
+ (~ (1ULL << (_keyno_))) : \
+ (~ (0ULL)) /*ignore*/ )
#else
#define mi_is_key_active(_keymap_,_keyno_) \
- test((_keymap_) & (ULL(1) << (_keyno_)))
+ MY_TEST((_keymap_) & (1ULL << (_keyno_)))
#define mi_set_key_active(_keymap_,_keyno_) \
- (_keymap_)|= (ULL(1) << (_keyno_))
+ (_keymap_)|= (1ULL << (_keyno_))
#define mi_clear_key_active(_keymap_,_keyno_) \
- (_keymap_)&= (~ (ULL(1) << (_keyno_)))
+ (_keymap_)&= (~ (1ULL << (_keyno_)))
#endif
#define mi_is_any_key_active(_keymap_) \
- test((_keymap_))
+ MY_TEST((_keymap_))
#define mi_is_all_keys_active(_keymap_,_keys_) \
((_keymap_) == mi_get_mask_all_keys_active(_keys_))
#define mi_set_all_keys_active(_keymap_,_keys_) \
@@ -361,8 +362,10 @@ typedef struct st_mi_sort_param
ulonglong notnull[HA_MAX_KEY_SEG+1];
my_off_t pos,max_pos,filepos,start_recpos;
- uint key, key_length,real_key_length,sortbuff_size;
- uint maxbuffers, keys, find_length, sort_keys_length;
+ uint key, key_length,real_key_length;
+ uint maxbuffers, find_length;
+ ulonglong sortbuff_size;
+ ha_rows keys;
my_bool fix_datafile, master;
my_bool calc_checksum; /* calculate table checksum */
@@ -371,10 +374,10 @@ typedef struct st_mi_sort_param
int (*key_write)(struct st_mi_sort_param *, const void *);
void (*lock_in_memory)(HA_CHECK *);
int (*write_keys)(struct st_mi_sort_param *, register uchar **,
- uint , struct st_buffpek *, IO_CACHE *);
- uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
+ ulonglong , struct st_buffpek *, IO_CACHE *);
+ my_off_t (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,uchar *,
- uint, uint);
+ uint, ulonglong);
} MI_SORT_PARAM;
/* functions in mi_check */
diff --git a/include/myisamchk.h b/include/myisamchk.h
index ded463f10ca..64724de1789 100644
--- a/include/myisamchk.h
+++ b/include/myisamchk.h
@@ -124,6 +124,7 @@ typedef struct st_handler_check_param
mysql_mutex_t print_msg_mutex;
my_bool need_print_msg_lock;
+ myf malloc_flags;
} HA_CHECK;
@@ -139,8 +140,8 @@ typedef struct st_buffpek {
my_off_t file_pos; /* Where we are in the sort file */
uchar *base, *key; /* Key pointers */
ha_rows count; /* Number of rows in table */
- ulong mem_count; /* numbers of keys in memory */
- ulong max_keys; /* Max keys in buffert */
+ ha_rows mem_count; /* Numbers of keys in memory */
+ ha_rows max_keys; /* Max keys in buffert */
} BUFFPEK;
#endif /* _myisamchk_h */
diff --git a/include/myisammrg.h b/include/myisammrg.h
index 84b2d637892..89293537989 100644
--- a/include/myisammrg.h
+++ b/include/myisammrg.h
@@ -31,7 +31,8 @@ extern "C" {
#include <queues.h>
-#define MYRG_NAME_EXT ".MRG"
+#define MYRG_NAME_EXT ".MRG"
+#define MYRG_NAME_TMPEXT ".MRG_TMP"
/* In which table to INSERT rows */
#define MERGE_INSERT_DISABLED 0
diff --git a/include/mysql.h b/include/mysql.h
index 2f205ec6463..f088ad668a1 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -44,7 +44,7 @@
extern "C" {
#endif
-#ifndef _global_h /* If not standard header */
+#ifndef MY_GLOBAL_INCLUDED /* If not standard header */
#ifndef MYSQL_ABI_CHECK
#include <sys/types.h>
#endif
@@ -67,7 +67,7 @@ typedef char my_bool;
typedef int my_socket;
#endif /* _WIN64 */
#endif /* my_socket_defined */
-#endif /* _global_h */
+#endif /* MY_GLOBAL_INCLUDED */
#include "mysql_version.h"
#include "mysql_com.h"
@@ -79,8 +79,8 @@ extern unsigned int mariadb_deinitialize_ssl;
extern unsigned int mysql_port;
extern char *mysql_unix_port;
-#define CLIENT_NET_READ_TIMEOUT 365*24*3600 /* Timeout on read */
-#define CLIENT_NET_WRITE_TIMEOUT 365*24*3600 /* Timeout on write */
+#define CLIENT_NET_READ_TIMEOUT (365*24*3600) /* Timeout on read */
+#define CLIENT_NET_WRITE_TIMEOUT (365*24*3600) /* Timeout on write */
#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
@@ -120,7 +120,7 @@ typedef struct st_mysql_field {
typedef char **MYSQL_ROW; /* return data as array of strings */
typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
-#ifndef _global_h
+#ifndef MY_GLOBAL_INCLUDED
#if defined(NO_CLIENT_LONG_LONG)
typedef unsigned long my_ulonglong;
#elif defined (__WIN__)
@@ -170,11 +170,20 @@ enum mysql_option
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
+ MYSQL_OPT_BIND,
+ MYSQL_OPT_SSL_KEY, MYSQL_OPT_SSL_CERT,
+ MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CAPATH, MYSQL_OPT_SSL_CIPHER,
+ MYSQL_OPT_SSL_CRL, MYSQL_OPT_SSL_CRLPATH,
+ MYSQL_OPT_CONNECT_ATTR_RESET, MYSQL_OPT_CONNECT_ATTR_ADD,
+ MYSQL_OPT_CONNECT_ATTR_DELETE,
+ MYSQL_SERVER_PUBLIC_KEY,
MYSQL_ENABLE_CLEARTEXT_PLUGIN,
+ MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,
/* MariaDB options */
MYSQL_PROGRESS_CALLBACK=5999,
- MYSQL_OPT_NONBLOCK=6000
+ MYSQL_OPT_NONBLOCK,
+ MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY
};
/**
@@ -199,7 +208,7 @@ struct st_mysql_options {
unsigned long max_allowed_packet;
my_bool use_ssl; /* if to use SSL or not */
my_bool compress,named_pipe;
- my_bool unused1;
+ my_bool use_thread_specific_memory;
my_bool unused2;
my_bool unused3;
my_bool unused4;
@@ -549,6 +558,8 @@ int STDCALL mysql_list_processes_cont(MYSQL_RES **ret, MYSQL *mysql,
int status);
int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
const void *arg);
+int STDCALL mysql_options4(MYSQL *mysql,enum mysql_option option,
+ const void *arg1, const void *arg2);
void STDCALL mysql_free_result(MYSQL_RES *result);
int STDCALL mysql_free_result_start(MYSQL_RES *result);
int STDCALL mysql_free_result_cont(MYSQL_RES *result, int status);
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index 4f7407095c9..a593f526c6e 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -26,8 +26,8 @@ typedef struct st_net {
unsigned char reading_or_writing;
char save_char;
char net_skip_rest_factor;
- my_bool unused1;
- my_bool compress;
+ my_bool thread_specific_malloc;
+ unsigned char compress;
my_bool unused3;
unsigned char *unused;
unsigned int last_errno;
@@ -47,6 +47,9 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
MYSQL_TYPE_BIT,
+ MYSQL_TYPE_TIMESTAMP2,
+ MYSQL_TYPE_DATETIME2,
+ MYSQL_TYPE_TIME2,
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248,
@@ -78,10 +81,10 @@ enum enum_mysql_set_option
MYSQL_OPTION_MULTI_STATEMENTS_ON,
MYSQL_OPTION_MULTI_STATEMENTS_OFF
};
-my_bool my_net_init(NET *net, Vio* vio);
+my_bool my_net_init(NET *net, Vio* vio, unsigned int my_flags);
void my_net_local_init(NET *net);
void net_end(NET *net);
- void net_clear(NET *net, my_bool clear_buffer);
+void net_clear(NET *net, my_bool clear_buffer);
my_bool net_realloc(NET *net, size_t length);
my_bool net_flush(NET *net);
my_bool my_net_write(NET *net,const unsigned char *packet, size_t len);
@@ -89,7 +92,7 @@ my_bool net_write_command(NET *net,unsigned char command,
const unsigned char *header, size_t head_len,
const unsigned char *packet, size_t len);
int net_real_write(NET *net,const unsigned char *packet, size_t len);
-unsigned long my_net_read(NET *net);
+unsigned long my_net_read_packet(NET *net, my_bool read_from_server);
struct sockaddr;
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
unsigned int timeout);
@@ -140,6 +143,7 @@ void get_tty_password_buff(const char *opt_message, char *to, size_t length);
const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
my_bool my_thread_init(void);
void my_thread_end(void);
+typedef long my_time_t;
enum enum_mysql_timestamp_type
{
MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
@@ -256,9 +260,18 @@ enum mysql_option
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
+ MYSQL_OPT_BIND,
+ MYSQL_OPT_SSL_KEY, MYSQL_OPT_SSL_CERT,
+ MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CAPATH, MYSQL_OPT_SSL_CIPHER,
+ MYSQL_OPT_SSL_CRL, MYSQL_OPT_SSL_CRLPATH,
+ MYSQL_OPT_CONNECT_ATTR_RESET, MYSQL_OPT_CONNECT_ATTR_ADD,
+ MYSQL_OPT_CONNECT_ATTR_DELETE,
+ MYSQL_SERVER_PUBLIC_KEY,
MYSQL_ENABLE_CLEARTEXT_PLUGIN,
+ MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,
MYSQL_PROGRESS_CALLBACK=5999,
- MYSQL_OPT_NONBLOCK=6000
+ MYSQL_OPT_NONBLOCK,
+ MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY
};
struct st_mysql_options_extention;
struct st_mysql_options {
@@ -277,7 +290,7 @@ struct st_mysql_options {
unsigned long max_allowed_packet;
my_bool use_ssl;
my_bool compress,named_pipe;
- my_bool unused1;
+ my_bool use_thread_specific_memory;
my_bool unused2;
my_bool unused3;
my_bool unused4;
@@ -533,6 +546,8 @@ int mysql_list_processes_cont(MYSQL_RES **ret, MYSQL *mysql,
int status);
int mysql_options(MYSQL *mysql,enum mysql_option option,
const void *arg);
+int mysql_options4(MYSQL *mysql,enum mysql_option option,
+ const void *arg1, const void *arg2);
void mysql_free_result(MYSQL_RES *result);
int mysql_free_result_start(MYSQL_RES *result);
int mysql_free_result_cont(MYSQL_RES *result, int status);
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 6b2dba46193..ceb6ac93ff5 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -45,6 +45,9 @@ class Item;
#define MYSQL_THD void*
#endif
+typedef char my_bool;
+typedef void * MYSQL_PLUGIN;
+
#include <mysql/services.h>
#define MYSQL_XIDDATASIZE 128
@@ -69,10 +72,10 @@ typedef struct st_mysql_xid MYSQL_XID;
*/
/* MySQL plugin interface version */
-#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0103
+#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0104
/* MariaDB plugin interface version */
-#define MARIA_PLUGIN_INTERFACE_VERSION 0x0104
+#define MARIA_PLUGIN_INTERFACE_VERSION 0x0108
/*
The allowable types of plugins
@@ -85,7 +88,8 @@ typedef struct st_mysql_xid MYSQL_XID;
#define MYSQL_AUDIT_PLUGIN 5 /* The Audit plugin type */
#define MYSQL_REPLICATION_PLUGIN 6 /* The replication plugin type */
#define MYSQL_AUTHENTICATION_PLUGIN 7 /* The authentication plugin type */
-#define MYSQL_MAX_PLUGIN_TYPE_NUM 8 /* The number of plugin types */
+#define MYSQL_VALIDATE_PASSWORD_PLUGIN 8 /* validate password plugin type */
+#define MYSQL_MAX_PLUGIN_TYPE_NUM 9 /* The number of plugin types */
/* We use the following strings to define licenses for plugins */
#define PLUGIN_LICENSE_PROPRIETARY 0
@@ -167,7 +171,7 @@ enum enum_mysql_show_type
SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG,
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
- SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG,
+ SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
};
@@ -569,7 +573,7 @@ struct handlerton;
/*
API for Replication plugin. (MYSQL_REPLICATION_PLUGIN)
*/
- #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0100
+ #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0200
/**
Replication plugin descriptor
@@ -617,11 +621,8 @@ int thd_sql_command(const MYSQL_THD thd);
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);
-char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
- unsigned int max_query_len);
-/* Increments the row counter, see THD::row_count */
-void thd_inc_row_count(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.
@@ -694,6 +695,41 @@ void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
*/
void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton,
const void *ha_data);
+
+
+/**
+ Signal that the first part of handler commit is finished, and that the
+ committed transaction is now visible and has fixed commit ordering with
+ respect to other transactions. The commit need _not_ be durable yet, and
+ typically will not be when this call makes sense.
+
+ This call is optional, if the storage engine does not call it the upper
+ layer will after the handler commit() method is done. However, the storage
+ engine may choose to call it itself to increase the possibility for group
+ commit.
+
+ In-order parallel replication uses this to apply different transaction in
+ parallel, but delay the commits of later transactions until earlier
+ transactions have committed first, thus achieving increased performance on
+ multi-core systems while still preserving full transaction consistency.
+
+ The storage engine can call this from within the commit() method, typically
+ after the commit record has been written to the transaction log, but before
+ the log has been fsync()'ed. This will allow the next replicated transaction
+ to proceed to commit before the first one has done fsync() or similar. Thus,
+ it becomes possible for multiple sequential replicated transactions to share
+ a single fsync() inside the engine in group commit.
+
+ Note that this method should _not_ be called from within the commit_ordered()
+ method, or any other place in the storage engine. When commit_ordered() is
+ used (typically when binlog is enabled), the transaction coordinator takes
+ care of this and makes group commit in the storage engine possible without
+ any other action needed on the part of the storage engine. This function
+ thd_wakeup_subsequent_commits() is only needed when no transaction
+ coordinator is used, meaning a single storage engine and no binary log.
+*/
+void thd_wakeup_subsequent_commits(MYSQL_THD thd, int wakeup_error);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index 74903fd74e3..2f8edfe192f 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -1,3 +1,5 @@
+typedef char my_bool;
+typedef void * MYSQL_PLUGIN;
extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
@@ -38,7 +40,8 @@ typedef enum _thd_wait_type_e {
THD_WAIT_BINLOG= 8,
THD_WAIT_GROUP_COMMIT= 9,
THD_WAIT_SYNC= 10,
- THD_WAIT_LAST= 11
+ THD_WAIT_NET= 11,
+ THD_WAIT_LAST= 12
} thd_wait_type;
extern struct thd_wait_service_st {
void (*thd_wait_begin_func)(void*, int);
@@ -46,13 +49,6 @@ extern struct thd_wait_service_st {
} *thd_wait_service;
void thd_wait_begin(void* thd, int wait_type);
void thd_wait_end(void* thd);
-struct scheduler_functions;
-extern struct my_thread_scheduler_service {
- int (*set)(struct scheduler_functions *scheduler);
- int (*reset)();
-} *my_thread_scheduler_service;
-int my_thread_scheduler_set(struct scheduler_functions *scheduler);
-int my_thread_scheduler_reset();
extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
void (*thd_progress_report_func)(void* thd,
@@ -83,6 +79,31 @@ extern struct kill_statement_service_st {
enum thd_kill_levels (*thd_kill_level_func)(const void*);
} *thd_kill_statement_service;
enum thd_kill_levels thd_kill_level(const void*);
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
+extern struct my_sha1_service_st {
+ void (*my_sha1_type)(unsigned char*, const char*, size_t);
+ void (*my_sha1_multi_type)(unsigned char*, ...);
+} *my_sha1_service;
+void my_sha1(unsigned char*, const char*, size_t);
+void my_sha1_multi(unsigned char*, ...);
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
@@ -104,6 +125,29 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
+extern struct thd_autoinc_service_st {
+ void (*thd_get_autoinc_func)(const void* thd,
+ unsigned long* off, unsigned long* inc);
+} *thd_autoinc_service;
+void thd_get_autoinc(const void* thd,
+ unsigned long* off, unsigned long* inc);
+extern struct thd_error_context_service_st {
+ const char *(*thd_get_error_message_func)(const void* thd);
+ unsigned int (*thd_get_error_number_func)(const void* thd);
+ unsigned long (*thd_get_error_row_func)(const void* thd);
+ void (*thd_inc_error_row_func)(void* thd);
+ char *(*thd_get_error_context_description_func)(void* thd,
+ char *buffer,
+ unsigned int length,
+ unsigned int max_query_length);
+} *thd_error_context_service;
+const char *thd_get_error_message(const void* thd);
+unsigned int thd_get_error_number(const void* thd);
+unsigned long thd_get_error_row(const void* thd);
+void thd_inc_error_row(void* thd);
+char *thd_get_error_context_description(void* thd,
+ char *buffer, unsigned int length,
+ unsigned int max_query_length);
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -116,7 +160,7 @@ enum enum_mysql_show_type
SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG,
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
- SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG,
+ SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
};
struct st_mysql_show_var {
@@ -242,9 +286,8 @@ int thd_sql_command(const void* thd);
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);
-char *thd_security_context(void* thd, char *buffer, unsigned int length,
- unsigned int max_query_len);
-void thd_inc_row_count(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);
@@ -254,6 +297,7 @@ void mysql_query_cache_invalidate4(void* thd,
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
void thd_set_ha_data(void* thd, const struct handlerton *hton,
const void *ha_data);
+void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
struct mysql_event_general
{
unsigned int event_subclass;
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index 84b2434a125..d052c550896 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -1,3 +1,5 @@
+typedef char my_bool;
+typedef void * MYSQL_PLUGIN;
extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
@@ -38,7 +40,8 @@ typedef enum _thd_wait_type_e {
THD_WAIT_BINLOG= 8,
THD_WAIT_GROUP_COMMIT= 9,
THD_WAIT_SYNC= 10,
- THD_WAIT_LAST= 11
+ THD_WAIT_NET= 11,
+ THD_WAIT_LAST= 12
} thd_wait_type;
extern struct thd_wait_service_st {
void (*thd_wait_begin_func)(void*, int);
@@ -46,13 +49,6 @@ extern struct thd_wait_service_st {
} *thd_wait_service;
void thd_wait_begin(void* thd, int wait_type);
void thd_wait_end(void* thd);
-struct scheduler_functions;
-extern struct my_thread_scheduler_service {
- int (*set)(struct scheduler_functions *scheduler);
- int (*reset)();
-} *my_thread_scheduler_service;
-int my_thread_scheduler_set(struct scheduler_functions *scheduler);
-int my_thread_scheduler_reset();
extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
void (*thd_progress_report_func)(void* thd,
@@ -83,6 +79,31 @@ extern struct kill_statement_service_st {
enum thd_kill_levels (*thd_kill_level_func)(const void*);
} *thd_kill_statement_service;
enum thd_kill_levels thd_kill_level(const void*);
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
+extern struct my_sha1_service_st {
+ void (*my_sha1_type)(unsigned char*, const char*, size_t);
+ void (*my_sha1_multi_type)(unsigned char*, ...);
+} *my_sha1_service;
+void my_sha1(unsigned char*, const char*, size_t);
+void my_sha1_multi(unsigned char*, ...);
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
@@ -104,6 +125,29 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
+extern struct thd_autoinc_service_st {
+ void (*thd_get_autoinc_func)(const void* thd,
+ unsigned long* off, unsigned long* inc);
+} *thd_autoinc_service;
+void thd_get_autoinc(const void* thd,
+ unsigned long* off, unsigned long* inc);
+extern struct thd_error_context_service_st {
+ const char *(*thd_get_error_message_func)(const void* thd);
+ unsigned int (*thd_get_error_number_func)(const void* thd);
+ unsigned long (*thd_get_error_row_func)(const void* thd);
+ void (*thd_inc_error_row_func)(void* thd);
+ char *(*thd_get_error_context_description_func)(void* thd,
+ char *buffer,
+ unsigned int length,
+ unsigned int max_query_length);
+} *thd_error_context_service;
+const char *thd_get_error_message(const void* thd);
+unsigned int thd_get_error_number(const void* thd);
+unsigned long thd_get_error_row(const void* thd);
+void thd_inc_error_row(void* thd);
+char *thd_get_error_context_description(void* thd,
+ char *buffer, unsigned int length,
+ unsigned int max_query_length);
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -116,7 +160,7 @@ enum enum_mysql_show_type
SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG,
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
- SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG,
+ SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
};
struct st_mysql_show_var {
@@ -242,9 +286,8 @@ int thd_sql_command(const void* thd);
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);
-char *thd_security_context(void* thd, char *buffer, unsigned int length,
- unsigned int max_query_len);
-void thd_inc_row_count(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);
@@ -254,6 +297,7 @@ void mysql_query_cache_invalidate4(void* thd,
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
void thd_set_ha_data(void* thd, const struct handlerton *hton,
const void *ha_data);
+void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
typedef struct st_plugin_vio_info
{
enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
diff --git a/include/mysql/plugin_auth_common.h b/include/mysql/plugin_auth_common.h
index c0b61730d0d..9d7dd2a08bf 100644
--- a/include/mysql/plugin_auth_common.h
+++ b/include/mysql/plugin_auth_common.h
@@ -34,6 +34,27 @@
return values of the plugin authenticate_user() method.
*/
+ /**
+ Authentication failed, plugin internal error.
+ An error occurred in the authentication plugin itself.
+ These errors are reported in table performance_schema.host_cache,
+ column COUNT_AUTH_PLUGIN_ERRORS.
+*/
+#define CR_AUTH_PLUGIN_ERROR 3
+/**
+ Authentication failed, client server handshake.
+ An error occurred during the client server handshake.
+ These errors are reported in table performance_schema.host_cache,
+ column COUNT_HANDSHAKE_ERRORS.
+*/
+#define CR_AUTH_HANDSHAKE 2
+/**
+ Authentication failed, user credentials.
+ For example, wrong passwords.
+ These errors are reported in table performance_schema.host_cache,
+ column COUNT_AUTHENTICATION_ERRORS.
+*/
+#define CR_AUTH_USER_CREDENTIALS 1
/**
Authentication failed. Additionally, all other CR_xxx values
(libmysql error code) can be used too.
diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp
index 8cb6348b24d..45eb06974f4 100644
--- a/include/mysql/plugin_ftparser.h.pp
+++ b/include/mysql/plugin_ftparser.h.pp
@@ -1,3 +1,5 @@
+typedef char my_bool;
+typedef void * MYSQL_PLUGIN;
extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
@@ -38,7 +40,8 @@ typedef enum _thd_wait_type_e {
THD_WAIT_BINLOG= 8,
THD_WAIT_GROUP_COMMIT= 9,
THD_WAIT_SYNC= 10,
- THD_WAIT_LAST= 11
+ THD_WAIT_NET= 11,
+ THD_WAIT_LAST= 12
} thd_wait_type;
extern struct thd_wait_service_st {
void (*thd_wait_begin_func)(void*, int);
@@ -46,13 +49,6 @@ extern struct thd_wait_service_st {
} *thd_wait_service;
void thd_wait_begin(void* thd, int wait_type);
void thd_wait_end(void* thd);
-struct scheduler_functions;
-extern struct my_thread_scheduler_service {
- int (*set)(struct scheduler_functions *scheduler);
- int (*reset)();
-} *my_thread_scheduler_service;
-int my_thread_scheduler_set(struct scheduler_functions *scheduler);
-int my_thread_scheduler_reset();
extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
void (*thd_progress_report_func)(void* thd,
@@ -83,6 +79,31 @@ extern struct kill_statement_service_st {
enum thd_kill_levels (*thd_kill_level_func)(const void*);
} *thd_kill_statement_service;
enum thd_kill_levels thd_kill_level(const void*);
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
+extern struct my_sha1_service_st {
+ void (*my_sha1_type)(unsigned char*, const char*, size_t);
+ void (*my_sha1_multi_type)(unsigned char*, ...);
+} *my_sha1_service;
+void my_sha1(unsigned char*, const char*, size_t);
+void my_sha1_multi(unsigned char*, ...);
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
@@ -104,6 +125,29 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
+extern struct thd_autoinc_service_st {
+ void (*thd_get_autoinc_func)(const void* thd,
+ unsigned long* off, unsigned long* inc);
+} *thd_autoinc_service;
+void thd_get_autoinc(const void* thd,
+ unsigned long* off, unsigned long* inc);
+extern struct thd_error_context_service_st {
+ const char *(*thd_get_error_message_func)(const void* thd);
+ unsigned int (*thd_get_error_number_func)(const void* thd);
+ unsigned long (*thd_get_error_row_func)(const void* thd);
+ void (*thd_inc_error_row_func)(void* thd);
+ char *(*thd_get_error_context_description_func)(void* thd,
+ char *buffer,
+ unsigned int length,
+ unsigned int max_query_length);
+} *thd_error_context_service;
+const char *thd_get_error_message(const void* thd);
+unsigned int thd_get_error_number(const void* thd);
+unsigned long thd_get_error_row(const void* thd);
+void thd_inc_error_row(void* thd);
+char *thd_get_error_context_description(void* thd,
+ char *buffer, unsigned int length,
+ unsigned int max_query_length);
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -116,7 +160,7 @@ enum enum_mysql_show_type
SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG,
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
- SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG,
+ SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
SHOW_always_last
};
struct st_mysql_show_var {
@@ -196,9 +240,8 @@ int thd_sql_command(const void* thd);
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);
-char *thd_security_context(void* thd, char *buffer, unsigned int length,
- unsigned int max_query_len);
-void thd_inc_row_count(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);
@@ -208,6 +251,7 @@ void mysql_query_cache_invalidate4(void* thd,
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
void thd_set_ha_data(void* thd, const struct handlerton *hton,
const void *ha_data);
+void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
enum enum_ftparser_mode
{
MYSQL_FTPARSER_SIMPLE_MODE= 0,
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h
index aa3ed7e901d..be9d7116b9b 100644
--- a/include/mysql/psi/mysql_file.h
+++ b/include/mysql/psi/mysql_file.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2012, 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
@@ -50,11 +50,18 @@
*/
/**
+ @def mysql_file_register(P1, P2, P3)
+ File registration.
+*/
+#define mysql_file_register(P1, P2, P3) \
+ inline_mysql_file_register(P1, P2, P3)
+
+/**
@def mysql_file_fgets(P1, P2, F)
Instrumented fgets.
@c mysql_file_fgets is a replacement for @c fgets.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fgets(P1, P2, F) \
inline_mysql_file_fgets(__FILE__, __LINE__, P1, P2, F)
#else
@@ -67,7 +74,7 @@
Instrumented fgetc.
@c mysql_file_fgetc is a replacement for @c fgetc.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fgetc(F) inline_mysql_file_fgetc(__FILE__, __LINE__, F)
#else
#define mysql_file_fgetc(F) inline_mysql_file_fgetc(F)
@@ -78,7 +85,7 @@
Instrumented fputs.
@c mysql_file_fputs is a replacement for @c fputs.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fputs(P1, F) \
inline_mysql_file_fputs(__FILE__, __LINE__, P1, F)
#else
@@ -91,7 +98,7 @@
Instrumented fputc.
@c mysql_file_fputc is a replacement for @c fputc.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fputc(P1, F) \
inline_mysql_file_fputc(__FILE__, __LINE__, P1, F)
#else
@@ -111,7 +118,7 @@
Instrumented vfprintf.
@c mysql_file_vfprintf is a replacement for @c vfprintf.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_vfprintf(F, P1, P2) \
inline_mysql_file_vfprintf(__FILE__, __LINE__, F, P1, P2)
#else
@@ -124,7 +131,7 @@
Instrumented fflush.
@c mysql_file_fflush is a replacement for @c fflush.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fflush(F) \
inline_mysql_file_fflush(__FILE__, __LINE__, F)
#else
@@ -144,7 +151,7 @@
Instrumented fstat.
@c mysql_file_fstat is a replacement for @c my_fstat.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fstat(FN, S, FL) \
inline_mysql_file_fstat(__FILE__, __LINE__, FN, S, FL)
#else
@@ -157,7 +164,7 @@
Instrumented stat.
@c mysql_file_stat is a replacement for @c my_stat.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_stat(K, FN, S, FL) \
inline_mysql_file_stat(K, __FILE__, __LINE__, FN, S, FL)
#else
@@ -170,7 +177,7 @@
Instrumented chsize.
@c mysql_file_chsize is a replacement for @c my_chsize.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_chsize(F, P1, P2, P3) \
inline_mysql_file_chsize(__FILE__, __LINE__, F, P1, P2, P3)
#else
@@ -183,7 +190,7 @@
Instrumented fopen.
@c mysql_file_fopen is a replacement for @c my_fopen.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fopen(K, N, F1, F2) \
inline_mysql_file_fopen(K, __FILE__, __LINE__, N, F1, F2)
#else
@@ -203,7 +210,7 @@
@code DBUG_ASSERT(file != NULL) @endcode,
since doing so could introduce regressions.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fclose(FD, FL) \
inline_mysql_file_fclose(__FILE__, __LINE__, FD, FL)
#else
@@ -216,7 +223,7 @@
Instrumented fread.
@c mysql_file_fread is a replacement for @c my_fread.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fread(FD, P1, P2, P3) \
inline_mysql_file_fread(__FILE__, __LINE__, FD, P1, P2, P3)
#else
@@ -229,7 +236,7 @@
Instrumented fwrite.
@c mysql_file_fwrite is a replacement for @c my_fwrite.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fwrite(FD, P1, P2, P3) \
inline_mysql_file_fwrite(__FILE__, __LINE__, FD, P1, P2, P3)
#else
@@ -242,7 +249,7 @@
Instrumented fseek.
@c mysql_file_fseek is a replacement for @c my_fseek.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_fseek(FD, P, W, F) \
inline_mysql_file_fseek(__FILE__, __LINE__, FD, P, W, F)
#else
@@ -255,7 +262,7 @@
Instrumented ftell.
@c mysql_file_ftell is a replacement for @c my_ftell.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_ftell(FD, F) \
inline_mysql_file_ftell(__FILE__, __LINE__, FD, F)
#else
@@ -268,7 +275,7 @@
Instrumented create.
@c mysql_file_create is a replacement for @c my_create.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_create(K, N, F1, F2, F3) \
inline_mysql_file_create(K, __FILE__, __LINE__, N, F1, F2, F3)
#else
@@ -281,7 +288,7 @@
Instrumented create_temp_file.
@c mysql_file_create_temp is a replacement for @c create_temp_file.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_create_temp(K, T, D, P, M, F) \
inline_mysql_file_create_temp(K, T, D, P, M, F)
#else
@@ -294,7 +301,7 @@
Instrumented open.
@c mysql_file_open is a replacement for @c my_open.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_open(K, N, F1, F2) \
inline_mysql_file_open(K, __FILE__, __LINE__, N, F1, F2)
#else
@@ -307,7 +314,7 @@
Instrumented close.
@c mysql_file_close is a replacement for @c my_close.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_close(FD, F) \
inline_mysql_file_close(__FILE__, __LINE__, FD, F)
#else
@@ -320,7 +327,7 @@
Instrumented read.
@c mysql_read is a replacement for @c my_read.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_read(FD, B, S, F) \
inline_mysql_file_read(__FILE__, __LINE__, FD, B, S, F)
#else
@@ -333,7 +340,7 @@
Instrumented write.
@c mysql_file_write is a replacement for @c my_write.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_write(FD, B, S, F) \
inline_mysql_file_write(__FILE__, __LINE__, FD, B, S, F)
#else
@@ -346,7 +353,7 @@
Instrumented pread.
@c mysql_pread is a replacement for @c my_pread.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_pread(FD, B, S, O, F) \
inline_mysql_file_pread(__FILE__, __LINE__, FD, B, S, O, F)
#else
@@ -359,7 +366,7 @@
Instrumented pwrite.
@c mysql_file_pwrite is a replacement for @c my_pwrite.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_pwrite(FD, B, S, O, F) \
inline_mysql_file_pwrite(__FILE__, __LINE__, FD, B, S, O, F)
#else
@@ -372,7 +379,7 @@
Instrumented seek.
@c mysql_file_seek is a replacement for @c my_seek.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_seek(FD, P, W, F) \
inline_mysql_file_seek(__FILE__, __LINE__, FD, P, W, F)
#else
@@ -385,7 +392,7 @@
Instrumented tell.
@c mysql_file_tell is a replacement for @c my_tell.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_tell(FD, F) \
inline_mysql_file_tell(__FILE__, __LINE__, FD, F)
#else
@@ -398,7 +405,7 @@
Instrumented delete.
@c mysql_file_delete is a replacement for @c my_delete.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_delete(K, P1, P2) \
inline_mysql_file_delete(K, __FILE__, __LINE__, P1, P2)
#else
@@ -411,7 +418,7 @@
Instrumented rename.
@c mysql_file_rename is a replacement for @c my_rename.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_rename(K, P1, P2, P3) \
inline_mysql_file_rename(K, __FILE__, __LINE__, P1, P2, P3)
#else
@@ -425,7 +432,7 @@
@c mysql_file_create_with_symlink is a replacement
for @c my_create_with_symlink.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_create_with_symlink(K, P1, P2, P3, P4, P5) \
inline_mysql_file_create_with_symlink(K, __FILE__, __LINE__, \
P1, P2, P3, P4, P5)
@@ -440,7 +447,7 @@
@c mysql_file_delete_with_symlink is a replacement
for @c my_handler_delete_with_symlink.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_delete_with_symlink(K, P1, P2, P3) \
inline_mysql_file_delete_with_symlink(K, __FILE__, __LINE__, P1, P2, P3)
#else
@@ -454,7 +461,7 @@
@c mysql_file_rename_with_symlink is a replacement
for @c my_rename_with_symlink.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_rename_with_symlink(K, P1, P2, P3) \
inline_mysql_file_rename_with_symlink(K, __FILE__, __LINE__, P1, P2, P3)
#else
@@ -467,7 +474,7 @@
Instrumented file sync.
@c mysql_file_sync is a replacement for @c my_sync.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_sync(P1, P2) \
inline_mysql_file_sync(__FILE__, __LINE__, P1, P2)
#else
@@ -498,115 +505,126 @@ struct st_mysql_file
*/
typedef struct st_mysql_file MYSQL_FILE;
+static inline void inline_mysql_file_register(
+#ifdef HAVE_PSI_FILE_INTERFACE
+ const char *category,
+ PSI_file_info *info,
+ int count
+#else
+ const char *category __attribute__ ((unused)),
+ void *info __attribute__ ((unused)),
+ int count __attribute__ ((unused))
+#endif
+)
+{
+#ifdef HAVE_PSI_FILE_INTERFACE
+ PSI_FILE_CALL(register_file)(category, info, count);
+#endif
+}
+
static inline char *
inline_mysql_file_fgets(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
char *str, int size, MYSQL_FILE *file)
{
char *result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_READ);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_READ);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) size, src_file, src_line);
+ 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
+
result= fgets(str, size, file->m_file);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, result ? strlen(result) : 0);
-#endif
return result;
}
static inline int
inline_mysql_file_fgetc(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
MYSQL_FILE *file)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_READ);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_READ);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 1, src_file, src_line);
+ 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
+
result= fgetc(file->m_file);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 1);
-#endif
return result;
}
static inline int
inline_mysql_file_fputs(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
const char *str, MYSQL_FILE *file)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- size_t bytes= 0;
- if (likely(PSI_server && file->m_psi))
+ size_t bytes;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_WRITE);
- if (likely(locker != NULL))
- {
- bytes= str ? strlen(str) : 0;
- PSI_server->start_file_wait(locker, bytes, src_file, src_line);
- }
+ 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
+
result= fputs(str, file->m_file);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, bytes);
-#endif
return result;
}
static inline int
inline_mysql_file_fputc(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
char c, MYSQL_FILE *file)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_WRITE);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 1, src_file, src_line);
+ 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
+
result= fputc(c, file->m_file);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 1);
-#endif
return result;
}
@@ -618,78 +636,77 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...)
*/
int result;
va_list args;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_WRITE);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, __FILE__, __LINE__);
+ 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
+
va_start(args, format);
result= vfprintf(file->m_file, format, args);
va_end(args);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) result);
-#endif
return result;
}
static inline int
inline_mysql_file_vfprintf(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
MYSQL_FILE *file, const char *format, va_list args)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_WRITE);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_WRITE);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= vfprintf(file->m_file, format, args);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) result);
-#endif
return result;
}
static inline int
inline_mysql_file_fflush(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
MYSQL_FILE *file)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_FLUSH);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_FLUSH);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= fflush(file->m_file);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
@@ -701,90 +718,86 @@ static inline int inline_mysql_file_feof(MYSQL_FILE *file)
static inline int
inline_mysql_file_fstat(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
int filenr, MY_STAT *stat_area, myf flags)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, filenr, PSI_FILE_FSTAT);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_descriptor_locker(&state, filenr,
- PSI_FILE_FSTAT);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_fstat(filenr, stat_area, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline MY_STAT *
inline_mysql_file_stat(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *path, MY_STAT *stat_area, myf flags)
{
MY_STAT *result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_STAT, path, &locker);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_name_locker(&state,
- key, PSI_FILE_STAT,
- path, &locker);
- if (likely(locker != NULL))
- PSI_server->start_file_open_wait(locker, src_file, src_line);
+ 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
+
result= my_stat(path, stat_area, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline int
inline_mysql_file_chsize(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
File file, my_off_t newlength, int filler, myf flags)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, file, PSI_FILE_CHSIZE);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_descriptor_locker(&state, file,
- PSI_FILE_CHSIZE);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) newlength, src_file,
- src_line);
+ 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
+
result= my_chsize(file, newlength, filler, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) newlength);
-#endif
return result;
}
static inline MYSQL_FILE*
inline_mysql_file_fopen(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *filename, int flags, myf myFlags)
@@ -793,30 +806,32 @@ inline_mysql_file_fopen(
that= (MYSQL_FILE*) my_malloc(sizeof(MYSQL_FILE), MYF(MY_WME));
if (likely(that != NULL))
{
- that->m_psi= 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))
{
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
- PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
- {
- locker= PSI_server->get_thread_file_name_locker
- (&state, key, PSI_FILE_STREAM_OPEN, filename, that);
- if (likely(locker != NULL))
- that->m_psi= PSI_server->start_file_open_wait(locker, src_file,
- src_line);
- }
-#endif
+ PSI_FILE_CALL(start_file_open_wait)
+ (locker, src_file, src_line);
that->m_file= my_fopen(filename, flags, myFlags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_open_wait(locker);
-#endif
+ 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;
+ }
+#endif
+
+ that->m_psi= NULL;
+ that->m_file= my_fopen(filename, flags, myFlags);
+ if (unlikely(that->m_file == NULL))
+ {
+ my_free(that);
+ return NULL;
}
}
return that;
@@ -824,7 +839,7 @@ inline_mysql_file_fopen(
static inline int
inline_mysql_file_fclose(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
MYSQL_FILE *file, myf flags)
@@ -832,23 +847,22 @@ inline_mysql_file_fclose(
int result= 0;
if (likely(file != NULL))
{
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- DBUG_ASSERT(file != NULL);
- if (likely(PSI_server && file->m_psi))
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_STREAM_CLOSE);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_STREAM_CLOSE);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_fclose(file->m_file, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
my_free(file);
}
return result;
@@ -856,156 +870,147 @@ inline_mysql_file_fclose(
static inline size_t
inline_mysql_file_fread(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
MYSQL_FILE *file, uchar *buffer, size_t count, myf flags)
{
- size_t result= 0;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+ size_t result;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
- {
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_READ);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, count, src_file, src_line);
- }
-#endif
- result= my_fread(file->m_file, buffer, count, flags);
-#ifdef HAVE_PSI_INTERFACE
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_READ);
if (likely(locker != NULL))
{
- size_t bytes_read;
+ 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_server->end_file_wait(locker, bytes_read);
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
}
#endif
+
+ result= my_fread(file->m_file, buffer, count, flags);
return result;
}
static inline size_t
inline_mysql_file_fwrite(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
MYSQL_FILE *file, const uchar *buffer, size_t count, myf flags)
{
- size_t result= 0;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+ size_t result;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
- {
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_WRITE);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, count, src_file, src_line);
- }
-#endif
- result= my_fwrite(file->m_file, buffer, count, flags);
-#ifdef HAVE_PSI_INTERFACE
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_WRITE);
if (likely(locker != NULL))
{
- size_t bytes_written;
+ 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_server->end_file_wait(locker, bytes_written);
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
}
#endif
+
+ result= my_fwrite(file->m_file, buffer, count, flags);
return result;
}
static inline my_off_t
inline_mysql_file_fseek(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
MYSQL_FILE *file, my_off_t pos, int whence, myf flags)
{
my_off_t result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_SEEK);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_SEEK);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_fseek(file->m_file, pos, whence, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline my_off_t
inline_mysql_file_ftell(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
MYSQL_FILE *file, myf flags)
{
my_off_t result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server && file->m_psi))
+ locker= PSI_FILE_CALL(get_thread_file_stream_locker)
+ (&state, file->m_psi, PSI_FILE_TELL);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_stream_locker(&state, file->m_psi,
- PSI_FILE_TELL);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_ftell(file->m_file, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline File
inline_mysql_file_create(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *filename, int create_flags, int access_flags, myf myFlags)
{
File file;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_CREATE, filename, &locker);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_CREATE,
- filename, &locker);
- if (likely(locker != NULL))
- PSI_server->start_file_open_wait(locker, src_file, src_line);
+ 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
+
file= my_create(filename, create_flags, access_flags, myFlags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_open_wait_and_bind_to_descriptor(locker, file);
-#endif
return file;
}
static inline File
inline_mysql_file_create_temp(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key,
#endif
char *to, const char *dir, const char *pfx, int mode, myf myFlags)
@@ -1017,424 +1022,404 @@ inline_mysql_file_create_temp(
before the create_temp_file call.
*/
file= create_temp_file(to, dir, pfx, mode, myFlags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server != NULL))
- PSI_server->create_file(key, to, file);
+#ifdef HAVE_PSI_FILE_INTERFACE
+ PSI_FILE_CALL(create_file)(key, to, file);
#endif
return file;
}
static inline File
inline_mysql_file_open(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *filename, int flags, myf myFlags)
{
File file;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_OPEN, filename, &locker);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_OPEN,
- filename, &locker);
- if (likely(locker != NULL))
- PSI_server->start_file_open_wait(locker, src_file, src_line);
+ 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
+
file= my_open(filename, flags, myFlags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_open_wait_and_bind_to_descriptor(locker, file);
-#endif
return file;
}
static inline int
inline_mysql_file_close(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
File file, myf flags)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, file, PSI_FILE_CLOSE);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_descriptor_locker(&state, file,
- PSI_FILE_CLOSE);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_close(file, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline size_t
inline_mysql_file_read(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
File file, uchar *buffer, size_t count, myf flags)
{
- size_t result= 0;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+ size_t result;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
- {
- locker= PSI_server->get_thread_file_descriptor_locker(&state, file,
- PSI_FILE_READ);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, count, src_file, src_line);
- }
-#endif
- result= my_read(file, buffer, count, flags);
-#ifdef HAVE_PSI_INTERFACE
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, file, PSI_FILE_READ);
if (likely(locker != NULL))
{
- size_t bytes_read;
+ 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_server->end_file_wait(locker, bytes_read);
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
}
#endif
+
+ result= my_read(file, buffer, count, flags);
return result;
}
static inline size_t
inline_mysql_file_write(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
File file, const uchar *buffer, size_t count, myf flags)
{
size_t result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
- {
- locker= PSI_server->get_thread_file_descriptor_locker(&state, file,
- PSI_FILE_WRITE);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, count, src_file, src_line);
- }
-#endif
- result= my_write(file, buffer, count, flags);
-#ifdef HAVE_PSI_INTERFACE
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, file, PSI_FILE_WRITE);
if (likely(locker != NULL))
{
- size_t bytes_written;
+ 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_server->end_file_wait(locker, bytes_written);
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
}
#endif
+
+ result= my_write(file, buffer, count, flags);
return result;
}
static inline size_t
inline_mysql_file_pread(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
File file, uchar *buffer, size_t count, my_off_t offset, myf flags)
{
size_t result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
- {
- locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_READ);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, count, src_file, src_line);
- }
-#endif
- result= my_pread(file, buffer, count, offset, flags);
-#ifdef HAVE_PSI_INTERFACE
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, file, PSI_FILE_READ);
if (likely(locker != NULL))
{
- size_t bytes_read;
+ 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_server->end_file_wait(locker, bytes_read);
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
}
#endif
+
+ result= my_pread(file, buffer, count, offset, flags);
return result;
}
static inline size_t
inline_mysql_file_pwrite(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
File file, const uchar *buffer, size_t count, my_off_t offset, myf flags)
{
size_t result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
- {
- locker= PSI_server->get_thread_file_descriptor_locker(&state, file,
- PSI_FILE_WRITE);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, count, src_file, src_line);
- }
-#endif
- result= my_pwrite(file, buffer, count, offset, flags);
-#ifdef HAVE_PSI_INTERFACE
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, file, PSI_FILE_WRITE);
if (likely(locker != NULL))
{
- size_t bytes_written;
+ 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_server->end_file_wait(locker, bytes_written);
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
}
#endif
+
+ result= my_pwrite(file, buffer, count, offset, flags);
return result;
}
static inline my_off_t
inline_mysql_file_seek(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
File file, my_off_t pos, int whence, myf flags)
{
my_off_t result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, file, PSI_FILE_SEEK);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_SEEK);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_seek(file, pos, whence, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline my_off_t
inline_mysql_file_tell(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
File file, myf flags)
{
my_off_t result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, file, PSI_FILE_TELL);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_descriptor_locker(&state, file, PSI_FILE_TELL);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_tell(file, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline int
inline_mysql_file_delete(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *name, myf flags)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_DELETE, name, &locker);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_DELETE,
- name, &locker);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_delete(name, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline int
inline_mysql_file_rename(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *from, const char *to, myf flags)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_RENAME, to, &locker);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_RENAME,
- to, &locker);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_rename(from, to, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline File
inline_mysql_file_create_with_symlink(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *linkname, const char *filename, int create_flags,
int access_flags, myf flags)
{
File file;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_CREATE, filename, &locker);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_CREATE,
- filename, &locker);
- if (likely(locker != NULL))
- PSI_server->start_file_open_wait(locker, src_file, src_line);
+ 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
+
file= my_create_with_symlink(linkname, filename, create_flags, access_flags,
flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_open_wait_and_bind_to_descriptor(locker, file);
-#endif
return file;
}
+
static inline int
inline_mysql_file_delete_with_symlink(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *name, const char *ext, myf flags)
{
int result;
- char fullname[FN_REFLEN];
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+ 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;
-#endif
- fn_format(fullname, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_DELETE, fullname, &locker);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_DELETE,
- fullname, &locker);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_handler_delete_with_symlink(fullname, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline int
inline_mysql_file_rename_with_symlink(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
PSI_file_key key, const char *src_file, uint src_line,
#endif
const char *from, const char *to, myf flags)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_RENAME, to, &locker);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_RENAME,
- to, &locker);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_rename_with_symlink(from, to, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
static inline int
inline_mysql_file_sync(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_FILE_INTERFACE
const char *src_file, uint src_line,
#endif
File fd, myf flags)
{
int result= 0;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_file_locker *locker= NULL;
+#ifdef HAVE_PSI_FILE_INTERFACE
+ struct PSI_file_locker *locker;
PSI_file_locker_state state;
- if (likely(PSI_server != NULL))
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)
+ (&state, fd, PSI_FILE_SYNC);
+ if (likely(locker != NULL))
{
- locker= PSI_server->get_thread_file_descriptor_locker(&state, fd, PSI_FILE_SYNC);
- if (likely(locker != NULL))
- PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line);
+ 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
+
result= my_sync(fd, flags);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_file_wait(locker, (size_t) 0);
-#endif
return result;
}
/** @} (end of group File_instrumentation) */
#endif
-
diff --git a/include/mysql/psi/mysql_idle.h b/include/mysql/psi/mysql_idle.h
new file mode 100644
index 00000000000..5c72b715b7a
--- /dev/null
+++ b/include/mysql/psi/mysql_idle.h
@@ -0,0 +1,92 @@
+/* Copyright (c) 2011, 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef MYSQL_IDLE_H
+#define MYSQL_IDLE_H
+
+/**
+ @file mysql/psi/mysql_idle.h
+ Instrumentation helpers for idle waits.
+*/
+
+#include "mysql/psi/psi.h"
+
+/**
+ @defgroup Idle_instrumentation Idle Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ @def MYSQL_START_IDLE_WAIT
+ Instrumentation helper for table io_waits.
+ This instrumentation marks the start of a wait event.
+ @param LOCKER the locker
+ @param STATE the locker state
+ @sa MYSQL_END_IDLE_WAIT.
+*/
+#ifdef HAVE_PSI_IDLE_INTERFACE
+ #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
+ LOCKER= inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__)
+#else
+ #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
+ do {} while (0)
+#endif
+
+/**
+ @def MYSQL_END_IDLE_WAIT
+ Instrumentation helper for idle waits.
+ This instrumentation marks the end of a wait event.
+ @param LOCKER the locker
+ @sa MYSQL_START_IDLE_WAIT.
+*/
+#ifdef HAVE_PSI_IDLE_INTERFACE
+ #define MYSQL_END_IDLE_WAIT(LOCKER) \
+ inline_mysql_end_idle_wait(LOCKER)
+#else
+ #define MYSQL_END_IDLE_WAIT(LOCKER) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_IDLE_INTERFACE
+/**
+ Instrumentation calls for MYSQL_START_IDLE_WAIT.
+ @sa MYSQL_END_IDLE_WAIT.
+*/
+static inline struct PSI_idle_locker *
+inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
+ const char *src_file, int src_line)
+{
+ struct PSI_idle_locker *locker;
+ locker= PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line);
+ return locker;
+}
+
+/**
+ Instrumentation calls for MYSQL_END_IDLE_WAIT.
+ @sa MYSQL_START_IDLE_WAIT.
+*/
+static inline void
+inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
+{
+ if (likely(locker != NULL))
+ PSI_IDLE_CALL(end_idle_wait)(locker);
+}
+#endif
+
+/** @} (end of group Idle_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h
new file mode 100644
index 00000000000..1573fe77a9a
--- /dev/null
+++ b/include/mysql/psi/mysql_socket.h
@@ -0,0 +1,1161 @@
+/* Copyright (c) 2010, 2012, 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
+*/
+
+#ifndef MYSQL_SOCKET_H
+#define MYSQL_SOCKET_H
+
+/* For strlen() */
+#include <string.h>
+/* For MY_STAT */
+#include <my_dir.h>
+/* For my_chsize */
+#include <my_sys.h>
+/* For socket api */
+#ifdef __WIN__
+ #include <ws2def.h>
+ #include <winsock2.h>
+ #include <MSWSock.h>
+ #define SOCKBUF_T char
+#else
+ #include <netinet/in.h>
+ #define SOCKBUF_T void
+#endif
+/**
+ @file mysql/psi/mysql_socket.h
+[...]
+*/
+
+#include "mysql/psi/psi.h"
+
+/**
+ @defgroup Socket_instrumentation Socket Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ @def mysql_socket_register(P1, P2, P3)
+ Socket registration.
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_register(P1, P2, P3) \
+ inline_mysql_socket_register(P1, P2, P3)
+#else
+ #define mysql_socket_register(P1, P2, P3) \
+ do {} while (0)
+#endif
+
+struct st_mysql_socket
+{
+ /** The real socket descriptor. */
+ my_socket fd;
+
+ /**
+ The instrumentation hook.
+ Note that this hook is not conditionally defined,
+ for binary compatibility of the @c MYSQL_SOCKET interface.
+ */
+ struct PSI_socket *m_psi;
+};
+
+/**
+ An instrumented socket.
+ @c MYSQL_SOCKET is a replacement for @c my_socket.
+*/
+typedef struct st_mysql_socket MYSQL_SOCKET;
+
+
+/**
+ @def MYSQL_INVALID_SOCKET
+ MYSQL_SOCKET initial value.
+*/
+//MYSQL_SOCKET MYSQL_INVALID_SOCKET= {INVALID_SOCKET, NULL};
+#define MYSQL_INVALID_SOCKET mysql_socket_invalid()
+
+/**
+ MYSQL_SOCKET helper. Initialize instrumented socket.
+ @sa mysql_socket_getfd
+ @sa mysql_socket_setfd
+*/
+static inline MYSQL_SOCKET
+mysql_socket_invalid()
+{
+ MYSQL_SOCKET mysql_socket= {INVALID_SOCKET, NULL};
+ return mysql_socket;
+}
+
+/**
+ Set socket descriptor and address.
+ @param socket nstrumented socket
+ @param fd socket descriptor
+ @param addr unformatted socket address
+ @param adr_len length of socket addres
+*/
+
+static inline void
+mysql_socket_set_address(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ MYSQL_SOCKET socket,
+ const struct sockaddr *addr,
+ socklen_t addr_len
+#else
+ MYSQL_SOCKET socket __attribute__ ((unused)),
+ const struct sockaddr *addr __attribute__ ((unused)),
+ socklen_t addr_len __attribute__ ((unused))
+#endif
+)
+{
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (socket.m_psi != NULL)
+ PSI_SOCKET_CALL(set_socket_info)(socket.m_psi, NULL, addr, addr_len);
+#endif
+}
+
+/**
+ Set socket descriptor and address.
+ @param socket instrumented socket
+ @param thread instrumented owning thread
+*/
+static inline void
+mysql_socket_set_thread_owner(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+MYSQL_SOCKET socket
+#else
+MYSQL_SOCKET socket __attribute__ ((unused))
+#endif
+)
+{
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (socket.m_psi != NULL)
+ PSI_SOCKET_CALL(set_socket_thread_owner)(socket.m_psi);
+#endif
+}
+
+/**
+ MYSQL_SOCKET helper. Get socket descriptor.
+ @param mysql_socket Instrumented socket
+ @sa mysql_socket_getfd
+*/
+static inline my_socket
+mysql_socket_getfd(MYSQL_SOCKET mysql_socket)
+{
+ return mysql_socket.fd;
+}
+
+/**
+ MYSQL_SOCKET helper. Set socket descriptor.
+ @param mysql_socket Instrumented socket
+ @param fd Socket descriptor
+ @sa mysql_socket_setfd
+*/
+static inline void
+mysql_socket_setfd(MYSQL_SOCKET *mysql_socket, my_socket fd)
+{
+ if (likely(mysql_socket != NULL))
+ mysql_socket->fd= fd;
+}
+
+/**
+ @def MYSQL_SOCKET_WAIT_VARIABLES
+ Instrumentation helper for socket waits.
+ This instrumentation declares local variables.
+ Do not use a ';' after this macro
+ @param LOCKER locker
+ @param STATE locker state
+ @sa MYSQL_START_SOCKET_WAIT.
+ @sa MYSQL_END_SOCKET_WAIT.
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define MYSQL_SOCKET_WAIT_VARIABLES(LOCKER, STATE) \
+ struct PSI_socket_locker* LOCKER; \
+ PSI_socket_locker_state STATE;
+#else
+ #define MYSQL_SOCKET_WAIT_VARIABLES(LOCKER, STATE)
+#endif
+
+/**
+ @def MYSQL_START_SOCKET_WAIT
+ Instrumentation helper for socket waits.
+ This instrumentation marks the start of a wait event.
+ @param LOCKER locker
+ @param STATE locker state
+ @param SOCKET instrumented socket
+ @param OP The socket operation to be performed
+ @param FLAGS per-socket operation flags.
+ @param COUNT bytes to be written/read
+ @sa MYSQL_END_SOCKET_WAIT.
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define MYSQL_START_SOCKET_WAIT(LOCKER, STATE, SOCKET, OP, COUNT) \
+ LOCKER= inline_mysql_start_socket_wait(STATE, SOCKET, OP, COUNT,\
+ __FILE__, __LINE__)
+#else
+ #define MYSQL_START_SOCKET_WAIT(LOCKER, STATE, SOCKET, OP, COUNT) \
+ do {} while (0)
+#endif
+
+/**
+ @def MYSQL_END_SOCKET_WAIT
+ Instrumentation helper for socket waits.
+ This instrumentation marks the end of a wait event.
+ @param LOCKER locker
+ @param COUNT actual bytes written/read, or -1
+ @sa MYSQL_START_SOCKET_WAIT.
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define MYSQL_END_SOCKET_WAIT(LOCKER, COUNT) \
+ inline_mysql_end_socket_wait(LOCKER, COUNT)
+#else
+ #define MYSQL_END_SOCKET_WAIT(LOCKER, COUNT) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define MYSQL_SOCKET_SET_STATE(SOCKET, STATE) \
+ inline_mysql_socket_set_state(SOCKET, STATE)
+#else
+ #define MYSQL_SOCKET_SET_STATE(SOCKET, STATE) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+/**
+ Instrumentation calls for MYSQL_START_SOCKET_WAIT.
+ @sa MYSQL_START_SOCKET_WAIT.
+*/
+static inline struct PSI_socket_locker*
+inline_mysql_start_socket_wait(PSI_socket_locker_state *state,
+ MYSQL_SOCKET mysql_socket,
+ enum PSI_socket_operation op,
+ size_t byte_count,
+ const char *src_file, int src_line)
+{
+ struct PSI_socket_locker *locker;
+ if (mysql_socket.m_psi != NULL)
+ {
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (state, mysql_socket.m_psi, op, byte_count, src_file, src_line);
+ }
+ else
+ locker= NULL;
+ return locker;
+}
+
+/**
+ Instrumentation calls for MYSQL_END_SOCKET_WAIT.
+ @sa MYSQL_END_SOCKET_WAIT.
+*/
+static inline void
+inline_mysql_end_socket_wait(struct PSI_socket_locker *locker, size_t byte_count)
+{
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, byte_count);
+}
+
+/**
+ Set the state (IDLE, ACTIVE) of an instrumented socket.
+ @param socket the instrumented socket
+ @param state the new state
+ @sa PSI_socket_state
+*/
+static inline void
+inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
+{
+ if (socket.m_psi != NULL)
+ PSI_SOCKET_CALL(set_socket_state)(socket.m_psi, state);
+}
+#endif /* HAVE_PSI_SOCKET_INTERFACE */
+
+/**
+ @def mysql_socket_socket(K, D, T, P)
+ Create a socket.
+ @c mysql_socket_socket is a replacement for @c socket.
+ @param K PSI_socket_key for this instrumented socket
+ @param D Socket domain
+ @param T Protocol type
+ @param P Transport protocol
+*/
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_socket(K, D, T, P) \
+ inline_mysql_socket_socket(K, D, T, P)
+#else
+ #define mysql_socket_socket(K, D, T, P) \
+ inline_mysql_socket_socket(D, T, P)
+#endif
+
+/**
+ @def mysql_socket_bind(FD, AP, L)
+ Bind a socket to a local port number and IP address
+ @c mysql_socket_bind is a replacement for @c bind.
+ @param FD Instrumented socket descriptor returned by socket()
+ @param AP Pointer to local port number and IP address in sockaddr structure
+ @param L Length of sockaddr structure
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_bind(FD, AP, L) \
+ inline_mysql_socket_bind(__FILE__, __LINE__, FD, AP, L)
+#else
+ #define mysql_socket_bind(FD, AP, L) \
+ inline_mysql_socket_bind(FD, AP, L)
+#endif
+
+/**
+ @def mysql_socket_getsockname(FD, AP, LP)
+ Return port number and IP address of the local host
+ @c mysql_socket_getsockname is a replacement for @c getsockname.
+ @param FD Instrumented socket descriptor returned by socket()
+ @param A Pointer to returned address of local host in sockaddr structure
+ @param L Pointer to length of sockaddr structure
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_getsockname(FD, AP, LP) \
+ inline_mysql_socket_getsockname(__FILE__, __LINE__, FD, AP, LP)
+#else
+ #define mysql_socket_getsockname(FD, AP, LP) \
+ inline_mysql_socket_getsockname(FD, AP, LP)
+#endif
+
+/**
+ @def mysql_socket_connect(FD, AP, L)
+ Establish a connection to a remote host.
+ @c mysql_socket_connect is a replacement for @c connect.
+ @param FD Instrumented socket descriptor returned by socket()
+ @param AP Pointer to target address in sockaddr structure
+ @param L Length of sockaddr structure
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_connect(FD, AP, L) \
+ inline_mysql_socket_connect(__FILE__, __LINE__, FD, AP, L)
+#else
+ #define mysql_socket_connect(FD, AP, L) \
+ inline_mysql_socket_connect(FD, AP, L)
+#endif
+
+/**
+ @def mysql_socket_getpeername(FD, AP, LP)
+ Get port number and IP address of remote host that a socket is connected to.
+ @c mysql_socket_getpeername is a replacement for @c getpeername.
+ @param FD Instrumented socket descriptor returned by socket() or accept()
+ @param AP Pointer to returned address of remote host in sockaddr structure
+ @param LP Pointer to length of sockaddr structure
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_getpeername(FD, AP, LP) \
+ inline_mysql_socket_getpeername(__FILE__, __LINE__, FD, AP, LP)
+#else
+ #define mysql_socket_getpeername(FD, AP, LP) \
+ inline_mysql_socket_getpeername(FD, AP, LP)
+#endif
+
+/**
+ @def mysql_socket_send(FD, B, N, FL)
+ Send data from the buffer, B, to a connected socket.
+ @c mysql_socket_send is a replacement for @c send.
+ @param FD Instrumented socket descriptor returned by socket() or accept()
+ @param B Buffer to send
+ @param N Number of bytes to send
+ @param FL Control flags
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_send(FD, B, N, FL) \
+ inline_mysql_socket_send(__FILE__, __LINE__, FD, B, N, FL)
+#else
+ #define mysql_socket_send(FD, B, N, FL) \
+ inline_mysql_socket_send(FD, B, N, FL)
+#endif
+
+/**
+ @def mysql_socket_recv(FD, B, N, FL)
+ Receive data from a connected socket.
+ @c mysql_socket_recv is a replacement for @c recv.
+ @param FD Instrumented socket descriptor returned by socket() or accept()
+ @param B Buffer to receive to
+ @param N Maximum bytes to receive
+ @param FL Control flags
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_recv(FD, B, N, FL) \
+ inline_mysql_socket_recv(__FILE__, __LINE__, FD, B, N, FL)
+#else
+ #define mysql_socket_recv(FD, B, N, FL) \
+ inline_mysql_socket_recv(FD, B, N, FL)
+#endif
+
+/**
+ @def mysql_socket_sendto(FD, B, N, FL, AP, L)
+ Send data to a socket at the specified address.
+ @c mysql_socket_sendto is a replacement for @c sendto.
+ @param FD Instrumented socket descriptor returned by socket()
+ @param B Buffer to send
+ @param N Number of bytes to send
+ @param FL Control flags
+ @param AP Pointer to destination sockaddr structure
+ @param L Size of sockaddr structure
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_sendto(FD, B, N, FL, AP, L) \
+ inline_mysql_socket_sendto(__FILE__, __LINE__, FD, B, N, FL, AP, L)
+#else
+ #define mysql_socket_sendto(FD, B, N, FL, AP, L) \
+ inline_mysql_socket_sendto(FD, B, N, FL, AP, L)
+#endif
+
+/**
+ @def mysql_socket_recvfrom(FD, B, N, FL, AP, L)
+ Receive data from a socket and return source address information
+ @c mysql_socket_recvfrom is a replacement for @c recvfrom.
+ @param FD Instrumented socket descriptor returned by socket()
+ @param B Buffer to receive to
+ @param N Maximum bytes to receive
+ @param FL Control flags
+ @param AP Pointer to source address in sockaddr_storage structure
+ @param L Size of sockaddr_storage structure
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_recvfrom(FD, B, N, FL, AP, LP) \
+ inline_mysql_socket_recvfrom(__FILE__, __LINE__, FD, B, N, FL, AP, LP)
+#else
+ #define mysql_socket_recvfrom(FD, B, N, FL, AP, LP) \
+ inline_mysql_socket_recvfrom(FD, B, N, FL, AP, LP)
+#endif
+
+/**
+ @def mysql_socket_getsockopt(FD, LV, ON, OP, OL)
+ Get a socket option for the specified socket.
+ @c mysql_socket_getsockopt is a replacement for @c getsockopt.
+ @param FD Instrumented socket descriptor returned by socket()
+ @param LV Protocol level
+ @param ON Option to query
+ @param OP Buffer which will contain the value for the requested option
+ @param OL Pointer to length of OP
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_getsockopt(FD, LV, ON, OP, OL) \
+ inline_mysql_socket_getsockopt(__FILE__, __LINE__, FD, LV, ON, OP, OL)
+#else
+ #define mysql_socket_getsockopt(FD, LV, ON, OP, OL) \
+ inline_mysql_socket_getsockopt(FD, LV, ON, OP, OL)
+#endif
+
+/**
+ @def mysql_socket_setsockopt(FD, LV, ON, OP, OL)
+ Set a socket option for the specified socket.
+ @c mysql_socket_setsockopt is a replacement for @c setsockopt.
+ @param FD Instrumented socket descriptor returned by socket()
+ @param LV Protocol level
+ @param ON Option to modify
+ @param OP Buffer containing the value for the specified option
+ @param OL Pointer to length of OP
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_setsockopt(FD, LV, ON, OP, OL) \
+ inline_mysql_socket_setsockopt(__FILE__, __LINE__, FD, LV, ON, OP, OL)
+#else
+ #define mysql_socket_setsockopt(FD, LV, ON, OP, OL) \
+ inline_mysql_socket_setsockopt(FD, LV, ON, OP, OL)
+#endif
+
+/**
+ @def mysql_socket_listen(FD, N)
+ Set socket state to listen for an incoming connection.
+ @c mysql_socket_listen is a replacement for @c listen.
+ @param FD Instrumented socket descriptor, bound and connected
+ @param N Maximum number of pending connections allowed.
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_listen(FD, N) \
+ inline_mysql_socket_listen(__FILE__, __LINE__, FD, N)
+#else
+ #define mysql_socket_listen(FD, N) \
+ inline_mysql_socket_listen(FD, N)
+#endif
+
+/**
+ @def mysql_socket_accept(K, FD, AP, LP)
+ Accept a connection from any remote host; TCP only.
+ @c mysql_socket_accept is a replacement for @c accept.
+ @param K PSI_socket_key for this instrumented socket
+ @param FD Instrumented socket descriptor, bound and placed in a listen state
+ @param AP Pointer to sockaddr structure with returned IP address and port of connected host
+ @param LP Pointer to length of valid information in AP
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_accept(K, FD, AP, LP) \
+ inline_mysql_socket_accept(__FILE__, __LINE__, K, FD, AP, LP)
+#else
+ #define mysql_socket_accept(K, FD, AP, LP) \
+ inline_mysql_socket_accept(FD, AP, LP)
+#endif
+
+/**
+ @def mysql_socket_close(FD)
+ Close a socket and sever any connections.
+ @c mysql_socket_close is a replacement for @c close.
+ @param FD Instrumented socket descriptor returned by socket() or accept()
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_close(FD) \
+ inline_mysql_socket_close(__FILE__, __LINE__, FD)
+#else
+ #define mysql_socket_close(FD) \
+ inline_mysql_socket_close(FD)
+#endif
+
+/**
+ @def mysql_socket_shutdown(FD, H)
+ Disable receives and/or sends on a socket.
+ @c mysql_socket_shutdown is a replacement for @c shutdown.
+ @param FD Instrumented socket descriptor returned by socket() or accept()
+ @param H Specifies which operations to shutdown
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_socket_shutdown(FD, H) \
+ inline_mysql_socket_shutdown(__FILE__, __LINE__, FD, H)
+#else
+ #define mysql_socket_shutdown(FD, H) \
+ inline_mysql_socket_shutdown(FD, H)
+#endif
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+static inline void inline_mysql_socket_register(
+ const char *category,
+ PSI_socket_info *info,
+ int count)
+{
+ PSI_SOCKET_CALL(register_socket)(category, info, count);
+}
+#endif
+
+/** mysql_socket_socket */
+
+static inline MYSQL_SOCKET
+inline_mysql_socket_socket
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ PSI_socket_key key,
+#endif
+ int domain, int type, int protocol)
+{
+ MYSQL_SOCKET mysql_socket= MYSQL_INVALID_SOCKET;
+ mysql_socket.fd= socket(domain, type, protocol);
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (likely(mysql_socket.fd != INVALID_SOCKET))
+ {
+ mysql_socket.m_psi= PSI_SOCKET_CALL(init_socket)
+ (key, (const my_socket*)&mysql_socket.fd, NULL, 0);
+ }
+#endif
+ return mysql_socket;
+}
+
+/** mysql_socket_bind */
+
+static inline int
+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)
+{
+ int result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker_state state;
+ PSI_socket_locker *locker;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_BIND, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= bind(mysql_socket.fd, addr, len);
+
+ /* Instrumentation end */
+ if (result == 0)
+ PSI_SOCKET_CALL(set_socket_info)(mysql_socket.m_psi, NULL, addr, len);
+
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= bind(mysql_socket.fd, addr, len);
+ return result;
+}
+
+/** mysql_socket_getsockname */
+
+static inline int
+inline_mysql_socket_getsockname
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, struct sockaddr *addr, socklen_t *len)
+{
+ int result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_BIND, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= getsockname(mysql_socket.fd, addr, len);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= getsockname(mysql_socket.fd, addr, len);
+
+ return result;
+}
+
+/** mysql_socket_connect */
+
+static inline int
+inline_mysql_socket_connect
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, const struct sockaddr *addr, socklen_t len)
+{
+ int result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_CONNECT, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= connect(mysql_socket.fd, addr, len);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= connect(mysql_socket.fd, addr, len);
+
+ return result;
+}
+
+/** mysql_socket_getpeername */
+
+static inline int
+inline_mysql_socket_getpeername
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, struct sockaddr *addr, socklen_t *len)
+{
+ int result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_BIND, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= getpeername(mysql_socket.fd, addr, len);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= getpeername(mysql_socket.fd, addr, len);
+
+ return result;
+}
+
+/** mysql_socket_send */
+
+static inline ssize_t
+inline_mysql_socket_send
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, const SOCKBUF_T *buf, size_t n, int flags)
+{
+ ssize_t result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_SEND, n, src_file, src_line);
+
+ /* Instrumented code */
+ result= send(mysql_socket.fd, buf, IF_WIN((int),) n, flags);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ {
+ size_t bytes_written;
+ bytes_written= (result > -1) ? result : 0;
+ PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_written);
+ }
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= send(mysql_socket.fd, buf, IF_WIN((int),) n, flags);
+
+ return result;
+}
+
+/** mysql_socket_recv */
+
+static inline ssize_t
+inline_mysql_socket_recv
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, SOCKBUF_T *buf, size_t n, int flags)
+{
+ ssize_t result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_RECV, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= recv(mysql_socket.fd, buf, IF_WIN((int),) n, flags);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ {
+ size_t bytes_read;
+ bytes_read= (result > -1) ? result : 0;
+ PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_read);
+ }
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= recv(mysql_socket.fd, buf, IF_WIN((int),) n, flags);
+
+ return result;
+}
+
+/** mysql_socket_sendto */
+
+static inline ssize_t
+inline_mysql_socket_sendto
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, const SOCKBUF_T *buf, size_t n, int flags, const struct sockaddr *addr, socklen_t addr_len)
+{
+ ssize_t result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_SEND, n, src_file, src_line);
+
+ /* Instrumented code */
+ result= sendto(mysql_socket.fd, buf, IF_WIN((int),) n, flags, addr, addr_len);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ {
+ size_t bytes_written;
+ bytes_written = (result > -1) ? result : 0;
+ PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_written);
+ }
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= sendto(mysql_socket.fd, buf, IF_WIN((int),) n, flags, addr, addr_len);
+
+ return result;
+}
+
+/** mysql_socket_recvfrom */
+
+static inline ssize_t
+inline_mysql_socket_recvfrom
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, SOCKBUF_T *buf, size_t n, int flags,
+ struct sockaddr *addr, socklen_t *addr_len)
+{
+ ssize_t result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_RECV, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= recvfrom(mysql_socket.fd, buf, IF_WIN((int),) n, flags, addr, addr_len);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ {
+ size_t bytes_read;
+ bytes_read = (result > -1) ? result : 0;
+ PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_read);
+ }
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= recvfrom(mysql_socket.fd, buf, IF_WIN((int),) n, flags, addr, addr_len);
+
+ return result;
+}
+
+/** mysql_socket_getsockopt */
+
+static inline int
+inline_mysql_socket_getsockopt
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, int level, int optname, SOCKBUF_T *optval, socklen_t *optlen)
+{
+ int result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_OPT, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= getsockopt(mysql_socket.fd, level, optname, optval, optlen);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= getsockopt(mysql_socket.fd, level, optname, optval, optlen);
+
+ return result;
+}
+
+/** mysql_socket_setsockopt */
+
+static inline int
+inline_mysql_socket_setsockopt
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, int level, int optname, const SOCKBUF_T *optval,
+ socklen_t optlen)
+{
+ int result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_OPT, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= setsockopt(mysql_socket.fd, level, optname, optval, optlen);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= setsockopt(mysql_socket.fd, level, optname, optval, optlen);
+
+ return result;
+}
+
+/** mysql_socket_listen */
+
+static inline int
+inline_mysql_socket_listen
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, int backlog)
+{
+ int result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_CONNECT, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= listen(mysql_socket.fd, backlog);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= listen(mysql_socket.fd, backlog);
+
+ return result;
+}
+
+/** mysql_socket_accept */
+
+static inline MYSQL_SOCKET
+inline_mysql_socket_accept
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line, PSI_socket_key key,
+#endif
+ MYSQL_SOCKET socket_listen, struct sockaddr *addr, socklen_t *addr_len)
+{
+ MYSQL_SOCKET socket_accept= MYSQL_INVALID_SOCKET;
+ socklen_t addr_length= (addr_len != NULL) ? *addr_len : 0;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (socket_listen.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, socket_listen.m_psi, PSI_SOCKET_CONNECT, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+ }
+ else
+#endif
+ {
+ /* Non instrumented code */
+ socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
+ }
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (likely(socket_accept.fd != INVALID_SOCKET))
+ {
+ /* Initialize the instrument with the new socket descriptor and address */
+ socket_accept.m_psi= PSI_SOCKET_CALL(init_socket)
+ (key, (const my_socket*)&socket_accept.fd, addr, addr_length);
+ }
+#endif
+
+ return socket_accept;
+}
+
+/** mysql_socket_close */
+
+static inline int
+inline_mysql_socket_close
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket)
+{
+ int result;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_CLOSE, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= closesocket(mysql_socket.fd);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+ /* Remove the instrumentation for this socket. */
+ if (mysql_socket.m_psi != NULL)
+ PSI_SOCKET_CALL(destroy_socket)(mysql_socket.m_psi);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= closesocket(mysql_socket.fd);
+
+ return result;
+}
+
+/** mysql_socket_shutdown */
+
+static inline int
+inline_mysql_socket_shutdown
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket, int how)
+{
+ int result;
+
+#ifdef __WIN__
+ static LPFN_DISCONNECTEX DisconnectEx = NULL;
+ if (DisconnectEx == NULL)
+ {
+ DWORD dwBytesReturned;
+ GUID guidDisconnectEx = WSAID_DISCONNECTEX;
+ WSAIoctl(mysql_socket.fd, SIO_GET_EXTENSION_FUNCTION_POINTER,
+ &guidDisconnectEx, sizeof(GUID),
+ &DisconnectEx, sizeof(DisconnectEx),
+ &dwBytesReturned, NULL, NULL);
+ }
+#endif
+
+/* Instrumentation start */
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi != NULL)
+ {
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_SHUTDOWN, (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+#ifdef __WIN__
+ if (DisconnectEx)
+ result= (DisconnectEx(mysql_socket.fd, (LPOVERLAPPED) NULL,
+ (DWORD) 0, (DWORD) 0) == TRUE) ? 0 : -1;
+ else
+#endif
+ result= shutdown(mysql_socket.fd, how);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+#ifdef __WIN__
+ if (DisconnectEx)
+ result= (DisconnectEx(mysql_socket.fd, (LPOVERLAPPED) NULL,
+ (DWORD) 0, (DWORD) 0) == TRUE) ? 0 : -1;
+ else
+#endif
+ result= shutdown(mysql_socket.fd, how);
+
+ return result;
+}
+
+/** @} (end of group Socket_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/mysql_stage.h b/include/mysql/psi/mysql_stage.h
new file mode 100644
index 00000000000..91a5c12f82e
--- /dev/null
+++ b/include/mysql/psi/mysql_stage.h
@@ -0,0 +1,72 @@
+/* Copyright (c) 2010, 2012, 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 */
+
+#ifndef MYSQL_STAGE_H
+#define MYSQL_STAGE_H
+
+/**
+ @file mysql/psi/mysql_stage.h
+ Instrumentation helpers for stages.
+*/
+
+#include "mysql/psi/psi.h"
+
+/**
+ @defgroup Stage_instrumentation Stage Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ @def mysql_stage_register(P1, P2, P3)
+ Stage registration.
+*/
+#ifdef HAVE_PSI_STAGE_INTERFACE
+#define mysql_stage_register(P1, P2, P3) \
+ inline_mysql_stage_register(P1, P2, P3)
+#else
+#define mysql_stage_register(P1, P2, P3) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+ #define MYSQL_SET_STAGE(K, F, L) \
+ inline_mysql_set_stage(K, F, L)
+#else
+ #define MYSQL_SET_STAGE(K, F, L) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void inline_mysql_stage_register(
+ const char *category, PSI_stage_info **info, int count)
+{
+ PSI_STAGE_CALL(register_stage)(category, info, count);
+}
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void
+inline_mysql_set_stage(PSI_stage_key key,
+ const char *src_file, int src_line)
+{
+ PSI_STAGE_CALL(start_stage)(key, src_file, src_line);
+}
+#endif
+
+/** @} (end of group Stage_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/mysql_statement.h b/include/mysql/psi/mysql_statement.h
new file mode 100644
index 00000000000..3d5943fa55a
--- /dev/null
+++ b/include/mysql/psi/mysql_statement.h
@@ -0,0 +1,222 @@
+/* Copyright (c) 2010, 2015, 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 */
+
+#ifndef MYSQL_STATEMENT_H
+#define MYSQL_STATEMENT_H
+
+/**
+ @file mysql/psi/mysql_statement.h
+ Instrumentation helpers for statements.
+*/
+
+#include "mysql/psi/psi.h"
+
+/**
+ @defgroup Statement_instrumentation Statement Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ @def mysql_statement_register(P1, P2, P3)
+ Statement registration.
+*/
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+#define mysql_statement_register(P1, P2, P3) \
+ inline_mysql_statement_register(P1, P2, P3)
+#else
+#define mysql_statement_register(P1, P2, P3) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+ #define MYSQL_DIGEST_START(LOCKER) \
+ inline_mysql_digest_start(LOCKER)
+#else
+ #define MYSQL_DIGEST_START(LOCKER) \
+ NULL
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+ #define MYSQL_DIGEST_END(LOCKER, DIGEST) \
+ inline_mysql_digest_end(LOCKER, DIGEST)
+#else
+ #define MYSQL_DIGEST_END(LOCKER, DIGEST) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+ #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS) \
+ inline_mysql_start_statement(STATE, K, DB, DB_LEN, CS, __FILE__, __LINE__)
+#else
+ #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS) \
+ NULL
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+ #define MYSQL_REFINE_STATEMENT(LOCKER, K) \
+ inline_mysql_refine_statement(LOCKER, K)
+#else
+ #define MYSQL_REFINE_STATEMENT(LOCKER, K) \
+ NULL
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+ #define MYSQL_SET_STATEMENT_TEXT(LOCKER, P1, P2) \
+ inline_mysql_set_statement_text(LOCKER, P1, P2)
+#else
+ #define MYSQL_SET_STATEMENT_TEXT(LOCKER, P1, P2) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+ #define MYSQL_SET_STATEMENT_LOCK_TIME(LOCKER, P1) \
+ inline_mysql_set_statement_lock_time(LOCKER, P1)
+#else
+ #define MYSQL_SET_STATEMENT_LOCK_TIME(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+ #define MYSQL_SET_STATEMENT_ROWS_SENT(LOCKER, P1) \
+ inline_mysql_set_statement_rows_sent(LOCKER, P1)
+#else
+ #define MYSQL_SET_STATEMENT_ROWS_SENT(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+ #define MYSQL_SET_STATEMENT_ROWS_EXAMINED(LOCKER, P1) \
+ inline_mysql_set_statement_rows_examined(LOCKER, P1)
+#else
+ #define MYSQL_SET_STATEMENT_ROWS_EXAMINED(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+ #define MYSQL_END_STATEMENT(LOCKER, DA) \
+ inline_mysql_end_statement(LOCKER, DA)
+#else
+ #define MYSQL_END_STATEMENT(LOCKER, DA) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+static inline void inline_mysql_statement_register(
+ const char *category, PSI_statement_info *info, int count)
+{
+ PSI_STATEMENT_CALL(register_statement)(category, info, count);
+}
+
+#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+static inline struct PSI_digest_locker *
+inline_mysql_digest_start(PSI_statement_locker *locker)
+{
+ PSI_digest_locker* digest_locker= NULL;
+
+ if (likely(locker != NULL))
+ digest_locker= PSI_DIGEST_CALL(digest_start)(locker);
+ return digest_locker;
+}
+#endif
+
+#ifdef HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+static inline void
+inline_mysql_digest_end(PSI_digest_locker *locker, const sql_digest_storage *digest)
+{
+ if (likely(locker != NULL))
+ PSI_DIGEST_CALL(digest_end)(locker, digest);
+}
+#endif
+
+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 CHARSET_INFO *charset,
+ const char *src_file, int 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);
+ return locker;
+}
+
+static inline struct PSI_statement_locker *
+inline_mysql_refine_statement(PSI_statement_locker *locker,
+ PSI_statement_key key)
+{
+ if (likely(locker != NULL))
+ {
+ locker= PSI_STATEMENT_CALL(refine_statement)(locker, key);
+ }
+ return locker;
+}
+
+static inline void
+inline_mysql_set_statement_text(PSI_statement_locker *locker,
+ const char *text, uint text_len)
+{
+ if (likely(locker != NULL))
+ {
+ PSI_STATEMENT_CALL(set_statement_text)(locker, text, text_len);
+ }
+}
+
+static inline void
+inline_mysql_set_statement_lock_time(PSI_statement_locker *locker,
+ ulonglong count)
+{
+ if (likely(locker != NULL))
+ {
+ PSI_STATEMENT_CALL(set_statement_lock_time)(locker, count);
+ }
+}
+
+static inline void
+inline_mysql_set_statement_rows_sent(PSI_statement_locker *locker,
+ ulonglong count)
+{
+ if (likely(locker != NULL))
+ {
+ PSI_STATEMENT_CALL(set_statement_rows_sent)(locker, count);
+ }
+}
+
+static inline void
+inline_mysql_set_statement_rows_examined(PSI_statement_locker *locker,
+ ulonglong count)
+{
+ if (likely(locker != NULL))
+ {
+ PSI_STATEMENT_CALL(set_statement_rows_examined)(locker, count);
+ }
+}
+
+static inline void
+inline_mysql_end_statement(struct PSI_statement_locker *locker,
+ Diagnostics_area *stmt_da)
+{
+ PSI_STAGE_CALL(end_stage)();
+ if (likely(locker != NULL))
+ PSI_STATEMENT_CALL(end_statement)(locker, stmt_da);
+}
+#endif
+
+/** @} (end of group Statement_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/mysql_table.h b/include/mysql/psi/mysql_table.h
new file mode 100644
index 00000000000..bd703d75e1f
--- /dev/null
+++ b/include/mysql/psi/mysql_table.h
@@ -0,0 +1,207 @@
+/* Copyright (c) 2010, 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef MYSQL_TABLE_H
+#define MYSQL_TABLE_H
+
+/**
+ @file mysql/psi/mysql_table.h
+ Instrumentation helpers for table io.
+*/
+
+#include "mysql/psi/psi.h"
+
+/**
+ @defgroup Table_instrumentation Table Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+#ifdef HAVE_PSI_TABLE_INTERFACE
+#define PSI_CALL_unbind_table PSI_TABLE_CALL(unbind_table)
+#define PSI_CALL_rebind_table PSI_TABLE_CALL(rebind_table)
+#define PSI_CALL_open_table PSI_TABLE_CALL(open_table)
+#define PSI_CALL_close_table PSI_TABLE_CALL(close_table)
+#define PSI_CALL_get_table_share PSI_TABLE_CALL(get_table_share)
+#define PSI_CALL_release_table_share PSI_TABLE_CALL(release_table_share)
+#define PSI_CALL_drop_table_share PSI_TABLE_CALL(drop_table_share)
+#else
+#define PSI_CALL_unbind_table(A1) /* no-op */
+#define PSI_CALL_rebind_table(A1,A2,A3) NULL
+#define PSI_CALL_close_table(A1) /* no-op */
+#define PSI_CALL_open_table(A1,A2) NULL
+#define PSI_CALL_get_table_share(A1,A2) NULL
+#define PSI_CALL_release_table_share(A1) /* no-op */
+#define PSI_CALL_drop_table_share(A1,A2,A3,A4,A5) /* no-op */
+#endif
+
+/**
+ @def MYSQL_TABLE_WAIT_VARIABLES
+ Instrumentation helper for table waits.
+ This instrumentation declares local variables.
+ Do not use a ';' after this macro
+ @param LOCKER the locker
+ @param STATE the locker state
+ @sa MYSQL_START_TABLE_IO_WAIT.
+ @sa MYSQL_END_TABLE_IO_WAIT.
+ @sa MYSQL_START_TABLE_LOCK_WAIT.
+ @sa MYSQL_END_TABLE_LOCK_WAIT.
+*/
+#ifdef HAVE_PSI_TABLE_INTERFACE
+ #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) \
+ struct PSI_table_locker* LOCKER; \
+ PSI_table_locker_state STATE;
+#else
+ #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE)
+#endif
+
+/**
+ @def MYSQL_TABLE_IO_WAIT
+ Instrumentation helper for table io_waits.
+ This instrumentation marks the start of a wait event.
+ @param PSI the instrumented table
+ @param OP the table operation to be performed
+ @param INDEX the table index used if any, or MAY_KEY.
+ @param FLAGS per table operation flags.
+ @sa MYSQL_END_TABLE_WAIT.
+*/
+#ifdef HAVE_PSI_TABLE_INTERFACE
+ #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
+ { \
+ if (PSI != NULL) \
+ { \
+ PSI_table_locker *locker; \
+ PSI_table_locker_state state; \
+ locker= PSI_TABLE_CALL(start_table_io_wait) \
+ (& state, PSI, OP, INDEX, __FILE__, __LINE__); \
+ PAYLOAD \
+ if (locker != NULL) \
+ PSI_TABLE_CALL(end_table_io_wait)(locker); \
+ } \
+ else \
+ { \
+ PAYLOAD \
+ } \
+ }
+#else
+ #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
+ PAYLOAD
+#endif
+
+/**
+ @def MYSQL_TABLE_LOCK_WAIT
+ Instrumentation helper for table io_waits.
+ This instrumentation marks the start of a wait event.
+ @param PSI the instrumented table
+ @param OP the table operation to be performed
+ @param INDEX the table index used if any, or MAY_KEY.
+ @param FLAGS per table operation flags.
+ @sa MYSQL_END_TABLE_WAIT.
+*/
+#ifdef HAVE_PSI_TABLE_INTERFACE
+ #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
+ { \
+ if (PSI != NULL) \
+ { \
+ PSI_table_locker *locker; \
+ PSI_table_locker_state state; \
+ locker= PSI_TABLE_CALL(start_table_lock_wait) \
+ (& state, PSI, OP, FLAGS, __FILE__, __LINE__); \
+ PAYLOAD \
+ if (locker != NULL) \
+ PSI_TABLE_CALL(end_table_lock_wait)(locker); \
+ } \
+ else \
+ { \
+ PAYLOAD \
+ } \
+ }
+#else
+ #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
+ PAYLOAD
+#endif
+
+/**
+ @def MYSQL_START_TABLE_LOCK_WAIT
+ Instrumentation helper for table lock waits.
+ This instrumentation marks the start of a wait event.
+ @param LOCKER the locker
+ @param STATE the locker state
+ @param PSI the instrumented table
+ @param OP the table operation to be performed
+ @param FLAGS per table operation flags.
+ @sa MYSQL_END_TABLE_LOCK_WAIT.
+*/
+#ifdef HAVE_PSI_TABLE_INTERFACE
+ #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
+ LOCKER= inline_mysql_start_table_lock_wait(STATE, PSI, \
+ OP, FLAGS, __FILE__, __LINE__)
+#else
+ #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
+ do {} while (0)
+#endif
+
+/**
+ @def MYSQL_END_TABLE_LOCK_WAIT
+ Instrumentation helper for table lock waits.
+ This instrumentation marks the end of a wait event.
+ @param LOCKER the locker
+ @sa MYSQL_START_TABLE_LOCK_WAIT.
+*/
+#ifdef HAVE_PSI_TABLE_INTERFACE
+ #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
+ inline_mysql_end_table_lock_wait(LOCKER)
+#else
+ #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TABLE_INTERFACE
+/**
+ Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
+ @sa MYSQL_END_TABLE_LOCK_WAIT.
+*/
+static inline struct PSI_table_locker *
+inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
+ struct PSI_table *psi,
+ enum PSI_table_lock_operation op,
+ ulong flags, const char *src_file, int src_line)
+{
+ if (psi != NULL)
+ {
+ struct PSI_table_locker *locker;
+ locker= PSI_TABLE_CALL(start_table_lock_wait)
+ (state, psi, op, flags, src_file, src_line);
+ return locker;
+ }
+ return NULL;
+}
+
+/**
+ Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT.
+ @sa MYSQL_START_TABLE_LOCK_WAIT.
+*/
+static inline void
+inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
+{
+ if (locker != NULL)
+ PSI_TABLE_CALL(end_table_lock_wait)(locker);
+}
+#endif
+
+/** @} (end of group Table_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h
index f421f95cfd5..08dfeac37f1 100644
--- a/include/mysql/psi/mysql_thread.h
+++ b/include/mysql/psi/mysql_thread.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2013, Oracle and/or its affiliates.
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
@@ -69,7 +69,13 @@
struct st_mysql_mutex
{
/** The real mutex. */
+#ifdef SAFE_MUTEX
+ safe_mutex_t m_mutex;
+#elif defined(MY_PTHREAD_FASTMUTEX)
+ my_pthread_fastmutex_t m_mutex;
+#else
pthread_mutex_t m_mutex;
+#endif
/**
The instrumentation hook.
Note that this hook is not conditionally defined,
@@ -225,6 +231,13 @@ typedef struct st_mysql_cond mysql_cond_t;
rw_pr_lock_assert_not_write_owner(&(M)->m_prlock)
/**
+ @def mysql_mutex_register(P1, P2, P3)
+ Mutex registration.
+*/
+#define mysql_mutex_register(P1, P2, P3) \
+ inline_mysql_mutex_register(P1, P2, P3)
+
+/**
@def mysql_mutex_init(K, M, A)
Instrumented mutex_init.
@c mysql_mutex_init is a replacement for @c pthread_mutex_init.
@@ -233,7 +246,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@param A Mutex attributes
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_MUTEX_INTERFACE
#ifdef SAFE_MUTEX
#define mysql_mutex_init(K, M, A) \
inline_mysql_mutex_init(K, M, A, #M, __FILE__, __LINE__)
@@ -272,7 +285,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@param M The mutex to lock
*/
-#if defined(SAFE_MUTEX) || defined (HAVE_PSI_INTERFACE)
+#if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE)
#define mysql_mutex_lock(M) \
inline_mysql_mutex_lock(M, __FILE__, __LINE__)
#else
@@ -287,7 +300,7 @@ typedef struct st_mysql_cond mysql_cond_t;
for @c pthread_mutex_trylock.
*/
-#if defined(SAFE_MUTEX) || defined (HAVE_PSI_INTERFACE)
+#if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE)
#define mysql_mutex_trylock(M) \
inline_mysql_mutex_trylock(M, __FILE__, __LINE__)
#else
@@ -309,6 +322,13 @@ typedef struct st_mysql_cond mysql_cond_t;
#endif
/**
+ @def mysql_rwlock_register(P1, P2, P3)
+ Rwlock registration.
+*/
+#define mysql_rwlock_register(P1, P2, P3) \
+ inline_mysql_rwlock_register(P1, P2, P3)
+
+/**
@def mysql_rwlock_init(K, RW)
Instrumented rwlock_init.
@c mysql_rwlock_init is a replacement for @c pthread_rwlock_init.
@@ -316,7 +336,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@param K The PSI_rwlock_key for this instrumented rwlock
@param RW The rwlock to initialize
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
#define mysql_rwlock_init(K, RW) inline_mysql_rwlock_init(K, RW)
#else
#define mysql_rwlock_init(K, RW) inline_mysql_rwlock_init(RW)
@@ -329,7 +349,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@param K The PSI_rwlock_key for this instrumented prlock
@param RW The prlock to initialize
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
#define mysql_prlock_init(K, RW) inline_mysql_prlock_init(K, RW)
#else
#define mysql_prlock_init(K, RW) inline_mysql_prlock_init(RW)
@@ -357,7 +377,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_rwlock_rdlock is a drop-in replacement
for @c pthread_rwlock_rdlock.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
#define mysql_rwlock_rdlock(RW) \
inline_mysql_rwlock_rdlock(RW, __FILE__, __LINE__)
#else
@@ -371,7 +391,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_prlock_rdlock is a drop-in replacement
for @c rw_pr_rdlock.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
#define mysql_prlock_rdlock(RW) \
inline_mysql_prlock_rdlock(RW, __FILE__, __LINE__)
#else
@@ -385,7 +405,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_rwlock_wrlock is a drop-in replacement
for @c pthread_rwlock_wrlock.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
#define mysql_rwlock_wrlock(RW) \
inline_mysql_rwlock_wrlock(RW, __FILE__, __LINE__)
#else
@@ -399,7 +419,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_prlock_wrlock is a drop-in replacement
for @c rw_pr_wrlock.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
#define mysql_prlock_wrlock(RW) \
inline_mysql_prlock_wrlock(RW, __FILE__, __LINE__)
#else
@@ -413,7 +433,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_rwlock_tryrdlock is a drop-in replacement
for @c pthread_rwlock_tryrdlock.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
#define mysql_rwlock_tryrdlock(RW) \
inline_mysql_rwlock_tryrdlock(RW, __FILE__, __LINE__)
#else
@@ -427,7 +447,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_rwlock_trywrlock is a drop-in replacement
for @c pthread_rwlock_trywrlock.
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
#define mysql_rwlock_trywrlock(RW) \
inline_mysql_rwlock_trywrlock(RW, __FILE__, __LINE__)
#else
@@ -452,6 +472,13 @@ typedef struct st_mysql_cond mysql_cond_t;
#define mysql_prlock_unlock(RW) inline_mysql_prlock_unlock(RW)
/**
+ @def mysql_cond_register(P1, P2, P3)
+ Cond registration.
+*/
+#define mysql_cond_register(P1, P2, P3) \
+ inline_mysql_cond_register(P1, P2, P3)
+
+/**
@def mysql_cond_init(K, C, A)
Instrumented cond_init.
@c mysql_cond_init is a replacement for @c pthread_cond_init.
@@ -459,7 +486,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@param K The PSI_cond_key for this instrumented cond
@param A Condition attributes
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_COND_INTERFACE
#define mysql_cond_init(K, C, A) inline_mysql_cond_init(K, C, A)
#else
#define mysql_cond_init(K, C, A) inline_mysql_cond_init(C, A)
@@ -477,7 +504,7 @@ typedef struct st_mysql_cond mysql_cond_t;
Instrumented cond_wait.
@c mysql_cond_wait is a drop-in replacement for @c pthread_cond_wait.
*/
-#if defined(HAVE_PSI_INTERFACE) || defined(SAFE_MUTEX)
+#ifdef HAVE_PSI_COND_INTERFACE
#define mysql_cond_wait(C, M) \
inline_mysql_cond_wait(C, M, __FILE__, __LINE__)
#else
@@ -491,7 +518,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_cond_timedwait is a drop-in replacement
for @c pthread_cond_timedwait.
*/
-#if defined(HAVE_PSI_INTERFACE) || defined(SAFE_MUTEX)
+#ifdef HAVE_PSI_COND_INTERFACE
#define mysql_cond_timedwait(C, M, W) \
inline_mysql_cond_timedwait(C, M, W, __FILE__, __LINE__)
#else
@@ -514,6 +541,12 @@ typedef struct st_mysql_cond mysql_cond_t;
*/
#define mysql_cond_broadcast(C) inline_mysql_cond_broadcast(C)
+/**
+ @def mysql_thread_register(P1, P2, P3)
+ Thread registration.
+*/
+#define mysql_thread_register(P1, P2, P3) \
+ inline_mysql_thread_register(P1, P2, P3)
/**
@def mysql_thread_create(K, P1, P2, P3, P4)
@@ -532,7 +565,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@param P3 pthread_create parameter 3
@param P4 pthread_create parameter 4
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_THREAD_INTERFACE
#define mysql_thread_create(K, P1, P2, P3, P4) \
inline_mysql_thread_create(K, P1, P2, P3, P4)
#else
@@ -545,14 +578,31 @@ typedef struct st_mysql_cond mysql_cond_t;
Set the thread indentifier for the instrumentation.
@param I The thread identifier
*/
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_THREAD_INTERFACE
#define mysql_thread_set_psi_id(I) inline_mysql_thread_set_psi_id(I)
#else
#define mysql_thread_set_psi_id(I) do {} while (0)
#endif
+static inline void inline_mysql_mutex_register(
+#ifdef HAVE_PSI_MUTEX_INTERFACE
+ const char *category,
+ PSI_mutex_info *info,
+ int count
+#else
+ const char *category __attribute__ ((unused)),
+ void *info __attribute__ ((unused)),
+ int count __attribute__ ((unused))
+#endif
+)
+{
+#ifdef HAVE_PSI_MUTEX_INTERFACE
+ PSI_MUTEX_CALL(register_mutex)(category, info, count);
+#endif
+}
+
static inline int inline_mysql_mutex_init(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_MUTEX_INTERFACE
PSI_mutex_key key,
#endif
mysql_mutex_t *that,
@@ -562,14 +612,15 @@ static inline int inline_mysql_mutex_init(
#endif
)
{
-#ifdef HAVE_PSI_INTERFACE
- that->m_psi= PSI_server ? PSI_server->init_mutex(key, &that->m_mutex)
- : NULL;
+#ifdef HAVE_PSI_MUTEX_INTERFACE
+ that->m_psi= PSI_MUTEX_CALL(init_mutex)(key, &that->m_mutex);
#else
that->m_psi= NULL;
#endif
#ifdef SAFE_MUTEX
return safe_mutex_init(&that->m_mutex, attr, src_name, src_file, src_line);
+#elif defined(MY_PTHREAD_FASTMUTEX)
+ return my_pthread_fastmutex_init(&that->m_mutex, attr);
#else
return pthread_mutex_init(&that->m_mutex, attr);
#endif
@@ -582,15 +633,17 @@ static inline int inline_mysql_mutex_destroy(
#endif
)
{
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server && that->m_psi))
+#ifdef HAVE_PSI_MUTEX_INTERFACE
+ if (that->m_psi != NULL)
{
- PSI_server->destroy_mutex(that->m_psi);
+ PSI_MUTEX_CALL(destroy_mutex)(that->m_psi);
that->m_psi= NULL;
}
#endif
#ifdef SAFE_MUTEX
return safe_mutex_destroy(&that->m_mutex, src_file, src_line);
+#elif defined(MY_PTHREAD_FASTMUTEX)
+ return pthread_mutex_destroy(&that->m_mutex.mutex);
#else
return pthread_mutex_destroy(&that->m_mutex);
#endif
@@ -598,61 +651,95 @@ static inline int inline_mysql_mutex_destroy(
static inline int inline_mysql_mutex_lock(
mysql_mutex_t *that
-#if defined(SAFE_MUTEX) || defined (HAVE_PSI_INTERFACE)
+#if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE)
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_mutex_locker *locker= NULL;
- PSI_mutex_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_MUTEX_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_mutex_locker(&state, that->m_psi, PSI_MUTEX_LOCK);
- if (likely(locker != NULL))
- PSI_server->start_mutex_wait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_mutex_locker *locker;
+ PSI_mutex_locker_state state;
+ locker= PSI_MUTEX_CALL(start_mutex_wait)(&state, that->m_psi,
+ PSI_MUTEX_LOCK, src_file, src_line);
+
+ /* Instrumented code */
+#ifdef SAFE_MUTEX
+ result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line);
+#elif defined(MY_PTHREAD_FASTMUTEX)
+ result= my_pthread_fastmutex_lock(&that->m_mutex);
+#else
+ result= pthread_mutex_lock(&that->m_mutex);
+#endif
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_MUTEX_CALL(end_mutex_wait)(locker, result);
+
+ return result;
}
#endif
+
+ /* Non instrumented code */
#ifdef SAFE_MUTEX
result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line);
+#elif defined(MY_PTHREAD_FASTMUTEX)
+ result= my_pthread_fastmutex_lock(&that->m_mutex);
#else
result= pthread_mutex_lock(&that->m_mutex);
#endif
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_mutex_wait(locker, result);
-#endif
+
return result;
}
static inline int inline_mysql_mutex_trylock(
mysql_mutex_t *that
-#if defined(SAFE_MUTEX) || defined (HAVE_PSI_INTERFACE)
+#if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE)
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_mutex_locker *locker= NULL;
- PSI_mutex_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_MUTEX_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_mutex_locker(&state, that->m_psi, PSI_MUTEX_TRYLOCK);
- if (likely(locker != NULL))
- PSI_server->start_mutex_wait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_mutex_locker *locker;
+ PSI_mutex_locker_state state;
+ locker= PSI_MUTEX_CALL(start_mutex_wait)(&state, that->m_psi,
+ PSI_MUTEX_TRYLOCK, src_file, src_line);
+
+ /* Instrumented code */
+#ifdef SAFE_MUTEX
+ result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line);
+#elif defined(MY_PTHREAD_FASTMUTEX)
+ result= pthread_mutex_trylock(&that->m_mutex.mutex);
+#else
+ result= pthread_mutex_trylock(&that->m_mutex);
+#endif
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_MUTEX_CALL(end_mutex_wait)(locker, result);
+
+ return result;
}
#endif
+
+ /* Non instrumented code */
#ifdef SAFE_MUTEX
result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line);
+#elif defined(MY_PTHREAD_FASTMUTEX)
+ result= pthread_mutex_trylock(&that->m_mutex.mutex);
#else
result= pthread_mutex_trylock(&that->m_mutex);
#endif
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_mutex_wait(locker, result);
-#endif
+
return result;
}
@@ -664,27 +751,48 @@ static inline int inline_mysql_mutex_unlock(
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server && that->m_psi))
- PSI_server->unlock_mutex(that->m_psi);
+
+#ifdef HAVE_PSI_MUTEX_INTERFACE
+ if (that->m_psi != NULL)
+ PSI_MUTEX_CALL(unlock_mutex)(that->m_psi);
#endif
+
#ifdef SAFE_MUTEX
result= safe_mutex_unlock(&that->m_mutex, src_file, src_line);
+#elif defined(MY_PTHREAD_FASTMUTEX)
+ result= pthread_mutex_unlock(&that->m_mutex.mutex);
#else
result= pthread_mutex_unlock(&that->m_mutex);
#endif
+
return result;
}
+static inline void inline_mysql_rwlock_register(
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ const char *category,
+ PSI_rwlock_info *info,
+ int count
+#else
+ const char *category __attribute__ ((unused)),
+ void *info __attribute__ ((unused)),
+ int count __attribute__ ((unused))
+#endif
+)
+{
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ PSI_RWLOCK_CALL(register_rwlock)(category, info, count);
+#endif
+}
+
static inline int inline_mysql_rwlock_init(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
PSI_rwlock_key key,
#endif
mysql_rwlock_t *that)
{
-#ifdef HAVE_PSI_INTERFACE
- that->m_psi= (PSI_server ? PSI_server->init_rwlock(key, &that->m_rwlock)
- : NULL);
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ that->m_psi= PSI_RWLOCK_CALL(init_rwlock)(key, &that->m_rwlock);
#else
that->m_psi= NULL;
#endif
@@ -696,14 +804,13 @@ static inline int inline_mysql_rwlock_init(
#ifndef DISABLE_MYSQL_PRLOCK_H
static inline int inline_mysql_prlock_init(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
PSI_rwlock_key key,
#endif
mysql_prlock_t *that)
{
-#ifdef HAVE_PSI_INTERFACE
- that->m_psi= (PSI_server ? PSI_server->init_rwlock(key, &that->m_prlock)
- : NULL);
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ that->m_psi= PSI_RWLOCK_CALL(init_rwlock)(key, &that->m_prlock);
#else
that->m_psi= NULL;
#endif
@@ -714,10 +821,10 @@ static inline int inline_mysql_prlock_init(
static inline int inline_mysql_rwlock_destroy(
mysql_rwlock_t *that)
{
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server && that->m_psi))
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
{
- PSI_server->destroy_rwlock(that->m_psi);
+ PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi);
that->m_psi= NULL;
}
#endif
@@ -728,10 +835,10 @@ static inline int inline_mysql_rwlock_destroy(
static inline int inline_mysql_prlock_destroy(
mysql_prlock_t *that)
{
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server && that->m_psi))
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
{
- PSI_server->destroy_rwlock(that->m_psi);
+ PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi);
that->m_psi= NULL;
}
#endif
@@ -741,167 +848,215 @@ static inline int inline_mysql_prlock_destroy(
static inline int inline_mysql_rwlock_rdlock(
mysql_rwlock_t *that
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_rwlock_locker *locker= NULL;
- PSI_rwlock_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi,
- PSI_RWLOCK_READLOCK);
- if (likely(locker != NULL))
- PSI_server->start_rwlock_rdwait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_rwlock_locker *locker;
+ PSI_rwlock_locker_state state;
+ locker= PSI_RWLOCK_CALL(start_rwlock_rdwait)(&state, that->m_psi,
+ PSI_RWLOCK_READLOCK, src_file, src_line);
+
+ /* Instrumented code */
+ result= rw_rdlock(&that->m_rwlock);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, result);
+
+ return result;
}
#endif
+
+ /* Non instrumented code */
result= rw_rdlock(&that->m_rwlock);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_rwlock_rdwait(locker, result);
-#endif
+
return result;
}
#ifndef DISABLE_MYSQL_PRLOCK_H
static inline int inline_mysql_prlock_rdlock(
mysql_prlock_t *that
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_rwlock_locker *locker= NULL;
- PSI_rwlock_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi,
- PSI_RWLOCK_READLOCK);
- if (likely(locker != NULL))
- PSI_server->start_rwlock_rdwait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_rwlock_locker *locker;
+ PSI_rwlock_locker_state state;
+ locker= PSI_RWLOCK_CALL(start_rwlock_rdwait)(&state, that->m_psi,
+ PSI_RWLOCK_READLOCK, src_file, src_line);
+
+ /* Instrumented code */
+ result= rw_pr_rdlock(&that->m_prlock);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, result);
+
+ return result;
}
#endif
+
+ /* Non instrumented code */
result= rw_pr_rdlock(&that->m_prlock);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_rwlock_rdwait(locker, result);
-#endif
+
return result;
}
#endif
static inline int inline_mysql_rwlock_wrlock(
mysql_rwlock_t *that
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_rwlock_locker *locker= NULL;
- PSI_rwlock_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi,
- PSI_RWLOCK_WRITELOCK);
- if (likely(locker != NULL))
- PSI_server->start_rwlock_wrwait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_rwlock_locker *locker;
+ PSI_rwlock_locker_state state;
+ locker= PSI_RWLOCK_CALL(start_rwlock_wrwait)(&state, that->m_psi,
+ PSI_RWLOCK_WRITELOCK, src_file, src_line);
+
+ /* Instrumented code */
+ result= rw_wrlock(&that->m_rwlock);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_RWLOCK_CALL(end_rwlock_wrwait)(locker, result);
+
+ return result;
}
#endif
+
+ /* Non instrumented code */
result= rw_wrlock(&that->m_rwlock);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_rwlock_wrwait(locker, result);
-#endif
+
return result;
}
#ifndef DISABLE_MYSQL_PRLOCK_H
static inline int inline_mysql_prlock_wrlock(
mysql_prlock_t *that
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_rwlock_locker *locker= NULL;
- PSI_rwlock_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi,
- PSI_RWLOCK_WRITELOCK);
- if (likely(locker != NULL))
- PSI_server->start_rwlock_wrwait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_rwlock_locker *locker;
+ PSI_rwlock_locker_state state;
+ locker= PSI_RWLOCK_CALL(start_rwlock_wrwait)(&state, that->m_psi,
+ PSI_RWLOCK_WRITELOCK, src_file, src_line);
+
+ /* Instrumented code */
+ result= rw_pr_wrlock(&that->m_prlock);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_RWLOCK_CALL(end_rwlock_wrwait)(locker, result);
+
+ return result;
}
#endif
+
+ /* Non instrumented code */
result= rw_pr_wrlock(&that->m_prlock);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_rwlock_wrwait(locker, result);
-#endif
+
return result;
}
#endif
static inline int inline_mysql_rwlock_tryrdlock(
mysql_rwlock_t *that
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_rwlock_locker *locker= NULL;
- PSI_rwlock_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi,
- PSI_RWLOCK_TRYREADLOCK);
- if (likely(locker != NULL))
- PSI_server->start_rwlock_rdwait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_rwlock_locker *locker;
+ PSI_rwlock_locker_state state;
+ locker= PSI_RWLOCK_CALL(start_rwlock_rdwait)(&state, that->m_psi,
+ PSI_RWLOCK_TRYREADLOCK, src_file, src_line);
+
+ /* Instrumented code */
+ result= rw_tryrdlock(&that->m_rwlock);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, result);
+
+ return result;
}
#endif
+
+ /* Non instrumented code */
result= rw_tryrdlock(&that->m_rwlock);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_rwlock_rdwait(locker, result);
-#endif
+
return result;
}
static inline int inline_mysql_rwlock_trywrlock(
mysql_rwlock_t *that
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_rwlock_locker *locker= NULL;
- PSI_rwlock_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi,
- PSI_RWLOCK_TRYWRITELOCK);
- if (likely(locker != NULL))
- PSI_server->start_rwlock_wrwait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_rwlock_locker *locker;
+ PSI_rwlock_locker_state state;
+ locker= PSI_RWLOCK_CALL(start_rwlock_wrwait)(&state, that->m_psi,
+ PSI_RWLOCK_TRYWRITELOCK, src_file, src_line);
+
+ /* Instrumented code */
+ result= rw_trywrlock(&that->m_rwlock);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_RWLOCK_CALL(end_rwlock_wrwait)(locker, result);
+
+ return result;
}
#endif
+
+ /* Non instrumented code */
result= rw_trywrlock(&that->m_rwlock);
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_rwlock_wrwait(locker, result);
-#endif
+
return result;
}
@@ -909,9 +1064,9 @@ static inline int inline_mysql_rwlock_unlock(
mysql_rwlock_t *that)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server && that->m_psi))
- PSI_server->unlock_rwlock(that->m_psi);
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
+ PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi);
#endif
result= rw_unlock(&that->m_rwlock);
return result;
@@ -922,25 +1077,41 @@ static inline int inline_mysql_prlock_unlock(
mysql_prlock_t *that)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server && that->m_psi))
- PSI_server->unlock_rwlock(that->m_psi);
+#ifdef HAVE_PSI_RWLOCK_INTERFACE
+ if (that->m_psi != NULL)
+ PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi);
#endif
result= rw_pr_unlock(&that->m_prlock);
return result;
}
#endif
+static inline void inline_mysql_cond_register(
+#ifdef HAVE_PSI_COND_INTERFACE
+ const char *category,
+ PSI_cond_info *info,
+ int count
+#else
+ const char *category __attribute__ ((unused)),
+ void *info __attribute__ ((unused)),
+ int count __attribute__ ((unused))
+#endif
+)
+{
+#ifdef HAVE_PSI_COND_INTERFACE
+ PSI_COND_CALL(register_cond)(category, info, count);
+#endif
+}
+
static inline int inline_mysql_cond_init(
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_COND_INTERFACE
PSI_cond_key key,
#endif
mysql_cond_t *that,
const pthread_condattr_t *attr)
{
-#ifdef HAVE_PSI_INTERFACE
- that->m_psi= (PSI_server ? PSI_server->init_cond(key, &that->m_cond)
- : NULL);
+#ifdef HAVE_PSI_COND_INTERFACE
+ that->m_psi= PSI_COND_CALL(init_cond)(key, &that->m_cond);
#else
that->m_psi= NULL;
#endif
@@ -950,10 +1121,10 @@ static inline int inline_mysql_cond_init(
static inline int inline_mysql_cond_destroy(
mysql_cond_t *that)
{
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server && that->m_psi))
+#ifdef HAVE_PSI_COND_INTERFACE
+ if (that->m_psi != NULL)
{
- PSI_server->destroy_cond(that->m_psi);
+ PSI_COND_CALL(destroy_cond)(that->m_psi);
that->m_psi= NULL;
}
#endif
@@ -963,32 +1134,36 @@ static inline int inline_mysql_cond_destroy(
static inline int inline_mysql_cond_wait(
mysql_cond_t *that,
mysql_mutex_t *mutex
-#if defined(HAVE_PSI_INTERFACE) || defined(SAFE_MUTEX)
+#ifdef HAVE_PSI_COND_INTERFACE
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_cond_locker *locker= NULL;
- PSI_cond_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_COND_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_cond_locker(&state, that->m_psi, mutex->m_psi,
- PSI_COND_WAIT);
- if (likely(locker != NULL))
- PSI_server->start_cond_wait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_cond_locker *locker;
+ PSI_cond_locker_state state;
+ locker= PSI_COND_CALL(start_cond_wait)(&state, that->m_psi, mutex->m_psi,
+ PSI_COND_WAIT, src_file, src_line);
+
+ /* Instrumented code */
+ result= my_cond_wait(&that->m_cond, &mutex->m_mutex);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_COND_CALL(end_cond_wait)(locker, result);
+
+ return result;
}
#endif
-#ifdef SAFE_MUTEX
- result= safe_cond_wait(&that->m_cond, &mutex->m_mutex, src_file, src_line);
-#else
- result= pthread_cond_wait(&that->m_cond, &mutex->m_mutex);
-#endif
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_cond_wait(locker, result);
-#endif
+
+ /* Non instrumented code */
+ result= my_cond_wait(&that->m_cond, &mutex->m_mutex);
+
return result;
}
@@ -996,33 +1171,36 @@ static inline int inline_mysql_cond_timedwait(
mysql_cond_t *that,
mysql_mutex_t *mutex,
const struct timespec *abstime
-#if defined(HAVE_PSI_INTERFACE) || defined(SAFE_MUTEX)
+#ifdef HAVE_PSI_COND_INTERFACE
, const char *src_file, uint src_line
#endif
)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- struct PSI_cond_locker *locker= NULL;
- PSI_cond_locker_state state;
- if (likely(PSI_server && that->m_psi))
+
+#ifdef HAVE_PSI_COND_INTERFACE
+ if (that->m_psi != NULL)
{
- locker= PSI_server->get_thread_cond_locker(&state, that->m_psi, mutex->m_psi,
- PSI_COND_TIMEDWAIT);
- if (likely(locker != NULL))
- PSI_server->start_cond_wait(locker, src_file, src_line);
+ /* Instrumentation start */
+ PSI_cond_locker *locker;
+ PSI_cond_locker_state state;
+ locker= PSI_COND_CALL(start_cond_wait)(&state, that->m_psi, mutex->m_psi,
+ PSI_COND_TIMEDWAIT, src_file, src_line);
+
+ /* Instrumented code */
+ result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_COND_CALL(end_cond_wait)(locker, result);
+
+ return result;
}
#endif
-#ifdef SAFE_MUTEX
- result= safe_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime,
- src_file, src_line);
-#else
- result= pthread_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
-#endif
-#ifdef HAVE_PSI_INTERFACE
- if (likely(locker != NULL))
- PSI_server->end_cond_wait(locker, result);
-#endif
+
+ /* Non instrumented code */
+ result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
+
return result;
}
@@ -1030,9 +1208,9 @@ static inline int inline_mysql_cond_signal(
mysql_cond_t *that)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server && that->m_psi))
- PSI_server->signal_cond(that->m_psi);
+#ifdef HAVE_PSI_COND_INTERFACE
+ if (that->m_psi != NULL)
+ PSI_COND_CALL(signal_cond)(that->m_psi);
#endif
result= pthread_cond_signal(&that->m_cond);
return result;
@@ -1042,36 +1220,46 @@ static inline int inline_mysql_cond_broadcast(
mysql_cond_t *that)
{
int result;
-#ifdef HAVE_PSI_INTERFACE
- if (likely(PSI_server && that->m_psi))
- PSI_server->broadcast_cond(that->m_psi);
+#ifdef HAVE_PSI_COND_INTERFACE
+ if (that->m_psi != NULL)
+ PSI_COND_CALL(broadcast_cond)(that->m_psi);
#endif
result= pthread_cond_broadcast(&that->m_cond);
return result;
}
-#ifdef HAVE_PSI_INTERFACE
+static inline void inline_mysql_thread_register(
+#ifdef HAVE_PSI_THREAD_INTERFACE
+ const char *category,
+ PSI_thread_info *info,
+ int count
+#else
+ const char *category __attribute__ ((unused)),
+ void *info __attribute__ ((unused)),
+ int count __attribute__ ((unused))
+#endif
+)
+{
+#ifdef HAVE_PSI_THREAD_INTERFACE
+ PSI_THREAD_CALL(register_thread)(category, info, count);
+#endif
+}
+
+#ifdef HAVE_PSI_THREAD_INTERFACE
static inline int inline_mysql_thread_create(
PSI_thread_key key,
pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void*), void *arg)
{
int result;
- if (likely(PSI_server != NULL))
- result= PSI_server->spawn_thread(key, thread, attr, start_routine, arg);
- else
- result= pthread_create(thread, attr, start_routine, arg);
+ result= PSI_THREAD_CALL(spawn_thread)(key, thread, attr, start_routine, arg);
return result;
}
static inline void inline_mysql_thread_set_psi_id(ulong id)
{
- if (likely(PSI_server != NULL))
- {
- struct PSI_thread *psi= PSI_server->get_thread();
- if (likely(psi != NULL))
- PSI_server->set_thread_id(psi, id);
- }
+ struct PSI_thread *psi= PSI_THREAD_CALL(get_thread)();
+ PSI_THREAD_CALL(set_thread_id)(psi, id);
}
#endif
diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h
index 562e4a80fd5..3f43445e08a 100644
--- a/include/mysql/psi/psi.h
+++ b/include/mysql/psi/psi.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2015, 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
@@ -16,7 +16,20 @@
#ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
#define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
-#ifndef _global_h
+#ifdef EMBEDDED_LIBRARY
+#define DISABLE_PSI_MUTEX
+#define DISABLE_PSI_RWLOCK
+#define DISABLE_PSI_COND
+#define DISABLE_PSI_FILE
+#define DISABLE_PSI_TABLE
+#define DISABLE_PSI_SOCKET
+#define DISABLE_PSI_STAGE
+#define DISABLE_PSI_STATEMENT
+#define DISABLE_PSI_IDLE
+#define DISABLE_PSI_STATEMENT_DIGEST
+#endif /* EMBEDDED_LIBRARY */
+
+#ifndef MY_GLOBAL_INCLUDED
/*
Make sure a .c or .cc file contains an include to my_global.h first.
When this include is missing, all the #ifdef HAVE_XXX have no effect,
@@ -29,6 +42,10 @@
C_MODE_START
+struct TABLE_SHARE;
+
+struct sql_digest_storage;
+
/**
@file mysql/psi/psi.h
Performance schema instrumentation interface.
@@ -43,42 +60,84 @@ C_MODE_START
This is an opaque structure.
*/
struct PSI_mutex;
+typedef struct PSI_mutex PSI_mutex;
/**
Interface for an instrumented rwlock.
This is an opaque structure.
*/
struct PSI_rwlock;
+typedef struct PSI_rwlock PSI_rwlock;
/**
Interface for an instrumented condition.
This is an opaque structure.
*/
struct PSI_cond;
+typedef struct PSI_cond PSI_cond;
/**
Interface for an instrumented table share.
This is an opaque structure.
*/
struct PSI_table_share;
+typedef struct PSI_table_share PSI_table_share;
/**
Interface for an instrumented table handle.
This is an opaque structure.
*/
struct PSI_table;
+typedef struct PSI_table PSI_table;
/**
Interface for an instrumented thread.
This is an opaque structure.
*/
struct PSI_thread;
+typedef struct PSI_thread PSI_thread;
/**
Interface for an instrumented file handle.
This is an opaque structure.
*/
struct PSI_file;
+typedef struct PSI_file PSI_file;
+
+/**
+ Interface for an instrumented socket descriptor.
+ This is an opaque structure.
+*/
+struct PSI_socket;
+typedef struct PSI_socket PSI_socket;
+
+/**
+ Interface for an instrumented table operation.
+ This is an opaque structure.
+*/
+struct PSI_table_locker;
+typedef struct PSI_table_locker PSI_table_locker;
+
+/**
+ Interface for an instrumented statement.
+ This is an opaque structure.
+*/
+struct PSI_statement_locker;
+typedef struct PSI_statement_locker PSI_statement_locker;
+
+/**
+ Interface for an instrumented idle operation.
+ This is an opaque structure.
+*/
+struct PSI_idle_locker;
+typedef struct PSI_idle_locker PSI_idle_locker;
+
+/**
+ Interface for an instrumented statement digest operation.
+ This is an opaque structure.
+*/
+struct PSI_digest_locker;
+typedef struct PSI_digest_locker PSI_digest_locker;
/** Entry point for the performance schema interface. */
struct PSI_bootstrap
@@ -98,10 +157,134 @@ struct PSI_bootstrap
*/
void* (*get_interface)(int version);
};
+typedef struct PSI_bootstrap PSI_bootstrap;
#ifdef HAVE_PSI_INTERFACE
/**
+ @def DISABLE_PSI_MUTEX
+ Compiling option to disable the mutex instrumentation.
+ This option is mostly intended to be used during development,
+ when doing special builds with only a subset of the performance schema instrumentation,
+ for code analysis / profiling / performance tuning of a specific instrumentation alone.
+ For this reason, DISABLE_PSI_MUTEX is not advertised in the cmake general options.
+ To disable mutexes, add -DDISABLE_PSI_MUTEX to CFLAGS.
+ @sa DISABLE_PSI_RWLOCK
+ @sa DISABLE_PSI_COND
+ @sa DISABLE_PSI_FILE
+ @sa DISABLE_PSI_THREAD
+ @sa DISABLE_PSI_TABLE
+ @sa DISABLE_PSI_STAGE
+ @sa DISABLE_PSI_STATEMENT
+ @sa DISABLE_PSI_SOCKET
+ @sa DISABLE_PSI_IDLE
+*/
+
+#ifndef DISABLE_PSI_MUTEX
+#define HAVE_PSI_MUTEX_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_RWLOCK
+ Compiling option to disable the rwlock instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_RWLOCK
+#define HAVE_PSI_RWLOCK_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_COND
+ Compiling option to disable the cond instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_COND
+#define HAVE_PSI_COND_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_FILE
+ Compiling option to disable the file instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_FILE
+#define HAVE_PSI_FILE_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_THREAD
+ Compiling option to disable the thread instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+#ifndef DISABLE_PSI_THREAD
+#define HAVE_PSI_THREAD_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_TABLE
+ Compiling option to disable the table instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_TABLE
+#define HAVE_PSI_TABLE_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_STAGE
+ Compiling option to disable the stage instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_STAGE
+#define HAVE_PSI_STAGE_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_STATEMENT
+ Compiling option to disable the statement instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_STATEMENT
+#define HAVE_PSI_STATEMENT_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_STATEMENT_DIGEST
+ Compiling option to disable the statement digest instrumentation.
+*/
+
+#ifndef DISABLE_PSI_STATEMENT
+#ifndef DISABLE_PSI_STATEMENT_DIGEST
+#define HAVE_PSI_STATEMENT_DIGEST_INTERFACE
+#endif
+#endif
+
+/**
+ @def DISABLE_PSI_SOCKET
+ Compiling option to disable the statement instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_SOCKET
+#define HAVE_PSI_SOCKET_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_IDLE
+ Compiling option to disable the idle instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_IDLE
+#define HAVE_PSI_IDLE_INTERFACE
+#endif
+
+/**
@def PSI_VERSION_1
Performance Schema Interface number for version 1.
This version is supported.
@@ -133,25 +316,35 @@ struct PSI_bootstrap
This is an opaque structure.
*/
struct PSI_mutex_locker;
+typedef struct PSI_mutex_locker PSI_mutex_locker;
/**
Interface for an instrumented rwlock operation.
This is an opaque structure.
*/
-
struct PSI_rwlock_locker;
+typedef struct PSI_rwlock_locker PSI_rwlock_locker;
+
/**
Interface for an instrumented condition operation.
This is an opaque structure.
*/
-
struct PSI_cond_locker;
+typedef struct PSI_cond_locker PSI_cond_locker;
/**
Interface for an instrumented file operation.
This is an opaque structure.
*/
struct PSI_file_locker;
+typedef struct PSI_file_locker PSI_file_locker;
+
+/**
+ Interface for an instrumented socket operation.
+ This is an opaque structure.
+*/
+struct PSI_socket_locker;
+typedef struct PSI_socket_locker PSI_socket_locker;
/** Operation performed on an instrumented mutex. */
enum PSI_mutex_operation
@@ -161,6 +354,7 @@ enum PSI_mutex_operation
/** Lock attempt. */
PSI_MUTEX_TRYLOCK= 1
};
+typedef enum PSI_mutex_operation PSI_mutex_operation;
/** Operation performed on an instrumented rwlock. */
enum PSI_rwlock_operation
@@ -174,6 +368,7 @@ enum PSI_rwlock_operation
/** Write lock attempt. */
PSI_RWLOCK_TRYWRITELOCK= 3
};
+typedef enum PSI_rwlock_operation PSI_rwlock_operation;
/** Operation performed on an instrumented condition. */
enum PSI_cond_operation
@@ -183,6 +378,7 @@ enum PSI_cond_operation
/** Wait, with timeout. */
PSI_COND_TIMEDWAIT= 1
};
+typedef enum PSI_cond_operation PSI_cond_operation;
/** Operation performed on an instrumented file. */
enum PSI_file_operation
@@ -221,19 +417,84 @@ enum PSI_file_operation
PSI_FILE_FSTAT= 12,
/** File chsize, as in @c my_chsize(). */
PSI_FILE_CHSIZE= 13,
- /** File delete, such as @c my_delete() or @c my_delete_with_symlink(). */
+ /** File delete, such as @c my_delete() or @c my_handler_delete_with_symlink(). */
PSI_FILE_DELETE= 14,
/** File rename, such as @c my_rename() or @c my_rename_with_symlink(). */
PSI_FILE_RENAME= 15,
/** File sync, as in @c fsync() or @c my_sync(). */
PSI_FILE_SYNC= 16
};
+typedef enum PSI_file_operation PSI_file_operation;
-/**
- Interface for an instrumented table operation.
- This is an opaque structure.
-*/
-struct PSI_table_locker;
+/** IO operation performed on an instrumented table. */
+enum PSI_table_io_operation
+{
+ /** Row fetch. */
+ PSI_TABLE_FETCH_ROW= 0,
+ /** Row write. */
+ PSI_TABLE_WRITE_ROW= 1,
+ /** Row update. */
+ PSI_TABLE_UPDATE_ROW= 2,
+ /** Row delete. */
+ PSI_TABLE_DELETE_ROW= 3
+};
+typedef enum PSI_table_io_operation PSI_table_io_operation;
+
+/** Lock operation performed on an instrumented table. */
+enum PSI_table_lock_operation
+{
+ /** Table lock, in the server layer. */
+ PSI_TABLE_LOCK= 0,
+ /** Table lock, in the storage engine layer. */
+ PSI_TABLE_EXTERNAL_LOCK= 1
+};
+typedef enum PSI_table_lock_operation PSI_table_lock_operation;
+
+/** State of an instrumented socket. */
+enum PSI_socket_state
+{
+ /** Idle, waiting for the next command. */
+ PSI_SOCKET_STATE_IDLE= 1,
+ /** Active, executing a command. */
+ PSI_SOCKET_STATE_ACTIVE= 2
+};
+typedef enum PSI_socket_state PSI_socket_state;
+
+/** Operation performed on an instrumented socket. */
+enum PSI_socket_operation
+{
+ /** Socket creation, as in @c socket() or @c socketpair(). */
+ PSI_SOCKET_CREATE= 0,
+ /** Socket connection, as in @c connect(), @c listen() and @c accept(). */
+ PSI_SOCKET_CONNECT= 1,
+ /** Socket bind, as in @c bind(), @c getsockname() and @c getpeername(). */
+ PSI_SOCKET_BIND= 2,
+ /** Socket close, as in @c shutdown(). */
+ PSI_SOCKET_CLOSE= 3,
+ /** Socket send, @c send(). */
+ PSI_SOCKET_SEND= 4,
+ /** Socket receive, @c recv(). */
+ PSI_SOCKET_RECV= 5,
+ /** Socket send, @c sendto(). */
+ PSI_SOCKET_SENDTO= 6,
+ /** Socket receive, @c recvfrom). */
+ PSI_SOCKET_RECVFROM= 7,
+ /** Socket send, @c sendmsg(). */
+ PSI_SOCKET_SENDMSG= 8,
+ /** Socket receive, @c recvmsg(). */
+ PSI_SOCKET_RECVMSG= 9,
+ /** Socket seek, such as @c fseek() or @c seek(). */
+ PSI_SOCKET_SEEK= 10,
+ /** Socket options, as in @c getsockopt() and @c setsockopt(). */
+ PSI_SOCKET_OPT= 11,
+ /** Socket status, as in @c sockatmark() and @c isfdtype(). */
+ PSI_SOCKET_STAT= 12,
+ /** Socket shutdown, as in @c shutdown(). */
+ PSI_SOCKET_SHUTDOWN= 13,
+ /** Socket select, as in @c select() and @c poll(). */
+ PSI_SOCKET_SELECT= 14
+};
+typedef enum PSI_socket_operation PSI_socket_operation;
/**
Instrumented mutex key.
@@ -274,6 +535,27 @@ typedef unsigned int PSI_thread_key;
typedef unsigned int PSI_file_key;
/**
+ Instrumented stage key.
+ To instrument a stage, a stage key must be obtained using @c register_stage.
+ Using a zero key always disable the instrumentation.
+*/
+typedef unsigned int PSI_stage_key;
+
+/**
+ Instrumented statement key.
+ To instrument a statement, a statement key must be obtained using @c register_statement.
+ Using a zero key always disable the instrumentation.
+*/
+typedef unsigned int PSI_statement_key;
+
+/**
+ Instrumented socket key.
+ To instrument a socket, a socket key must be obtained using @c register_socket.
+ Using a zero key always disable the instrumentation.
+*/
+typedef unsigned int PSI_socket_key;
+
+/**
@def USE_PSI_1
Define USE_PSI_1 to use the interface version 1.
*/
@@ -300,6 +582,13 @@ typedef unsigned int PSI_file_key;
*/
#define PSI_FLAG_GLOBAL (1 << 0)
+/**
+ Global flag.
+ This flag indicate that an instrumentation point is a general placeholder,
+ that can mutate into a more specific instrumentation point.
+*/
+#define PSI_FLAG_MUTABLE (1 << 1)
+
#ifdef USE_PSI_1
#define HAVE_PSI_1
#endif
@@ -423,18 +712,95 @@ struct PSI_file_info_v1
};
/**
- State data storage for @c get_thread_mutex_locker_v1_t.
+ Stage instrument information.
+ @since PSI_VERSION_1
+ This structure is used to register an instrumented stage.
+*/
+struct PSI_stage_info_v1
+{
+ /** The registered stage key. */
+ PSI_stage_key m_key;
+ /** The name of the stage instrument to register. */
+ const char *m_name;
+ /** The flags of the stage instrument to register. */
+ int m_flags;
+};
+
+/**
+ Statement instrument information.
+ @since PSI_VERSION_1
+ This structure is used to register an instrumented statement.
+*/
+struct PSI_statement_info_v1
+{
+ /** The registered statement key. */
+ PSI_statement_key m_key;
+ /** The name of the statement instrument to register. */
+ const char *m_name;
+ /** The flags of the statement instrument to register. */
+ int m_flags;
+};
+
+/**
+ Socket instrument information.
+ @since PSI_VERSION_1
+ This structure is used to register an instrumented socket.
+*/
+struct PSI_socket_info_v1
+{
+ /**
+ Pointer to the key assigned to the registered socket.
+ */
+ PSI_socket_key *m_key;
+ /**
+ The name of the socket instrument to register.
+ */
+ const char *m_name;
+ /**
+ The flags of the socket instrument to register.
+ @sa PSI_FLAG_GLOBAL
+ */
+ int m_flags;
+};
+
+/**
+ State data storage for @c start_idle_wait_v1_t.
+ This structure provide temporary storage to an idle locker.
+ The content of this structure is considered opaque,
+ the fields are only hints of what an implementation
+ of the psi interface can use.
+ This memory is provided by the instrumented code for performance reasons.
+ @sa start_idle_wait_v1_t.
+*/
+struct PSI_idle_locker_state_v1
+{
+ /** Internal state. */
+ uint m_flags;
+ /** Current thread. */
+ struct PSI_thread *m_thread;
+ /** Timer start. */
+ ulonglong m_timer_start;
+ /** Timer function. */
+ ulonglong (*m_timer)(void);
+ /** Internal data. */
+ void *m_wait;
+};
+
+/**
+ State data storage for @c start_mutex_wait_v1_t.
This structure provide temporary storage to a mutex locker.
The content of this structure is considered opaque,
the fields are only hints of what an implementation
of the psi interface can use.
This memory is provided by the instrumented code for performance reasons.
- @sa get_thread_mutex_locker_v1_t
+ @sa start_mutex_wait_v1_t
*/
struct PSI_mutex_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current operation. */
+ enum PSI_mutex_operation m_operation;
/** Current mutex. */
struct PSI_mutex *m_mutex;
/** Current thread. */
@@ -443,29 +809,26 @@ struct PSI_mutex_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Current operation. */
- enum PSI_mutex_operation m_operation;
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
/** Internal data. */
void *m_wait;
};
/**
- State data storage for @c get_thread_rwlock_locker_v1_t.
+ State data storage for @c start_rwlock_rdwait_v1_t, @c start_rwlock_wrwait_v1_t.
This structure provide temporary storage to a rwlock locker.
The content of this structure is considered opaque,
the fields are only hints of what an implementation
of the psi interface can use.
This memory is provided by the instrumented code for performance reasons.
- @sa get_thread_rwlock_locker_v1_t
+ @sa start_rwlock_rdwait_v1_t
+ @sa start_rwlock_wrwait_v1_t
*/
struct PSI_rwlock_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current operation. */
+ enum PSI_rwlock_operation m_operation;
/** Current rwlock. */
struct PSI_rwlock *m_rwlock;
/** Current thread. */
@@ -474,29 +837,25 @@ struct PSI_rwlock_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Current operation. */
- enum PSI_rwlock_operation m_operation;
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
/** Internal data. */
void *m_wait;
};
/**
- State data storage for @c get_thread_cond_locker_v1_t.
+ State data storage for @c start_cond_wait_v1_t.
This structure provide temporary storage to a condition locker.
The content of this structure is considered opaque,
the fields are only hints of what an implementation
of the psi interface can use.
This memory is provided by the instrumented code for performance reasons.
- @sa get_thread_cond_locker_v1_t
+ @sa start_cond_wait_v1_t
*/
struct PSI_cond_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current operation. */
+ enum PSI_cond_operation m_operation;
/** Current condition. */
struct PSI_cond *m_cond;
/** Current mutex. */
@@ -507,12 +866,6 @@ struct PSI_cond_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Current operation. */
- enum PSI_cond_operation m_operation;
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
/** Internal data. */
void *m_wait;
};
@@ -532,8 +885,14 @@ struct PSI_file_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current operation. */
+ enum PSI_file_operation m_operation;
/** Current file. */
struct PSI_file *m_file;
+ /** Current file name. */
+ const char *m_name;
+ /** Current file class. */
+ void *m_class;
/** Current thread. */
struct PSI_thread *m_thread;
/** Operation number of bytes. */
@@ -542,33 +901,70 @@ struct PSI_file_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Current operation. */
- enum PSI_file_operation m_operation;
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
/** Internal data. */
void *m_wait;
};
/**
- State data storage for @c get_thread_table_locker_v1_t.
+ State data storage for @c start_table_io_wait_v1_t,
+ @c start_table_lock_wait_v1_t.
This structure provide temporary storage to a table locker.
The content of this structure is considered opaque,
the fields are only hints of what an implementation
of the psi interface can use.
This memory is provided by the instrumented code for performance reasons.
- @sa get_thread_table_locker_v1_t
+ @sa start_table_io_wait_v1_t
+ @sa start_table_lock_wait_v1_t
*/
struct PSI_table_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current io operation. */
+ enum PSI_table_io_operation m_io_operation;
/** Current table handle. */
struct PSI_table *m_table;
/** Current table share. */
struct PSI_table_share *m_table_share;
+ /** Current thread. */
+ struct PSI_thread *m_thread;
+ /** Timer start. */
+ ulonglong m_timer_start;
+ /** Timer function. */
+ ulonglong (*m_timer)(void);
+ /** Internal data. */
+ void *m_wait;
+ /**
+ Implementation specific.
+ For table io, the table io index.
+ For table lock, the lock type.
+ */
+ uint m_index;
+};
+
+/* Duplicate of NAME_LEN, to avoid dependency on mysql_com.h */
+#define PSI_SCHEMA_NAME_LEN (64 * 3)
+
+/**
+ State data storage for @c get_thread_statement_locker_v1_t,
+ @c get_thread_statement_locker_v1_t.
+ This structure provide temporary storage to a statement locker.
+ The content of this structure is considered opaque,
+ the fields are only hints of what an implementation
+ of the psi interface can use.
+ This memory is provided by the instrumented code for performance reasons.
+ @sa get_thread_statement_locker_v1_t
+*/
+struct PSI_statement_locker_state_v1
+{
+ /** Discarded flag. */
+ my_bool m_discarded;
+ /** Metric, no index used flag. */
+ uchar m_no_index_used;
+ /** Metric, no good index used flag. */
+ uchar m_no_good_index_used;
+ /** Internal state. */
+ uint m_flags;
/** Instrumentation class. */
void *m_class;
/** Current thread. */
@@ -577,12 +973,71 @@ struct PSI_table_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /* Current operation (waiting for WL#4895). */
- /* enum PSI_table_operation m_operation; */
- /** Current table io index. */
- uint m_index;
- /** Current table lock index. */
- uint m_lock_index;
+ /** Internal data. */
+ void *m_statement;
+ /** Locked time. */
+ ulonglong m_lock_time;
+ /** Rows sent. */
+ ulonglong m_rows_sent;
+ /** Rows examined. */
+ ulonglong m_rows_examined;
+ /** Metric, temporary tables created on disk. */
+ ulong m_created_tmp_disk_tables;
+ /** Metric, temporary tables created. */
+ ulong m_created_tmp_tables;
+ /** Metric, number of select full join. */
+ ulong m_select_full_join;
+ /** Metric, number of select full range join. */
+ ulong m_select_full_range_join;
+ /** Metric, number of select range. */
+ ulong m_select_range;
+ /** Metric, number of select range check. */
+ ulong m_select_range_check;
+ /** Metric, number of select scan. */
+ ulong m_select_scan;
+ /** Metric, number of sort merge passes. */
+ ulong m_sort_merge_passes;
+ /** Metric, number of sort merge. */
+ ulong m_sort_range;
+ /** Metric, number of sort rows. */
+ ulong m_sort_rows;
+ /** Metric, number of sort scans. */
+ ulong m_sort_scan;
+ /** Statement digest. */
+ const struct sql_digest_storage *m_digest;
+ /** Current schema name. */
+ char m_schema_name[PSI_SCHEMA_NAME_LEN];
+ /** Length in bytes of @c m_schema_name. */
+ uint m_schema_name_length;
+ /** Statement character set number. */
+ uint m_cs_number;
+};
+
+/**
+ State data storage for @c start_socket_wait_v1_t.
+ This structure provide temporary storage to a socket locker.
+ The content of this structure is considered opaque,
+ the fields are only hints of what an implementation
+ of the psi interface can use.
+ This memory is provided by the instrumented code for performance reasons.
+ @sa start_socket_wait_v1_t
+*/
+struct PSI_socket_locker_state_v1
+{
+ /** Internal state. */
+ uint m_flags;
+ /** Current socket. */
+ struct PSI_socket *m_socket;
+ /** Current thread. */
+ struct PSI_thread *m_thread;
+ /** Operation number of bytes. */
+ size_t m_number_of_bytes;
+ /** Timer start. */
+ ulonglong m_timer_start;
+ /** Timer function. */
+ ulonglong (*m_timer)(void);
+ /** Current operation. */
+ enum PSI_socket_operation m_operation;
/** Source file. */
const char* m_src_file;
/** Source line number. */
@@ -639,6 +1094,33 @@ typedef void (*register_file_v1_t)
(const char *category, struct PSI_file_info_v1 *info, int count);
/**
+ Stage registration API.
+ @param category a category name
+ @param info an array of stage info to register
+ @param count the size of the info array
+*/
+typedef void (*register_stage_v1_t)
+ (const char *category, struct PSI_stage_info_v1 **info, int count);
+
+/**
+ Statement registration API.
+ @param category a category name
+ @param info an array of stage info to register
+ @param count the size of the info array
+*/
+typedef void (*register_statement_v1_t)
+ (const char *category, struct PSI_statement_info_v1 *info, int count);
+
+/**
+ Socket registration API.
+ @param category a category name (typically a plugin name)
+ @param info an array of socket info to register
+ @param count the size of the info array
+*/
+typedef void (*register_socket_v1_t)
+ (const char *category, struct PSI_socket_info_v1 *info, int count);
+
+/**
Mutex instrumentation initialisation API.
@param key the registered mutex key
@param identity the address of the mutex itself
@@ -684,17 +1166,31 @@ typedef struct PSI_cond* (*init_cond_v1_t)
typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond);
/**
- Acquire a table info by name.
- @param schema_name name of the table schema
- @param schema_name_length length of schema_name
- @param table_name name of the table
- @param table_name_length length of table_name
- @param identity table identity pointer, typically the table share
- @return a table info, or NULL if the table is not instrumented
+ Socket instrumentation initialisation API.
+ @param key the registered mutex key
+ @param socket descriptor
+ @param addr the socket ip address
+ @param addr_len length of socket ip address
+ @return an instrumented socket
+*/
+typedef struct PSI_socket* (*init_socket_v1_t)
+ (PSI_socket_key key, const my_socket *fd,
+ const struct sockaddr *addr, socklen_t addr_len);
+
+/**
+ socket instrumentation destruction API.
+ @param socket the socket to destroy
+*/
+typedef void (*destroy_socket_v1_t)(struct PSI_socket *socket);
+
+/**
+ Acquire a table share instrumentation.
+ @param temporary True for temporary tables
+ @param share The SQL layer table share
+ @return a table share instrumentation, or NULL
*/
typedef struct PSI_table_share* (*get_table_share_v1_t)
- (const char *schema_name, int schema_name_length, const char *table_name,
- int table_name_length, const void *identity);
+ (my_bool temporary, struct TABLE_SHARE *share);
/**
Release a table share.
@@ -703,6 +1199,18 @@ typedef struct PSI_table_share* (*get_table_share_v1_t)
typedef void (*release_table_share_v1_t)(struct PSI_table_share *share);
/**
+ Drop a table share.
+ @param temporary True for temporary tables
+ @param schema_name the table schema name
+ @param schema_name_length the table schema name length
+ @param table_name the table name
+ @param table_name_length the table name length
+*/
+typedef void (*drop_table_share_v1_t)
+ (my_bool temporary, const char *schema_name, int schema_name_length,
+ const char *table_name, int table_name_length);
+
+/**
Open an instrumentation table handle.
@param share the table to open
@param identity table handle identity
@@ -712,6 +1220,23 @@ typedef struct PSI_table* (*open_table_v1_t)
(struct PSI_table_share *share, const void *identity);
/**
+ Unbind a table handle from the current thread.
+ This operation happens when an opened table is added to the open table cache.
+ @param table the table to unbind
+*/
+typedef void (*unbind_table_v1_t)
+ (struct PSI_table *table);
+
+/**
+ Rebind a table handle to the current thread.
+ This operation happens when a table from the open table cache
+ is reused for a thread.
+ @param table the table to unbind
+*/
+typedef PSI_table* (*rebind_table_v1_t)
+ (PSI_table_share *share, const void *identity, PSI_table *table);
+
+/**
Close an instrumentation table handle.
Note that the table handle is invalid after this call.
@param table the table handle to close
@@ -750,7 +1275,7 @@ typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
@return an instrumented thread
*/
typedef struct PSI_thread* (*new_thread_v1_t)
- (PSI_thread_key key, const void *identity, ulong thread_id);
+ (PSI_thread_key key, const void *identity, ulonglong thread_id);
/**
Assign an id to an instrumented thread.
@@ -758,7 +1283,7 @@ typedef struct PSI_thread* (*new_thread_v1_t)
@param id the id to assign
*/
typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
- unsigned long id);
+ ulonglong id);
/**
Get the instrumentation for the running thread.
@@ -770,65 +1295,70 @@ typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
typedef struct PSI_thread* (*get_thread_v1_t)(void);
/**
- Attach a thread instrumentation to the running thread.
- In case of thread pools, this method should be called when
- a worker thread picks a work item and runs it.
- Also, this method should be called if the instrumented code does not
- keep the pointer returned by @c new_thread() and relies on @c get_thread()
- instead.
- @param thread the thread instrumentation
+ Assign a user name to the instrumented thread.
+ @param user the user name
+ @param user_len the user name length
*/
-typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
+typedef void (*set_thread_user_v1_t)(const char *user, int user_len);
-/** Delete the current thread instrumentation. */
-typedef void (*delete_current_thread_v1_t)(void);
+/**
+ Assign a user name and host name to the instrumented thread.
+ @param user the user name
+ @param user_len the user name length
+ @param host the host name
+ @param host_len the host name length
+*/
+typedef void (*set_thread_user_host_v1_t)(const char *user, int user_len,
+ const char *host, int host_len);
-/** Delete a thread instrumentation. */
-typedef void (*delete_thread_v1_t)(struct PSI_thread *thread);
+/**
+ Assign a current database to the instrumented thread.
+ @param db the database name
+ @param db_len the database name length
+*/
+typedef void (*set_thread_db_v1_t)(const char* db, int db_len);
/**
- Get a mutex instrumentation locker.
- @param state data storage for the locker
- @param mutex the instrumented mutex to lock
- @return a mutex locker, or NULL
+ Assign a current command to the instrumented thread.
+ @param command the current command
*/
-typedef struct PSI_mutex_locker* (*get_thread_mutex_locker_v1_t)
- (struct PSI_mutex_locker_state_v1 *state,
- struct PSI_mutex *mutex,
- enum PSI_mutex_operation op);
+typedef void (*set_thread_command_v1_t)(int command);
/**
- Get a rwlock instrumentation locker.
- @param state data storage for the locker
- @param rwlock the instrumented rwlock to lock
- @return a rwlock locker, or NULL
+ Assign a start time to the instrumented thread.
+ @param start_time the thread start time
*/
-typedef struct PSI_rwlock_locker* (*get_thread_rwlock_locker_v1_t)
- (struct PSI_rwlock_locker_state_v1 *state,
- struct PSI_rwlock *rwlock,
- enum PSI_rwlock_operation op);
+typedef void (*set_thread_start_time_v1_t)(time_t start_time);
/**
- Get a cond instrumentation locker.
- @param state data storage for the locker
- @param cond the instrumented condition to wait on
- @param mutex the instrumented mutex associated with the condition
- @return a condition locker, or NULL
+ Assign a state to the instrumented thread.
+ @param state the thread state
*/
-typedef struct PSI_cond_locker* (*get_thread_cond_locker_v1_t)
- (struct PSI_cond_locker_state_v1 *state,
- struct PSI_cond *cond, struct PSI_mutex *mutex,
- enum PSI_cond_operation op);
+typedef void (*set_thread_state_v1_t)(const char* state);
/**
- Get a table instrumentation locker.
- @param state data storage for the locker
- @param table the instrumented table to lock
- @return a table locker, or NULL
+ Assign a process info to the instrumented thread.
+ @param info the process into string
+ @param info_len the process into string length
*/
-typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t)
- (struct PSI_table_locker_state_v1 *state,
- struct PSI_table *table);
+typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
+
+/**
+ Attach a thread instrumentation to the running thread.
+ In case of thread pools, this method should be called when
+ a worker thread picks a work item and runs it.
+ Also, this method should be called if the instrumented code does not
+ keep the pointer returned by @c new_thread() and relies on @c get_thread()
+ instead.
+ @param thread the thread instrumentation
+*/
+typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
+
+/** Delete the current thread instrumentation. */
+typedef void (*delete_current_thread_v1_t)(void);
+
+/** Delete a thread instrumentation. */
+typedef void (*delete_thread_v1_t)(struct PSI_thread *thread);
/**
Get a file instrumentation locker, for opening or creating a file.
@@ -894,12 +1424,26 @@ typedef void (*signal_cond_v1_t)
typedef void (*broadcast_cond_v1_t)
(struct PSI_cond *cond);
+typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
+ (struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
+
+typedef void (*end_idle_wait_v1_t)
+ (struct PSI_idle_locker *locker);
+
/**
Record a mutex instrumentation wait start event.
- @param locker a thread locker for the running thread
+ @param state data storage for the locker
+ @param mutex the instrumented mutex to lock
+ @param op the operation to perform
+ @param file the source file name
+ @param line the source line number
+ @return a mutex locker, or NULL
*/
-typedef void (*start_mutex_wait_v1_t)
- (struct PSI_mutex_locker *locker, const char *src_file, uint src_line);
+typedef struct PSI_mutex_locker* (*start_mutex_wait_v1_t)
+ (struct PSI_mutex_locker_state_v1 *state,
+ struct PSI_mutex *mutex,
+ enum PSI_mutex_operation op,
+ const char *src_file, uint src_line);
/**
Record a mutex instrumentation wait end event.
@@ -914,8 +1458,11 @@ typedef void (*end_mutex_wait_v1_t)
@param locker a thread locker for the running thread
@param must must block: 1 for lock, 0 for trylock
*/
-typedef void (*start_rwlock_rdwait_v1_t)
- (struct PSI_rwlock_locker *locker, const char *src_file, uint src_line);
+typedef struct PSI_rwlock_locker* (*start_rwlock_rdwait_v1_t)
+ (struct PSI_rwlock_locker_state_v1 *state,
+ struct PSI_rwlock *rwlock,
+ enum PSI_rwlock_operation op,
+ const char *src_file, uint src_line);
/**
Record a rwlock instrumentation read wait end event.
@@ -930,8 +1477,11 @@ typedef void (*end_rwlock_rdwait_v1_t)
@param locker a thread locker for the running thread
@param must must block: 1 for lock, 0 for trylock
*/
-typedef void (*start_rwlock_wrwait_v1_t)
- (struct PSI_rwlock_locker *locker, const char *src_file, uint src_line);
+typedef struct PSI_rwlock_locker* (*start_rwlock_wrwait_v1_t)
+ (struct PSI_rwlock_locker_state_v1 *state,
+ struct PSI_rwlock *rwlock,
+ enum PSI_rwlock_operation op,
+ const char *src_file, uint src_line);
/**
Record a rwlock instrumentation write wait end event.
@@ -946,8 +1496,12 @@ typedef void (*end_rwlock_wrwait_v1_t)
@param locker a thread locker for the running thread
@param must must block: 1 for wait, 0 for timedwait
*/
-typedef void (*start_cond_wait_v1_t)
- (struct PSI_cond_locker *locker, const char *src_file, uint src_line);
+typedef struct PSI_cond_locker* (*start_cond_wait_v1_t)
+ (struct PSI_cond_locker_state_v1 *state,
+ struct PSI_cond *cond,
+ struct PSI_mutex *mutex,
+ enum PSI_cond_operation op,
+ const char *src_file, uint src_line);
/**
Record a condition instrumentation wait end event.
@@ -958,19 +1512,42 @@ typedef void (*end_cond_wait_v1_t)
(struct PSI_cond_locker *locker, int rc);
/**
- Record a table instrumentation wait start event.
+ Record a table instrumentation io wait start event.
@param locker a table locker for the running thread
@param file the source file name
@param line the source line number
*/
-typedef void (*start_table_wait_v1_t)
- (struct PSI_table_locker *locker, const char *src_file, uint src_line);
+typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
+ (struct PSI_table_locker_state_v1 *state,
+ struct PSI_table *table,
+ enum PSI_table_io_operation op,
+ uint index,
+ const char *src_file, uint src_line);
/**
- Record a table instrumentation wait end event.
+ Record a table instrumentation io wait end event.
@param locker a table locker for the running thread
*/
-typedef void (*end_table_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
+
+/**
+ Record a table instrumentation lock wait start event.
+ @param locker a table locker for the running thread
+ @param file the source file name
+ @param line the source line number
+*/
+typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
+ (struct PSI_table_locker_state_v1 *state,
+ struct PSI_table *table,
+ enum PSI_table_lock_operation op,
+ ulong flags,
+ const char *src_file, uint src_line);
+
+/**
+ Record a table instrumentation lock wait end event.
+ @param locker a table locker for the running thread
+*/
+typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
/**
Start a file instrumentation open operation.
@@ -978,16 +1555,18 @@ typedef void (*end_table_wait_v1_t)(struct PSI_table_locker *locker);
@param op the operation to perform
@param src_file the source file name
@param src_line the source line number
- @return an instrumented file handle
*/
-typedef struct PSI_file* (*start_file_open_wait_v1_t)
+typedef void (*start_file_open_wait_v1_t)
(struct PSI_file_locker *locker, const char *src_file, uint src_line);
/**
End a file instrumentation open operation, for file streams.
@param locker the file locker.
+ @param result the opened file (NULL indicates failure, non NULL success).
+ @return an instrumented file handle
*/
-typedef void (*end_file_open_wait_v1_t)(struct PSI_file_locker *locker);
+typedef struct PSI_file* (*end_file_open_wait_v1_t)
+ (struct PSI_file_locker *locker, void *result);
/**
End a file instrumentation open operation, for non stream files.
@@ -1025,6 +1604,297 @@ typedef void (*end_file_wait_v1_t)
(struct PSI_file_locker *locker, size_t count);
/**
+ Start a file instrumentation close operation.
+ @param locker the file locker
+ @param op the operation to perform
+ @param src_file the source file name
+ @param src_line the source line number
+*/
+typedef void (*start_file_close_wait_v1_t)
+ (struct PSI_file_locker *locker, const char *src_file, uint src_line);
+
+/**
+ End a file instrumentation close operation.
+ @param locker the file locker.
+ @param rc the close operation return code (0 for success).
+ @return an instrumented file handle
+*/
+typedef void (*end_file_close_wait_v1_t)
+ (struct PSI_file_locker *locker, int rc);
+
+/**
+ Start a new stage, and implicitly end the previous stage.
+ @param key the key of the new stage
+ @param src_file the source file name
+ @param src_line the source line number
+*/
+typedef void (*start_stage_v1_t)
+ (PSI_stage_key key, const char *src_file, int src_line);
+
+/** End the current stage. */
+typedef void (*end_stage_v1_t) (void);
+
+/**
+ Get a statement instrumentation locker.
+ @param state data storage for the locker
+ @param key the statement instrumentation key
+ @param charset client character set
+ @return a statement locker, or NULL
+*/
+typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t)
+ (struct PSI_statement_locker_state_v1 *state,
+ PSI_statement_key key, const void *charset);
+
+/**
+ Refine a statement locker to a more specific key.
+ Note that only events declared mutable can be refined.
+ @param the statement locker for the current event
+ @param key the new key for the event
+ @sa PSI_FLAG_MUTABLE
+*/
+typedef struct PSI_statement_locker* (*refine_statement_v1_t)
+ (struct PSI_statement_locker *locker,
+ PSI_statement_key key);
+
+/**
+ Start a new statement event.
+ @param locker the statement locker for this event
+ @param db the active database name for this statement
+ @param db_length the active database name length for this statement
+ @param src_file source file name
+ @param src_line source line number
+*/
+typedef void (*start_statement_v1_t)
+ (struct PSI_statement_locker *locker,
+ const char *db, uint db_length,
+ const char *src_file, uint src_line);
+
+/**
+ Set the statement text for a statement event.
+ @param locker the current statement locker
+ @param text the statement text
+ @param text_len the statement text length
+*/
+typedef void (*set_statement_text_v1_t)
+ (struct PSI_statement_locker *locker,
+ const char *text, uint text_len);
+
+/**
+ Set a statement event lock time.
+ @param locker the statement locker
+ @param lock_time the locked time, in microseconds
+*/
+typedef void (*set_statement_lock_time_t)
+ (struct PSI_statement_locker *locker, ulonglong lock_time);
+
+/**
+ Set a statement event rows sent metric.
+ @param locker the statement locker
+ @param count the number of rows sent
+*/
+typedef void (*set_statement_rows_sent_t)
+ (struct PSI_statement_locker *locker, ulonglong count);
+
+/**
+ Set a statement event rows examined metric.
+ @param locker the statement locker
+ @param count the number of rows examined
+*/
+typedef void (*set_statement_rows_examined_t)
+ (struct PSI_statement_locker *locker, ulonglong count);
+
+/**
+ Increment a statement event "created tmp disk tables" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_created_tmp_disk_tables_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "created tmp tables" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_created_tmp_tables_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "select full join" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_select_full_join_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "select full range join" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_select_full_range_join_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "select range join" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_select_range_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "select range check" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_select_range_check_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "select scan" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_select_scan_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "sort merge passes" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_sort_merge_passes_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "sort range" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_sort_range_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "sort rows" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_sort_rows_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Increment a statement event "sort scan" metric.
+ @param locker the statement locker
+ @param count the metric increment value
+*/
+typedef void (*inc_statement_sort_scan_t)
+ (struct PSI_statement_locker *locker, ulong count);
+
+/**
+ Set a statement event "no index used" metric.
+ @param locker the statement locker
+ @param count the metric value
+*/
+typedef void (*set_statement_no_index_used_t)
+ (struct PSI_statement_locker *locker);
+
+/**
+ Set a statement event "no good index used" metric.
+ @param locker the statement locker
+ @param count the metric value
+*/
+typedef void (*set_statement_no_good_index_used_t)
+ (struct PSI_statement_locker *locker);
+
+/**
+ End a statement event.
+ @param locker the statement locker
+ @param stmt_da the statement diagnostics area.
+ @sa Diagnostics_area
+*/
+typedef void (*end_statement_v1_t)
+ (struct PSI_statement_locker *locker, void *stmt_da);
+
+/**
+ Record a socket instrumentation start event.
+ @param locker a socket locker for the running thread
+ @param op socket operation to be performed
+ @param count the number of bytes requested, or 0 if not applicable
+ @param src_file the source file name
+ @param src_line the source line number
+*/
+typedef struct PSI_socket_locker* (*start_socket_wait_v1_t)
+ (struct PSI_socket_locker_state_v1 *state,
+ struct PSI_socket *socket,
+ enum PSI_socket_operation op,
+ size_t count,
+ const char *src_file, uint src_line);
+
+/**
+ Record a socket instrumentation end event.
+ Note that for socket close operations, the instrumented socket handle
+ associated with the socket (which was provided to obtain a locker)
+ is invalid after this call.
+ @param locker a socket locker for the running thread
+ @param count the number of bytes actually used in the operation,
+ or 0 if not applicable, or -1 if the operation failed
+ @sa get_thread_socket_locker
+*/
+typedef void (*end_socket_wait_v1_t)
+ (struct PSI_socket_locker *locker, size_t count);
+
+/**
+ Set the socket state for an instrumented socket.
+ @param socket the instrumented socket
+ @param state socket state
+ */
+typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket,
+ enum PSI_socket_state state);
+
+/**
+ Set the socket info for an instrumented socket.
+ @param socket the instrumented socket
+ @param fd the socket descriptor
+ @param addr the socket ip address
+ @param addr_len length of socket ip address
+ @param thread_id associated thread id
+*/
+typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
+ const my_socket *fd,
+ const struct sockaddr *addr,
+ socklen_t addr_len);
+
+/**
+ Bind a socket to the thread that owns it.
+ @param socket instrumented socket
+*/
+typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
+
+/**
+ Get a digest locker for the current statement.
+ @param locker a statement locker for the running thread
+*/
+typedef struct PSI_digest_locker * (*digest_start_v1_t)
+ (struct PSI_statement_locker *locker);
+
+typedef void (*digest_end_v1_t)
+ (struct PSI_digest_locker *locker, const struct sql_digest_storage *digest);
+
+/**
+ Stores an array of connection attributes
+ @param buffer char array of length encoded connection attributes
+ in network format
+ @param length legnth of the data in buffer
+ @param from_cs charset in which @buffer is encodded
+ @return state
+ @retval non-0 attributes truncated
+ @retval 0 stored the attribute
+*/
+typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
+ const void *from_cs);
+
+/**
Performance Schema Interface, version 1.
@since PSI_VERSION_1
*/
@@ -1040,6 +1910,12 @@ struct PSI_v1
register_thread_v1_t register_thread;
/** @sa register_file_v1_t. */
register_file_v1_t register_file;
+ /** @sa register_stage_v1_t. */
+ register_stage_v1_t register_stage;
+ /** @sa register_statement_v1_t. */
+ register_statement_v1_t register_statement;
+ /** @sa register_socket_v1_t. */
+ register_socket_v1_t register_socket;
/** @sa init_mutex_v1_t. */
init_mutex_v1_t init_mutex;
/** @sa destroy_mutex_v1_t. */
@@ -1052,12 +1928,22 @@ struct PSI_v1
init_cond_v1_t init_cond;
/** @sa destroy_cond_v1_t. */
destroy_cond_v1_t destroy_cond;
+ /** @sa init_socket_v1_t. */
+ init_socket_v1_t init_socket;
+ /** @sa destroy_socket_v1_t. */
+ destroy_socket_v1_t destroy_socket;
/** @sa get_table_share_v1_t. */
get_table_share_v1_t get_table_share;
/** @sa release_table_share_v1_t. */
release_table_share_v1_t release_table_share;
+ /** @sa drop_table_share_v1_t. */
+ drop_table_share_v1_t drop_table_share;
/** @sa open_table_v1_t. */
open_table_v1_t open_table;
+ /** @sa unbind_table_v1_t. */
+ unbind_table_v1_t unbind_table;
+ /** @sa rebind_table_v1_t. */
+ rebind_table_v1_t rebind_table;
/** @sa close_table_v1_t. */
close_table_v1_t close_table;
/** @sa create_file_v1_t. */
@@ -1070,20 +1956,26 @@ struct PSI_v1
set_thread_id_v1_t set_thread_id;
/** @sa get_thread_v1_t. */
get_thread_v1_t get_thread;
+ /** @sa set_thread_user_v1_t. */
+ set_thread_user_v1_t set_thread_user;
+ /** @sa set_thread_user_host_v1_t. */
+ set_thread_user_host_v1_t set_thread_user_host;
+ /** @sa set_thread_db_v1_t. */
+ set_thread_db_v1_t set_thread_db;
+ /** @sa set_thread_command_v1_t. */
+ set_thread_command_v1_t set_thread_command;
+ /** @sa set_thread_start_time_v1_t. */
+ set_thread_start_time_v1_t set_thread_start_time;
+ /** @sa set_thread_state_v1_t. */
+ set_thread_state_v1_t set_thread_state;
+ /** @sa set_thread_info_v1_t. */
+ set_thread_info_v1_t set_thread_info;
/** @sa set_thread_v1_t. */
set_thread_v1_t set_thread;
/** @sa delete_current_thread_v1_t. */
delete_current_thread_v1_t delete_current_thread;
/** @sa delete_thread_v1_t. */
delete_thread_v1_t delete_thread;
- /** @sa get_thread_mutex_locker_v1_t. */
- get_thread_mutex_locker_v1_t get_thread_mutex_locker;
- /** @sa get_thread_rwlock_locker_v1_t. */
- get_thread_rwlock_locker_v1_t get_thread_rwlock_locker;
- /** @sa get_thread_cond_locker_v1_t. */
- get_thread_cond_locker_v1_t get_thread_cond_locker;
- /** @sa get_thread_table_locker_v1_t. */
- get_thread_table_locker_v1_t get_thread_table_locker;
/** @sa get_thread_file_name_locker_v1_t. */
get_thread_file_name_locker_v1_t get_thread_file_name_locker;
/** @sa get_thread_file_stream_locker_v1_t. */
@@ -1098,6 +1990,10 @@ struct PSI_v1
signal_cond_v1_t signal_cond;
/** @sa broadcast_cond_v1_t. */
broadcast_cond_v1_t broadcast_cond;
+ /** @sa start_idle_wait_v1_t. */
+ start_idle_wait_v1_t start_idle_wait;
+ /** @sa end_idle_wait_v1_t. */
+ end_idle_wait_v1_t end_idle_wait;
/** @sa start_mutex_wait_v1_t. */
start_mutex_wait_v1_t start_mutex_wait;
/** @sa end_mutex_wait_v1_t. */
@@ -1114,10 +2010,14 @@ struct PSI_v1
start_cond_wait_v1_t start_cond_wait;
/** @sa end_cond_wait_v1_t. */
end_cond_wait_v1_t end_cond_wait;
- /** @sa start_table_wait_v1_t. */
- start_table_wait_v1_t start_table_wait;
- /** @sa end_table_wait_v1_t. */
- end_table_wait_v1_t end_table_wait;
+ /** @sa start_table_io_wait_v1_t. */
+ start_table_io_wait_v1_t start_table_io_wait;
+ /** @sa end_table_io_wait_v1_t. */
+ end_table_io_wait_v1_t end_table_io_wait;
+ /** @sa start_table_lock_wait_v1_t. */
+ start_table_lock_wait_v1_t start_table_lock_wait;
+ /** @sa end_table_lock_wait_v1_t. */
+ end_table_lock_wait_v1_t end_table_lock_wait;
/** @sa start_file_open_wait_v1_t. */
start_file_open_wait_v1_t start_file_open_wait;
/** @sa end_file_open_wait_v1_t. */
@@ -1129,6 +2029,72 @@ struct PSI_v1
start_file_wait_v1_t start_file_wait;
/** @sa end_file_wait_v1_t. */
end_file_wait_v1_t end_file_wait;
+ /** @sa start_file_close_wait_v1_t. */
+ start_file_close_wait_v1_t start_file_close_wait;
+ /** @sa end_file_close_wait_v1_t. */
+ end_file_close_wait_v1_t end_file_close_wait;
+ /** @sa start_stage_v1_t. */
+ start_stage_v1_t start_stage;
+ /** @sa end_stage_v1_t. */
+ end_stage_v1_t end_stage;
+ /** @sa get_thread_statement_locker_v1_t. */
+ get_thread_statement_locker_v1_t get_thread_statement_locker;
+ /** @sa refine_statement_v1_t. */
+ refine_statement_v1_t refine_statement;
+ /** @sa start_statement_v1_t. */
+ start_statement_v1_t start_statement;
+ /** @sa set_statement_text_v1_t. */
+ set_statement_text_v1_t set_statement_text;
+ /** @sa set_statement_lock_time_t. */
+ set_statement_lock_time_t set_statement_lock_time;
+ /** @sa set_statement_rows_sent_t. */
+ set_statement_rows_sent_t set_statement_rows_sent;
+ /** @sa set_statement_rows_examined_t. */
+ set_statement_rows_examined_t set_statement_rows_examined;
+ /** @sa inc_statement_created_tmp_disk_tables. */
+ inc_statement_created_tmp_disk_tables_t inc_statement_created_tmp_disk_tables;
+ /** @sa inc_statement_created_tmp_tables. */
+ inc_statement_created_tmp_tables_t inc_statement_created_tmp_tables;
+ /** @sa inc_statement_select_full_join. */
+ inc_statement_select_full_join_t inc_statement_select_full_join;
+ /** @sa inc_statement_select_full_range_join. */
+ inc_statement_select_full_range_join_t inc_statement_select_full_range_join;
+ /** @sa inc_statement_select_range. */
+ inc_statement_select_range_t inc_statement_select_range;
+ /** @sa inc_statement_select_range_check. */
+ inc_statement_select_range_check_t inc_statement_select_range_check;
+ /** @sa inc_statement_select_scan. */
+ inc_statement_select_scan_t inc_statement_select_scan;
+ /** @sa inc_statement_sort_merge_passes. */
+ inc_statement_sort_merge_passes_t inc_statement_sort_merge_passes;
+ /** @sa inc_statement_sort_range. */
+ inc_statement_sort_range_t inc_statement_sort_range;
+ /** @sa inc_statement_sort_rows. */
+ inc_statement_sort_rows_t inc_statement_sort_rows;
+ /** @sa inc_statement_sort_scan. */
+ inc_statement_sort_scan_t inc_statement_sort_scan;
+ /** @sa set_statement_no_index_used. */
+ set_statement_no_index_used_t set_statement_no_index_used;
+ /** @sa set_statement_no_good_index_used. */
+ set_statement_no_good_index_used_t set_statement_no_good_index_used;
+ /** @sa end_statement_v1_t. */
+ end_statement_v1_t end_statement;
+ /** @sa start_socket_wait_v1_t. */
+ start_socket_wait_v1_t start_socket_wait;
+ /** @sa end_socket_wait_v1_t. */
+ end_socket_wait_v1_t end_socket_wait;
+ /** @sa set_socket_state_v1_t. */
+ set_socket_state_v1_t set_socket_state;
+ /** @sa set_socket_info_v1_t. */
+ set_socket_info_v1_t set_socket_info;
+ /** @sa set_socket_thread_owner_v1_t. */
+ set_socket_thread_owner_v1_t set_socket_thread_owner;
+ /** @sa digest_start_v1_t. */
+ digest_start_v1_t digest_start;
+ /** @sa digest_end_v1_t. */
+ digest_end_v1_t digest_end;
+ /** @sa set_thread_connect_attrs_v1_t. */
+ set_thread_connect_attrs_v1_t set_thread_connect_attrs;
};
/** @} (end of group Group_PSI_v1) */
@@ -1194,36 +2160,76 @@ struct PSI_file_info_v2
int placeholder;
};
+/** Placeholder */
+struct PSI_stage_info_v2
+{
+ /** Placeholder */
+ int placeholder;
+};
+
+/** Placeholder */
+struct PSI_statement_info_v2
+{
+ /** Placeholder */
+ int placeholder;
+};
+
+/** Placeholder */
+struct PSI_idle_locker_state_v2
+{
+ /** Placeholder */
+ int placeholder;
+};
+
+/** Placeholder */
struct PSI_mutex_locker_state_v2
{
/** Placeholder */
int placeholder;
};
+/** Placeholder */
struct PSI_rwlock_locker_state_v2
{
/** Placeholder */
int placeholder;
};
+/** Placeholder */
struct PSI_cond_locker_state_v2
{
/** Placeholder */
int placeholder;
};
+/** Placeholder */
struct PSI_file_locker_state_v2
{
/** Placeholder */
int placeholder;
};
+/** Placeholder */
struct PSI_table_locker_state_v2
{
/** Placeholder */
int placeholder;
};
+/** Placeholder */
+struct PSI_statement_locker_state_v2
+{
+ /** Placeholder */
+ int placeholder;
+};
+
+/** Placeholder */
+struct PSI_socket_locker_state_v2
+{
+ /** Placeholder */
+ int placeholder;
+};
+
/** @} (end of group Group_PSI_v2) */
#endif /* HAVE_PSI_2 */
@@ -1267,11 +2273,17 @@ typedef struct PSI_rwlock_info_v1 PSI_rwlock_info;
typedef struct PSI_cond_info_v1 PSI_cond_info;
typedef struct PSI_thread_info_v1 PSI_thread_info;
typedef struct PSI_file_info_v1 PSI_file_info;
+typedef struct PSI_stage_info_v1 PSI_stage_info;
+typedef struct PSI_statement_info_v1 PSI_statement_info;
+typedef struct PSI_socket_info_v1 PSI_socket_info;
+typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
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;
#endif
#ifdef USE_PSI_2
@@ -1281,11 +2293,17 @@ typedef struct PSI_rwlock_info_v2 PSI_rwlock_info;
typedef struct PSI_cond_info_v2 PSI_cond_info;
typedef struct PSI_thread_info_v2 PSI_thread_info;
typedef struct PSI_file_info_v2 PSI_file_info;
+typedef struct PSI_stage_info_v2 PSI_stage_info;
+typedef struct PSI_statement_info_v2 PSI_statement_info;
+typedef struct PSI_socket_info_v2 PSI_socket_info;
+typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
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;
#endif
#else /* HAVE_PSI_INTERFACE */
@@ -1301,10 +2319,88 @@ struct PSI_none
};
typedef struct PSI_none PSI;
+/**
+ Stage instrument information.
+ @since PSI_VERSION_1
+ This structure is used to register an instrumented stage.
+*/
+struct PSI_stage_info_none
+{
+ /** Unused stage key. */
+ unsigned int m_key;
+ /** The name of the stage instrument. */
+ const char *m_name;
+ /** Unused stage flags. */
+ int m_flags;
+};
+
+/**
+ The stage instrumentation has to co exist with the legacy
+ THD::set_proc_info instrumentation.
+ To avoid duplication of the instrumentation in the server,
+ the common PSI_stage_info structure is used,
+ so we export it here, even when not building
+ with HAVE_PSI_INTERFACE.
+*/
+typedef struct PSI_stage_info_none PSI_stage_info;
+
#endif /* HAVE_PSI_INTERFACE */
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
+/*
+ Allow to override PSI_XXX_CALL at compile time
+ with more efficient implementations, if available.
+ If nothing better is available,
+ make a dynamic call using the PSI_server function pointer.
+*/
+
+#ifndef PSI_MUTEX_CALL
+#define PSI_MUTEX_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_RWLOCK_CALL
+#define PSI_RWLOCK_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_COND_CALL
+#define PSI_COND_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_THREAD_CALL
+#define PSI_THREAD_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_FILE_CALL
+#define PSI_FILE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_SOCKET_CALL
+#define PSI_SOCKET_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_STAGE_CALL
+#define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_STATEMENT_CALL
+#define PSI_STATEMENT_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_DIGEST_CALL
+#define PSI_DIGEST_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_TABLE_CALL
+#define PSI_TABLE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_IDLE_CALL
+#define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#define PSI_DYNAMIC_CALL(M) PSI_server->M
+
/** @} */
C_MODE_END
diff --git a/include/mysql/psi/psi_abi_v0.h b/include/mysql/psi/psi_abi_v0.h
new file mode 100644
index 00000000000..c896f15a532
--- /dev/null
+++ b/include/mysql/psi/psi_abi_v0.h
@@ -0,0 +1,24 @@
+/* Copyright (c) 2011, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+/**
+ @file mysql/psi/psi_abi_v0.h
+ ABI check for mysql/psi/psi.h, when compiling without instrumentation.
+ This file is only used to automate detection of changes between versions.
+ Do not include this file, include mysql/psi/psi.h instead.
+*/
+#define MY_GLOBAL_INCLUDED
+#include "mysql/psi/psi.h"
+
diff --git a/include/mysql/psi/psi_abi_v0.h.pp b/include/mysql/psi/psi_abi_v0.h.pp
new file mode 100644
index 00000000000..17d61016a68
--- /dev/null
+++ b/include/mysql/psi/psi_abi_v0.h.pp
@@ -0,0 +1,47 @@
+#include "mysql/psi/psi.h"
+C_MODE_START
+struct TABLE_SHARE;
+struct sql_digest_storage;
+struct PSI_mutex;
+typedef struct PSI_mutex PSI_mutex;
+struct PSI_rwlock;
+typedef struct PSI_rwlock PSI_rwlock;
+struct PSI_cond;
+typedef struct PSI_cond PSI_cond;
+struct PSI_table_share;
+typedef struct PSI_table_share PSI_table_share;
+struct PSI_table;
+typedef struct PSI_table PSI_table;
+struct PSI_thread;
+typedef struct PSI_thread PSI_thread;
+struct PSI_file;
+typedef struct PSI_file PSI_file;
+struct PSI_socket;
+typedef struct PSI_socket PSI_socket;
+struct PSI_table_locker;
+typedef struct PSI_table_locker PSI_table_locker;
+struct PSI_statement_locker;
+typedef struct PSI_statement_locker PSI_statement_locker;
+struct PSI_idle_locker;
+typedef struct PSI_idle_locker PSI_idle_locker;
+struct PSI_digest_locker;
+typedef struct PSI_digest_locker PSI_digest_locker;
+struct PSI_bootstrap
+{
+ void* (*get_interface)(int version);
+};
+typedef struct PSI_bootstrap PSI_bootstrap;
+struct PSI_none
+{
+ int opaque;
+};
+typedef struct PSI_none PSI;
+struct PSI_stage_info_none
+{
+ unsigned int m_key;
+ const char *m_name;
+ int m_flags;
+};
+typedef struct PSI_stage_info_none PSI_stage_info;
+extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
+C_MODE_END
diff --git a/include/mysql/psi/psi_abi_v1.h b/include/mysql/psi/psi_abi_v1.h
index 0f62291696f..54c49f0c518 100644
--- a/include/mysql/psi/psi_abi_v1.h
+++ b/include/mysql/psi/psi_abi_v1.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2011, 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
@@ -21,6 +21,6 @@
*/
#define USE_PSI_1
#define HAVE_PSI_INTERFACE
-#define _global_h
+#define MY_GLOBAL_INCLUDED
#include "mysql/psi/psi.h"
diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp
index 9f8252473a6..17ac0271da2 100644
--- a/include/mysql/psi/psi_abi_v1.h.pp
+++ b/include/mysql/psi/psi_abi_v1.h.pp
@@ -1,24 +1,51 @@
C_MODE_START
+struct TABLE_SHARE;
+struct sql_digest_storage;
struct PSI_mutex;
+typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
+typedef struct PSI_rwlock PSI_rwlock;
struct PSI_cond;
+typedef struct PSI_cond PSI_cond;
struct PSI_table_share;
+typedef struct PSI_table_share PSI_table_share;
struct PSI_table;
+typedef struct PSI_table PSI_table;
struct PSI_thread;
+typedef struct PSI_thread PSI_thread;
struct PSI_file;
+typedef struct PSI_file PSI_file;
+struct PSI_socket;
+typedef struct PSI_socket PSI_socket;
+struct PSI_table_locker;
+typedef struct PSI_table_locker PSI_table_locker;
+struct PSI_statement_locker;
+typedef struct PSI_statement_locker PSI_statement_locker;
+struct PSI_idle_locker;
+typedef struct PSI_idle_locker PSI_idle_locker;
+struct PSI_digest_locker;
+typedef struct PSI_digest_locker PSI_digest_locker;
struct PSI_bootstrap
{
void* (*get_interface)(int version);
};
+typedef struct PSI_bootstrap PSI_bootstrap;
struct PSI_mutex_locker;
+typedef struct PSI_mutex_locker PSI_mutex_locker;
struct PSI_rwlock_locker;
+typedef struct PSI_rwlock_locker PSI_rwlock_locker;
struct PSI_cond_locker;
+typedef struct PSI_cond_locker PSI_cond_locker;
struct PSI_file_locker;
+typedef struct PSI_file_locker PSI_file_locker;
+struct PSI_socket_locker;
+typedef struct PSI_socket_locker PSI_socket_locker;
enum PSI_mutex_operation
{
PSI_MUTEX_LOCK= 0,
PSI_MUTEX_TRYLOCK= 1
};
+typedef enum PSI_mutex_operation PSI_mutex_operation;
enum PSI_rwlock_operation
{
PSI_RWLOCK_READLOCK= 0,
@@ -26,11 +53,13 @@ enum PSI_rwlock_operation
PSI_RWLOCK_TRYREADLOCK= 2,
PSI_RWLOCK_TRYWRITELOCK= 3
};
+typedef enum PSI_rwlock_operation PSI_rwlock_operation;
enum PSI_cond_operation
{
PSI_COND_WAIT= 0,
PSI_COND_TIMEDWAIT= 1
};
+typedef enum PSI_cond_operation PSI_cond_operation;
enum PSI_file_operation
{
PSI_FILE_CREATE= 0,
@@ -51,12 +80,54 @@ enum PSI_file_operation
PSI_FILE_RENAME= 15,
PSI_FILE_SYNC= 16
};
-struct PSI_table_locker;
+typedef enum PSI_file_operation PSI_file_operation;
+enum PSI_table_io_operation
+{
+ PSI_TABLE_FETCH_ROW= 0,
+ PSI_TABLE_WRITE_ROW= 1,
+ PSI_TABLE_UPDATE_ROW= 2,
+ PSI_TABLE_DELETE_ROW= 3
+};
+typedef enum PSI_table_io_operation PSI_table_io_operation;
+enum PSI_table_lock_operation
+{
+ PSI_TABLE_LOCK= 0,
+ PSI_TABLE_EXTERNAL_LOCK= 1
+};
+typedef enum PSI_table_lock_operation PSI_table_lock_operation;
+enum PSI_socket_state
+{
+ PSI_SOCKET_STATE_IDLE= 1,
+ PSI_SOCKET_STATE_ACTIVE= 2
+};
+typedef enum PSI_socket_state PSI_socket_state;
+enum PSI_socket_operation
+{
+ PSI_SOCKET_CREATE= 0,
+ PSI_SOCKET_CONNECT= 1,
+ PSI_SOCKET_BIND= 2,
+ PSI_SOCKET_CLOSE= 3,
+ PSI_SOCKET_SEND= 4,
+ PSI_SOCKET_RECV= 5,
+ PSI_SOCKET_SENDTO= 6,
+ PSI_SOCKET_RECVFROM= 7,
+ PSI_SOCKET_SENDMSG= 8,
+ PSI_SOCKET_RECVMSG= 9,
+ PSI_SOCKET_SEEK= 10,
+ PSI_SOCKET_OPT= 11,
+ PSI_SOCKET_STAT= 12,
+ PSI_SOCKET_SHUTDOWN= 13,
+ PSI_SOCKET_SELECT= 14
+};
+typedef enum PSI_socket_operation PSI_socket_operation;
typedef unsigned int PSI_mutex_key;
typedef unsigned int PSI_rwlock_key;
typedef unsigned int PSI_cond_key;
typedef unsigned int PSI_thread_key;
typedef unsigned int PSI_file_key;
+typedef unsigned int PSI_stage_key;
+typedef unsigned int PSI_statement_key;
+typedef unsigned int PSI_socket_key;
struct PSI_mutex_info_v1
{
PSI_mutex_key *m_key;
@@ -87,67 +158,127 @@ struct PSI_file_info_v1
const char *m_name;
int m_flags;
};
+struct PSI_stage_info_v1
+{
+ PSI_stage_key m_key;
+ const char *m_name;
+ int m_flags;
+};
+struct PSI_statement_info_v1
+{
+ PSI_statement_key m_key;
+ const char *m_name;
+ int m_flags;
+};
+struct PSI_socket_info_v1
+{
+ PSI_socket_key *m_key;
+ const char *m_name;
+ int m_flags;
+};
+struct PSI_idle_locker_state_v1
+{
+ uint m_flags;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_wait;
+};
struct PSI_mutex_locker_state_v1
{
uint m_flags;
+ enum PSI_mutex_operation m_operation;
struct PSI_mutex *m_mutex;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- enum PSI_mutex_operation m_operation;
- const char* m_src_file;
- int m_src_line;
void *m_wait;
};
struct PSI_rwlock_locker_state_v1
{
uint m_flags;
+ enum PSI_rwlock_operation m_operation;
struct PSI_rwlock *m_rwlock;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- enum PSI_rwlock_operation m_operation;
- const char* m_src_file;
- int m_src_line;
void *m_wait;
};
struct PSI_cond_locker_state_v1
{
uint m_flags;
+ enum PSI_cond_operation m_operation;
struct PSI_cond *m_cond;
struct PSI_mutex *m_mutex;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- enum PSI_cond_operation m_operation;
- const char* m_src_file;
- int m_src_line;
void *m_wait;
};
struct PSI_file_locker_state_v1
{
uint m_flags;
+ enum PSI_file_operation m_operation;
struct PSI_file *m_file;
+ const char *m_name;
+ void *m_class;
struct PSI_thread *m_thread;
size_t m_number_of_bytes;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- enum PSI_file_operation m_operation;
- const char* m_src_file;
- int m_src_line;
void *m_wait;
};
struct PSI_table_locker_state_v1
{
uint m_flags;
+ enum PSI_table_io_operation m_io_operation;
struct PSI_table *m_table;
struct PSI_table_share *m_table_share;
- void *m_class;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
+ void *m_wait;
uint m_index;
- uint m_lock_index;
+};
+struct PSI_statement_locker_state_v1
+{
+ my_bool m_discarded;
+ uchar m_no_index_used;
+ uchar m_no_good_index_used;
+ uint m_flags;
+ void *m_class;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_statement;
+ ulonglong m_lock_time;
+ ulonglong m_rows_sent;
+ ulonglong m_rows_examined;
+ ulong m_created_tmp_disk_tables;
+ ulong m_created_tmp_tables;
+ ulong m_select_full_join;
+ ulong m_select_full_range_join;
+ ulong m_select_range;
+ ulong m_select_range_check;
+ ulong m_select_scan;
+ ulong m_sort_merge_passes;
+ ulong m_sort_range;
+ ulong m_sort_rows;
+ ulong m_sort_scan;
+ const struct sql_digest_storage *m_digest;
+ char m_schema_name[(64 * 3)];
+ uint m_schema_name_length;
+ uint m_cs_number;
+};
+struct PSI_socket_locker_state_v1
+{
+ uint m_flags;
+ struct PSI_socket *m_socket;
+ struct PSI_thread *m_thread;
+ size_t m_number_of_bytes;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ enum PSI_socket_operation m_operation;
const char* m_src_file;
int m_src_line;
void *m_wait;
@@ -162,6 +293,12 @@ typedef void (*register_thread_v1_t)
(const char *category, struct PSI_thread_info_v1 *info, int count);
typedef void (*register_file_v1_t)
(const char *category, struct PSI_file_info_v1 *info, int count);
+typedef void (*register_stage_v1_t)
+ (const char *category, struct PSI_stage_info_v1 **info, int count);
+typedef void (*register_statement_v1_t)
+ (const char *category, struct PSI_statement_info_v1 *info, int count);
+typedef void (*register_socket_v1_t)
+ (const char *category, struct PSI_socket_info_v1 *info, int count);
typedef struct PSI_mutex* (*init_mutex_v1_t)
(PSI_mutex_key key, const void *identity);
typedef void (*destroy_mutex_v1_t)(struct PSI_mutex *mutex);
@@ -171,12 +308,22 @@ typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock);
typedef struct PSI_cond* (*init_cond_v1_t)
(PSI_cond_key key, const void *identity);
typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond);
+typedef struct PSI_socket* (*init_socket_v1_t)
+ (PSI_socket_key key, const my_socket *fd,
+ const struct sockaddr *addr, socklen_t addr_len);
+typedef void (*destroy_socket_v1_t)(struct PSI_socket *socket);
typedef struct PSI_table_share* (*get_table_share_v1_t)
- (const char *schema_name, int schema_name_length, const char *table_name,
- int table_name_length, const void *identity);
+ (my_bool temporary, struct TABLE_SHARE *share);
typedef void (*release_table_share_v1_t)(struct PSI_table_share *share);
+typedef void (*drop_table_share_v1_t)
+ (my_bool temporary, const char *schema_name, int schema_name_length,
+ const char *table_name, int table_name_length);
typedef struct PSI_table* (*open_table_v1_t)
(struct PSI_table_share *share, const void *identity);
+typedef void (*unbind_table_v1_t)
+ (struct PSI_table *table);
+typedef PSI_table* (*rebind_table_v1_t)
+ (PSI_table_share *share, const void *identity, PSI_table *table);
typedef void (*close_table_v1_t)(struct PSI_table *table);
typedef void (*create_file_v1_t)(PSI_file_key key, const char *name,
File file);
@@ -185,28 +332,21 @@ typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
const pthread_attr_t *attr,
void *(*start_routine)(void*), void *arg);
typedef struct PSI_thread* (*new_thread_v1_t)
- (PSI_thread_key key, const void *identity, ulong thread_id);
+ (PSI_thread_key key, const void *identity, ulonglong thread_id);
typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
- unsigned long id);
+ ulonglong id);
typedef struct PSI_thread* (*get_thread_v1_t)(void);
+typedef void (*set_thread_user_v1_t)(const char *user, int user_len);
+typedef void (*set_thread_user_host_v1_t)(const char *user, int user_len,
+ const char *host, int host_len);
+typedef void (*set_thread_db_v1_t)(const char* db, int db_len);
+typedef void (*set_thread_command_v1_t)(int command);
+typedef void (*set_thread_start_time_v1_t)(time_t start_time);
+typedef void (*set_thread_state_v1_t)(const char* state);
+typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
typedef void (*delete_current_thread_v1_t)(void);
typedef void (*delete_thread_v1_t)(struct PSI_thread *thread);
-typedef struct PSI_mutex_locker* (*get_thread_mutex_locker_v1_t)
- (struct PSI_mutex_locker_state_v1 *state,
- struct PSI_mutex *mutex,
- enum PSI_mutex_operation op);
-typedef struct PSI_rwlock_locker* (*get_thread_rwlock_locker_v1_t)
- (struct PSI_rwlock_locker_state_v1 *state,
- struct PSI_rwlock *rwlock,
- enum PSI_rwlock_operation op);
-typedef struct PSI_cond_locker* (*get_thread_cond_locker_v1_t)
- (struct PSI_cond_locker_state_v1 *state,
- struct PSI_cond *cond, struct PSI_mutex *mutex,
- enum PSI_cond_operation op);
-typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t)
- (struct PSI_table_locker_state_v1 *state,
- struct PSI_table *table);
typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t)
(struct PSI_file_locker_state_v1 *state,
PSI_file_key key, enum PSI_file_operation op, const char *name,
@@ -225,28 +365,57 @@ typedef void (*signal_cond_v1_t)
(struct PSI_cond *cond);
typedef void (*broadcast_cond_v1_t)
(struct PSI_cond *cond);
-typedef void (*start_mutex_wait_v1_t)
- (struct PSI_mutex_locker *locker, const char *src_file, uint src_line);
+typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
+ (struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
+typedef void (*end_idle_wait_v1_t)
+ (struct PSI_idle_locker *locker);
+typedef struct PSI_mutex_locker* (*start_mutex_wait_v1_t)
+ (struct PSI_mutex_locker_state_v1 *state,
+ struct PSI_mutex *mutex,
+ enum PSI_mutex_operation op,
+ const char *src_file, uint src_line);
typedef void (*end_mutex_wait_v1_t)
(struct PSI_mutex_locker *locker, int rc);
-typedef void (*start_rwlock_rdwait_v1_t)
- (struct PSI_rwlock_locker *locker, const char *src_file, uint src_line);
+typedef struct PSI_rwlock_locker* (*start_rwlock_rdwait_v1_t)
+ (struct PSI_rwlock_locker_state_v1 *state,
+ struct PSI_rwlock *rwlock,
+ enum PSI_rwlock_operation op,
+ const char *src_file, uint src_line);
typedef void (*end_rwlock_rdwait_v1_t)
(struct PSI_rwlock_locker *locker, int rc);
-typedef void (*start_rwlock_wrwait_v1_t)
- (struct PSI_rwlock_locker *locker, const char *src_file, uint src_line);
+typedef struct PSI_rwlock_locker* (*start_rwlock_wrwait_v1_t)
+ (struct PSI_rwlock_locker_state_v1 *state,
+ struct PSI_rwlock *rwlock,
+ enum PSI_rwlock_operation op,
+ const char *src_file, uint src_line);
typedef void (*end_rwlock_wrwait_v1_t)
(struct PSI_rwlock_locker *locker, int rc);
-typedef void (*start_cond_wait_v1_t)
- (struct PSI_cond_locker *locker, const char *src_file, uint src_line);
+typedef struct PSI_cond_locker* (*start_cond_wait_v1_t)
+ (struct PSI_cond_locker_state_v1 *state,
+ struct PSI_cond *cond,
+ struct PSI_mutex *mutex,
+ enum PSI_cond_operation op,
+ const char *src_file, uint src_line);
typedef void (*end_cond_wait_v1_t)
(struct PSI_cond_locker *locker, int rc);
-typedef void (*start_table_wait_v1_t)
- (struct PSI_table_locker *locker, const char *src_file, uint src_line);
-typedef void (*end_table_wait_v1_t)(struct PSI_table_locker *locker);
-typedef struct PSI_file* (*start_file_open_wait_v1_t)
+typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
+ (struct PSI_table_locker_state_v1 *state,
+ struct PSI_table *table,
+ enum PSI_table_io_operation op,
+ uint index,
+ const char *src_file, uint src_line);
+typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
+typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
+ (struct PSI_table_locker_state_v1 *state,
+ struct PSI_table *table,
+ enum PSI_table_lock_operation op,
+ ulong flags,
+ const char *src_file, uint src_line);
+typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*start_file_open_wait_v1_t)
(struct PSI_file_locker *locker, const char *src_file, uint src_line);
-typedef void (*end_file_open_wait_v1_t)(struct PSI_file_locker *locker);
+typedef struct PSI_file* (*end_file_open_wait_v1_t)
+ (struct PSI_file_locker *locker, void *result);
typedef void (*end_file_open_wait_and_bind_to_descriptor_v1_t)
(struct PSI_file_locker *locker, File file);
typedef void (*start_file_wait_v1_t)
@@ -254,6 +423,81 @@ typedef void (*start_file_wait_v1_t)
const char *src_file, uint src_line);
typedef void (*end_file_wait_v1_t)
(struct PSI_file_locker *locker, size_t count);
+typedef void (*start_file_close_wait_v1_t)
+ (struct PSI_file_locker *locker, const char *src_file, uint src_line);
+typedef void (*end_file_close_wait_v1_t)
+ (struct PSI_file_locker *locker, int rc);
+typedef void (*start_stage_v1_t)
+ (PSI_stage_key key, const char *src_file, int src_line);
+typedef void (*end_stage_v1_t) (void);
+typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t)
+ (struct PSI_statement_locker_state_v1 *state,
+ PSI_statement_key key, const void *charset);
+typedef struct PSI_statement_locker* (*refine_statement_v1_t)
+ (struct PSI_statement_locker *locker,
+ PSI_statement_key key);
+typedef void (*start_statement_v1_t)
+ (struct PSI_statement_locker *locker,
+ const char *db, uint db_length,
+ const char *src_file, uint src_line);
+typedef void (*set_statement_text_v1_t)
+ (struct PSI_statement_locker *locker,
+ const char *text, uint text_len);
+typedef void (*set_statement_lock_time_t)
+ (struct PSI_statement_locker *locker, ulonglong lock_time);
+typedef void (*set_statement_rows_sent_t)
+ (struct PSI_statement_locker *locker, ulonglong count);
+typedef void (*set_statement_rows_examined_t)
+ (struct PSI_statement_locker *locker, ulonglong count);
+typedef void (*inc_statement_created_tmp_disk_tables_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_created_tmp_tables_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_select_full_join_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_select_full_range_join_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_select_range_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_select_range_check_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_select_scan_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_sort_merge_passes_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_sort_range_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_sort_rows_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*inc_statement_sort_scan_t)
+ (struct PSI_statement_locker *locker, ulong count);
+typedef void (*set_statement_no_index_used_t)
+ (struct PSI_statement_locker *locker);
+typedef void (*set_statement_no_good_index_used_t)
+ (struct PSI_statement_locker *locker);
+typedef void (*end_statement_v1_t)
+ (struct PSI_statement_locker *locker, void *stmt_da);
+typedef struct PSI_socket_locker* (*start_socket_wait_v1_t)
+ (struct PSI_socket_locker_state_v1 *state,
+ struct PSI_socket *socket,
+ enum PSI_socket_operation op,
+ size_t count,
+ const char *src_file, uint src_line);
+typedef void (*end_socket_wait_v1_t)
+ (struct PSI_socket_locker *locker, size_t count);
+typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket,
+ enum PSI_socket_state state);
+typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
+ const my_socket *fd,
+ const struct sockaddr *addr,
+ socklen_t addr_len);
+typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
+typedef struct PSI_digest_locker * (*digest_start_v1_t)
+ (struct PSI_statement_locker *locker);
+typedef void (*digest_end_v1_t)
+ (struct PSI_digest_locker *locker, const struct sql_digest_storage *digest);
+typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
+ const void *from_cs);
struct PSI_v1
{
register_mutex_v1_t register_mutex;
@@ -261,28 +505,39 @@ struct PSI_v1
register_cond_v1_t register_cond;
register_thread_v1_t register_thread;
register_file_v1_t register_file;
+ register_stage_v1_t register_stage;
+ register_statement_v1_t register_statement;
+ register_socket_v1_t register_socket;
init_mutex_v1_t init_mutex;
destroy_mutex_v1_t destroy_mutex;
init_rwlock_v1_t init_rwlock;
destroy_rwlock_v1_t destroy_rwlock;
init_cond_v1_t init_cond;
destroy_cond_v1_t destroy_cond;
+ init_socket_v1_t init_socket;
+ destroy_socket_v1_t destroy_socket;
get_table_share_v1_t get_table_share;
release_table_share_v1_t release_table_share;
+ drop_table_share_v1_t drop_table_share;
open_table_v1_t open_table;
+ unbind_table_v1_t unbind_table;
+ rebind_table_v1_t rebind_table;
close_table_v1_t close_table;
create_file_v1_t create_file;
spawn_thread_v1_t spawn_thread;
new_thread_v1_t new_thread;
set_thread_id_v1_t set_thread_id;
get_thread_v1_t get_thread;
+ set_thread_user_v1_t set_thread_user;
+ set_thread_user_host_v1_t set_thread_user_host;
+ set_thread_db_v1_t set_thread_db;
+ set_thread_command_v1_t set_thread_command;
+ set_thread_start_time_v1_t set_thread_start_time;
+ set_thread_state_v1_t set_thread_state;
+ set_thread_info_v1_t set_thread_info;
set_thread_v1_t set_thread;
delete_current_thread_v1_t delete_current_thread;
delete_thread_v1_t delete_thread;
- get_thread_mutex_locker_v1_t get_thread_mutex_locker;
- get_thread_rwlock_locker_v1_t get_thread_rwlock_locker;
- get_thread_cond_locker_v1_t get_thread_cond_locker;
- get_thread_table_locker_v1_t get_thread_table_locker;
get_thread_file_name_locker_v1_t get_thread_file_name_locker;
get_thread_file_stream_locker_v1_t get_thread_file_stream_locker;
get_thread_file_descriptor_locker_v1_t get_thread_file_descriptor_locker;
@@ -290,6 +545,8 @@ struct PSI_v1
unlock_rwlock_v1_t unlock_rwlock;
signal_cond_v1_t signal_cond;
broadcast_cond_v1_t broadcast_cond;
+ start_idle_wait_v1_t start_idle_wait;
+ end_idle_wait_v1_t end_idle_wait;
start_mutex_wait_v1_t start_mutex_wait;
end_mutex_wait_v1_t end_mutex_wait;
start_rwlock_rdwait_v1_t start_rwlock_rdwait;
@@ -298,14 +555,49 @@ struct PSI_v1
end_rwlock_wrwait_v1_t end_rwlock_wrwait;
start_cond_wait_v1_t start_cond_wait;
end_cond_wait_v1_t end_cond_wait;
- start_table_wait_v1_t start_table_wait;
- end_table_wait_v1_t end_table_wait;
+ start_table_io_wait_v1_t start_table_io_wait;
+ end_table_io_wait_v1_t end_table_io_wait;
+ start_table_lock_wait_v1_t start_table_lock_wait;
+ end_table_lock_wait_v1_t end_table_lock_wait;
start_file_open_wait_v1_t start_file_open_wait;
end_file_open_wait_v1_t end_file_open_wait;
end_file_open_wait_and_bind_to_descriptor_v1_t
end_file_open_wait_and_bind_to_descriptor;
start_file_wait_v1_t start_file_wait;
end_file_wait_v1_t end_file_wait;
+ start_file_close_wait_v1_t start_file_close_wait;
+ end_file_close_wait_v1_t end_file_close_wait;
+ start_stage_v1_t start_stage;
+ end_stage_v1_t end_stage;
+ get_thread_statement_locker_v1_t get_thread_statement_locker;
+ refine_statement_v1_t refine_statement;
+ start_statement_v1_t start_statement;
+ set_statement_text_v1_t set_statement_text;
+ set_statement_lock_time_t set_statement_lock_time;
+ set_statement_rows_sent_t set_statement_rows_sent;
+ set_statement_rows_examined_t set_statement_rows_examined;
+ inc_statement_created_tmp_disk_tables_t inc_statement_created_tmp_disk_tables;
+ inc_statement_created_tmp_tables_t inc_statement_created_tmp_tables;
+ inc_statement_select_full_join_t inc_statement_select_full_join;
+ inc_statement_select_full_range_join_t inc_statement_select_full_range_join;
+ inc_statement_select_range_t inc_statement_select_range;
+ inc_statement_select_range_check_t inc_statement_select_range_check;
+ inc_statement_select_scan_t inc_statement_select_scan;
+ inc_statement_sort_merge_passes_t inc_statement_sort_merge_passes;
+ inc_statement_sort_range_t inc_statement_sort_range;
+ inc_statement_sort_rows_t inc_statement_sort_rows;
+ inc_statement_sort_scan_t inc_statement_sort_scan;
+ set_statement_no_index_used_t set_statement_no_index_used;
+ set_statement_no_good_index_used_t set_statement_no_good_index_used;
+ end_statement_v1_t end_statement;
+ start_socket_wait_v1_t start_socket_wait;
+ end_socket_wait_v1_t end_socket_wait;
+ set_socket_state_v1_t set_socket_state;
+ set_socket_info_v1_t set_socket_info;
+ set_socket_thread_owner_v1_t set_socket_thread_owner;
+ digest_start_v1_t digest_start;
+ digest_end_v1_t digest_end;
+ set_thread_connect_attrs_v1_t set_thread_connect_attrs;
};
typedef struct PSI_v1 PSI;
typedef struct PSI_mutex_info_v1 PSI_mutex_info;
@@ -313,10 +605,16 @@ typedef struct PSI_rwlock_info_v1 PSI_rwlock_info;
typedef struct PSI_cond_info_v1 PSI_cond_info;
typedef struct PSI_thread_info_v1 PSI_thread_info;
typedef struct PSI_file_info_v1 PSI_file_info;
+typedef struct PSI_stage_info_v1 PSI_stage_info;
+typedef struct PSI_statement_info_v1 PSI_statement_info;
+typedef struct PSI_socket_info_v1 PSI_socket_info;
+typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
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 PSI *PSI_server;
C_MODE_END
diff --git a/include/mysql/psi/psi_abi_v2.h b/include/mysql/psi/psi_abi_v2.h
index 08bca609b41..d2e6f2527b0 100644
--- a/include/mysql/psi/psi_abi_v2.h
+++ b/include/mysql/psi/psi_abi_v2.h
@@ -21,6 +21,6 @@
*/
#define USE_PSI_2
#define HAVE_PSI_INTERFACE
-#define _global_h
+#define MY_GLOBAL_INCLUDED
#include "mysql/psi/psi.h"
diff --git a/include/mysql/psi/psi_abi_v2.h.pp b/include/mysql/psi/psi_abi_v2.h.pp
index 9da270e6f8c..4e81fd66ca4 100644
--- a/include/mysql/psi/psi_abi_v2.h.pp
+++ b/include/mysql/psi/psi_abi_v2.h.pp
@@ -1,24 +1,51 @@
C_MODE_START
+struct TABLE_SHARE;
+struct sql_digest_storage;
struct PSI_mutex;
+typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
+typedef struct PSI_rwlock PSI_rwlock;
struct PSI_cond;
+typedef struct PSI_cond PSI_cond;
struct PSI_table_share;
+typedef struct PSI_table_share PSI_table_share;
struct PSI_table;
+typedef struct PSI_table PSI_table;
struct PSI_thread;
+typedef struct PSI_thread PSI_thread;
struct PSI_file;
+typedef struct PSI_file PSI_file;
+struct PSI_socket;
+typedef struct PSI_socket PSI_socket;
+struct PSI_table_locker;
+typedef struct PSI_table_locker PSI_table_locker;
+struct PSI_statement_locker;
+typedef struct PSI_statement_locker PSI_statement_locker;
+struct PSI_idle_locker;
+typedef struct PSI_idle_locker PSI_idle_locker;
+struct PSI_digest_locker;
+typedef struct PSI_digest_locker PSI_digest_locker;
struct PSI_bootstrap
{
void* (*get_interface)(int version);
};
+typedef struct PSI_bootstrap PSI_bootstrap;
struct PSI_mutex_locker;
+typedef struct PSI_mutex_locker PSI_mutex_locker;
struct PSI_rwlock_locker;
+typedef struct PSI_rwlock_locker PSI_rwlock_locker;
struct PSI_cond_locker;
+typedef struct PSI_cond_locker PSI_cond_locker;
struct PSI_file_locker;
+typedef struct PSI_file_locker PSI_file_locker;
+struct PSI_socket_locker;
+typedef struct PSI_socket_locker PSI_socket_locker;
enum PSI_mutex_operation
{
PSI_MUTEX_LOCK= 0,
PSI_MUTEX_TRYLOCK= 1
};
+typedef enum PSI_mutex_operation PSI_mutex_operation;
enum PSI_rwlock_operation
{
PSI_RWLOCK_READLOCK= 0,
@@ -26,11 +53,13 @@ enum PSI_rwlock_operation
PSI_RWLOCK_TRYREADLOCK= 2,
PSI_RWLOCK_TRYWRITELOCK= 3
};
+typedef enum PSI_rwlock_operation PSI_rwlock_operation;
enum PSI_cond_operation
{
PSI_COND_WAIT= 0,
PSI_COND_TIMEDWAIT= 1
};
+typedef enum PSI_cond_operation PSI_cond_operation;
enum PSI_file_operation
{
PSI_FILE_CREATE= 0,
@@ -51,12 +80,54 @@ enum PSI_file_operation
PSI_FILE_RENAME= 15,
PSI_FILE_SYNC= 16
};
-struct PSI_table_locker;
+typedef enum PSI_file_operation PSI_file_operation;
+enum PSI_table_io_operation
+{
+ PSI_TABLE_FETCH_ROW= 0,
+ PSI_TABLE_WRITE_ROW= 1,
+ PSI_TABLE_UPDATE_ROW= 2,
+ PSI_TABLE_DELETE_ROW= 3
+};
+typedef enum PSI_table_io_operation PSI_table_io_operation;
+enum PSI_table_lock_operation
+{
+ PSI_TABLE_LOCK= 0,
+ PSI_TABLE_EXTERNAL_LOCK= 1
+};
+typedef enum PSI_table_lock_operation PSI_table_lock_operation;
+enum PSI_socket_state
+{
+ PSI_SOCKET_STATE_IDLE= 1,
+ PSI_SOCKET_STATE_ACTIVE= 2
+};
+typedef enum PSI_socket_state PSI_socket_state;
+enum PSI_socket_operation
+{
+ PSI_SOCKET_CREATE= 0,
+ PSI_SOCKET_CONNECT= 1,
+ PSI_SOCKET_BIND= 2,
+ PSI_SOCKET_CLOSE= 3,
+ PSI_SOCKET_SEND= 4,
+ PSI_SOCKET_RECV= 5,
+ PSI_SOCKET_SENDTO= 6,
+ PSI_SOCKET_RECVFROM= 7,
+ PSI_SOCKET_SENDMSG= 8,
+ PSI_SOCKET_RECVMSG= 9,
+ PSI_SOCKET_SEEK= 10,
+ PSI_SOCKET_OPT= 11,
+ PSI_SOCKET_STAT= 12,
+ PSI_SOCKET_SHUTDOWN= 13,
+ PSI_SOCKET_SELECT= 14
+};
+typedef enum PSI_socket_operation PSI_socket_operation;
typedef unsigned int PSI_mutex_key;
typedef unsigned int PSI_rwlock_key;
typedef unsigned int PSI_cond_key;
typedef unsigned int PSI_thread_key;
typedef unsigned int PSI_file_key;
+typedef unsigned int PSI_stage_key;
+typedef unsigned int PSI_statement_key;
+typedef unsigned int PSI_socket_key;
struct PSI_v2
{
int placeholder;
@@ -81,6 +152,18 @@ struct PSI_file_info_v2
{
int placeholder;
};
+struct PSI_stage_info_v2
+{
+ int placeholder;
+};
+struct PSI_statement_info_v2
+{
+ int placeholder;
+};
+struct PSI_idle_locker_state_v2
+{
+ int placeholder;
+};
struct PSI_mutex_locker_state_v2
{
int placeholder;
@@ -101,16 +184,30 @@ struct PSI_table_locker_state_v2
{
int placeholder;
};
+struct PSI_statement_locker_state_v2
+{
+ int placeholder;
+};
+struct PSI_socket_locker_state_v2
+{
+ int placeholder;
+};
typedef struct PSI_v2 PSI;
typedef struct PSI_mutex_info_v2 PSI_mutex_info;
typedef struct PSI_rwlock_info_v2 PSI_rwlock_info;
typedef struct PSI_cond_info_v2 PSI_cond_info;
typedef struct PSI_thread_info_v2 PSI_thread_info;
typedef struct PSI_file_info_v2 PSI_file_info;
+typedef struct PSI_stage_info_v2 PSI_stage_info;
+typedef struct PSI_statement_info_v2 PSI_statement_info;
+typedef struct PSI_socket_info_v2 PSI_socket_info;
+typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
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 PSI *PSI_server;
C_MODE_END
diff --git a/include/mysql/service_debug_sync.h b/include/mysql/service_debug_sync.h
index f7bab99ac97..eee8e6bbe96 100644
--- a/include/mysql/service_debug_sync.h
+++ b/include/mysql/service_debug_sync.h
@@ -337,11 +337,18 @@ extern void (*debug_sync_C_callback_ptr)(MYSQL_THD, const char *, size_t);
#define DEBUG_SYNC(thd, name) \
do { \
if (debug_sync_service) \
- debug_sync_service(thd, name, sizeof(name)-1); \
+ debug_sync_service(thd, STRING_WITH_LEN(name)); \
+ } while(0)
+
+#define DEBUG_SYNC_C_IF_THD(thd, name) \
+ do { \
+ if (debug_sync_service && thd) \
+ debug_sync_service((MYSQL_THD) thd, STRING_WITH_LEN(name)); \
} while(0)
#else
-#define DEBUG_SYNC(thd,name) do { } while(0)
-#endif
+#define DEBUG_SYNC(thd,name) do { } while(0)
+#define DEBUG_SYNC_C_IF_THD(thd, _sync_point_name_) do { } while(0)
+#endif /* defined(ENABLED_DEBUG_SYNC) */
/* compatibility macro */
#define DEBUG_SYNC_C(name) DEBUG_SYNC(NULL, name)
diff --git a/include/mysql/service_my_plugin_log.h b/include/mysql/service_my_plugin_log.h
new file mode 100644
index 00000000000..0cf7817573c
--- /dev/null
+++ b/include/mysql/service_my_plugin_log.h
@@ -0,0 +1,64 @@
+/* Copyright (c) 2011, 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 */
+
+/**
+ @file
+ This service provides functions to report error conditions and log to
+ mysql error log.
+*/
+
+#ifndef MYSQL_SERVICE_MY_PLUGIN_LOG_INCLUDED
+#define MYSQL_SERVICE_MY_PLUGIN_LOG_INCLUDED
+
+#ifndef MYSQL_ABI_CHECK
+#include <stdarg.h>
+#endif
+
+/* keep in sync with the loglevel enum in my_sys.h */
+enum plugin_log_level
+{
+ MY_ERROR_LEVEL,
+ MY_WARNING_LEVEL,
+ MY_INFORMATION_LEVEL
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern struct my_plugin_log_service
+{
+ /** write a message to the log */
+ int (*my_plugin_log_message)(MYSQL_PLUGIN *, enum plugin_log_level, const char *, ...);
+} *my_plugin_log_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define my_plugin_log_message my_plugin_log_service->my_plugin_log_message
+
+#else
+
+int my_plugin_log_message(MYSQL_PLUGIN *plugin, enum plugin_log_level level,
+ const char *format, ...);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/mysql/service_progress_report.h b/include/mysql/service_progress_report.h
index 670b1c37630..7ec3aa4c946 100644
--- a/include/mysql/service_progress_report.h
+++ b/include/mysql/service_progress_report.h
@@ -22,7 +22,7 @@
if requested.
The functions are documented at
- http://kb.askmonty.org/en/progress-reporting#how-to-add-support-for-progress-reporting-to-a-storage-engine
+ https://mariadb.com/kb/en/progress-reporting/#how-to-add-support-for-progress-reporting-to-a-storage-engine
*/
#ifdef __cplusplus
diff --git a/include/mysql/service_sha1.h b/include/mysql/service_sha1.h
new file mode 100644
index 00000000000..01f5ba81566
--- /dev/null
+++ b/include/mysql/service_sha1.h
@@ -0,0 +1,57 @@
+#ifndef MYSQL_SERVICE_SHA1_INCLUDED
+/* Copyright (c) 2013, Monty Program Ab
+
+ 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 */
+
+/**
+ @file
+ my sha1 service
+
+ Functions to calculate SHA1 hash from a memory buffer
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef MYSQL_ABI_CHECK
+#include <stdlib.h>
+#endif
+
+#define MY_SHA1_HASH_SIZE 20 /* Hash size in bytes */
+
+extern struct my_sha1_service_st {
+ void (*my_sha1_type)(unsigned char*, const char*, size_t);
+ void (*my_sha1_multi_type)(unsigned char*, ...);
+} *my_sha1_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define my_sha1(A,B,C) my_sha1_service->my_sha1_type(A,B,C)
+#define my_sha1_multi my_sha1_service->my_sha1_multi_type
+
+#else
+
+void my_sha1(unsigned char*, const char*, size_t);
+void my_sha1_multi(unsigned char*, ...);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_SHA1_INCLUDED
+#endif
+
diff --git a/include/mysql/service_thd_autoinc.h b/include/mysql/service_thd_autoinc.h
new file mode 100644
index 00000000000..a4e336ab232
--- /dev/null
+++ b/include/mysql/service_thd_autoinc.h
@@ -0,0 +1,53 @@
+#ifndef MYSQL_SERVICE_THD_AUTOINC_INCLUDED
+/* Copyright (C) 2013 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
+ 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 */
+
+/**
+ @file
+ This service provides access to the auto_increment related system variables:
+
+ @@auto_increment_offset
+ @@auto_increment_increment
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern struct thd_autoinc_service_st {
+ void (*thd_get_autoinc_func)(const MYSQL_THD thd,
+ unsigned long* off, unsigned long* inc);
+} *thd_autoinc_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+#define thd_get_autoinc(thd, off, inc) \
+ (thd_autoinc_service->thd_get_autoinc_func((thd), (off), (inc)))
+#else
+/**
+ Return autoincrement system variables
+ @param IN thd user thread connection handle
+ @param OUT off the value of @@SESSION.auto_increment_offset
+ @param OUT inc the value of @@SESSION.auto_increment_increment
+*/
+void thd_get_autoinc(const MYSQL_THD thd,
+ unsigned long* off, unsigned long* inc);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_THD_AUTOINC_INCLUDED
+#endif
diff --git a/include/mysql/service_thd_error_context.h b/include/mysql/service_thd_error_context.h
new file mode 100644
index 00000000000..7619aa44082
--- /dev/null
+++ b/include/mysql/service_thd_error_context.h
@@ -0,0 +1,93 @@
+#ifndef MYSQL_SERVICE_THD_STMT_DA_INCLUDED
+/* Copyright (C) 2013 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
+ 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 */
+
+/**
+ @file
+ This service provides access to the statement diagnostics area:
+ - error message
+ - error number
+ - row for warning (e.g. for multi-row INSERT statements)
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern struct thd_error_context_service_st {
+ const char *(*thd_get_error_message_func)(const MYSQL_THD thd);
+ unsigned int (*thd_get_error_number_func)(const MYSQL_THD thd);
+ unsigned long (*thd_get_error_row_func)(const MYSQL_THD thd);
+ void (*thd_inc_error_row_func)(MYSQL_THD thd);
+ char *(*thd_get_error_context_description_func)(MYSQL_THD thd,
+ char *buffer,
+ unsigned int length,
+ unsigned int max_query_length);
+} *thd_error_context_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+#define thd_get_error_message(thd) \
+ (thd_error_context_service->thd_get_error_message_func((thd)))
+#define thd_get_error_number(thd) \
+ (thd_error_context_service->thd_get_error_number_func((thd)))
+#define thd_get_error_row(thd) \
+ (thd_error_context_service->thd_get_error_row_func((thd)))
+#define thd_inc_error_row(thd) \
+ (thd_error_context_service->thd_inc_error_row_func((thd)))
+#define thd_get_error_context_description(thd, buffer, length, max_query_len) \
+ (thd_error_context_service->thd_get_error_context_description_func((thd), \
+ (buffer), \
+ (length), \
+ (max_query_len)))
+#else
+/**
+ Return error message
+ @param thd user thread connection handle
+ @return error text
+*/
+const char *thd_get_error_message(const MYSQL_THD thd);
+/**
+ Return error number
+ @param thd user thread connection handle
+ @return error number
+*/
+unsigned int thd_get_error_number(const MYSQL_THD thd);
+/**
+ Return the current row number (i.e. in a multiple INSERT statement)
+ @param thd user thread connection handle
+ @return row number
+*/
+unsigned long thd_get_error_row(const MYSQL_THD thd);
+/**
+ Increment the current row number
+ @param thd user thread connection handle
+*/
+void thd_inc_error_row(MYSQL_THD thd);
+/**
+ Return a text description of a thread, its security context (user,host)
+ and the current query.
+*/
+char *thd_get_error_context_description(MYSQL_THD thd,
+ char *buffer, unsigned int length,
+ unsigned int max_query_length);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_THD_STMT_DA_INCLUDED
+#endif
diff --git a/include/mysql/service_thd_timezone.h b/include/mysql/service_thd_timezone.h
new file mode 100644
index 00000000000..f44f011b891
--- /dev/null
+++ b/include/mysql/service_thd_timezone.h
@@ -0,0 +1,73 @@
+#ifndef MYSQL_SERVICE_THD_TIMEZONE_INCLUDED
+/* Copyright (C) 2013 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
+ 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 */
+
+/**
+ @file
+ This service provdes functions to convert between my_time_t and
+ MYSQL_TIME taking into account the current value of the time_zone
+ session variable.
+
+ The values of the my_time_t type are in Unix timestamp format,
+ i.e. the number of seconds since "1970-01-01 00:00:00 UTC".
+
+ The values of the MYSQL_TIME type are in the current time zone,
+ according to thd->variables.time_zone.
+
+ If the MYSQL_THD parameter is NULL, then global_system_variables.time_zone
+ is used for conversion.
+*/
+
+#ifndef MYSQL_ABI_CHECK
+/*
+ This service currently does not depend on any system headers.
+ If it needs system headers in the future, make sure to put
+ them inside this ifndef.
+*/
+#endif
+
+#include "mysql_time.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(MYSQL_THD thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define thd_TIME_to_gmt_sec(thd, ltime, errcode) \
+ (thd_timezone_service->thd_TIME_to_gmt_sec((thd), (ltime), (errcode)))
+
+#define thd_gmt_sec_to_TIME(thd, ltime, t) \
+ (thd_timezone_service->thd_gmt_sec_to_TIME((thd), (ltime), (t)))
+
+#else
+
+my_time_t thd_TIME_to_gmt_sec(MYSQL_THD thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_THD_TIMEZONE_INCLUDED
+#endif
diff --git a/include/mysql/service_thd_wait.h b/include/mysql/service_thd_wait.h
index 6b47a4ff21e..c35b35df820 100644
--- a/include/mysql/service_thd_wait.h
+++ b/include/mysql/service_thd_wait.h
@@ -74,7 +74,8 @@ typedef enum _thd_wait_type_e {
THD_WAIT_BINLOG= 8,
THD_WAIT_GROUP_COMMIT= 9,
THD_WAIT_SYNC= 10,
- THD_WAIT_LAST= 11
+ THD_WAIT_NET= 11,
+ THD_WAIT_LAST= 12
} thd_wait_type;
extern struct thd_wait_service_st {
diff --git a/include/mysql/service_thread_scheduler.h b/include/mysql/service_thread_scheduler.h
deleted file mode 100644
index 5a5e0e2f520..00000000000
--- a/include/mysql/service_thread_scheduler.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (c) 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-1301 USA
-*/
-
-#ifndef SERVICE_THREAD_SCHEDULER_INCLUDED
-#define SERVICE_THREAD_SCHEDULER_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct scheduler_functions;
-
-extern struct my_thread_scheduler_service {
- int (*set)(struct scheduler_functions *scheduler);
- int (*reset)();
-} *my_thread_scheduler_service;
-
-#ifdef MYSQL_DYNAMIC_PLUGIN
-
-#define my_thread_scheduler_set(F) my_thread_scheduler_service->set((F))
-#define my_thread_scheduler_reset() my_thread_scheduler_service->reset()
-
-#else
-
-/**
- Set the thread scheduler to use for the server.
-
- @param scheduler Pointer to scheduler callbacks to use.
- @retval 0 Scheduler installed correctly.
- @retval 1 Invalid value (NULL) used for scheduler.
-*/
-int my_thread_scheduler_set(struct scheduler_functions *scheduler);
-
-/**
- Restore the previous thread scheduler.
-
- @note If no thread scheduler was installed previously with
- thd_set_thread_scheduler, this function will report an error.
-
- @retval 0 Scheduler installed correctly.
- @retval 1 No scheduler installed.
-*/
-int my_thread_scheduler_reset();
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SERVICE_THREAD_SCHEDULER_INCLUDED */
diff --git a/include/mysql/services.h b/include/mysql/services.h
index 51d3bd1f909..62cac338703 100644
--- a/include/mysql/services.h
+++ b/include/mysql/services.h
@@ -1,5 +1,6 @@
#ifndef MYSQL_SERVICES_INCLUDED
-/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2009, 2010, Oracle and/or its affiliates.
+ Copyright (c) 2012, 2013, Monty Program Ab
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
@@ -21,11 +22,14 @@ extern "C" {
#include <mysql/service_my_snprintf.h>
#include <mysql/service_thd_alloc.h>
#include <mysql/service_thd_wait.h>
-#include <mysql/service_thread_scheduler.h>
#include <mysql/service_progress_report.h>
#include <mysql/service_debug_sync.h>
#include <mysql/service_kill_statement.h>
+#include <mysql/service_thd_timezone.h>
+#include <mysql/service_sha1.h>
#include <mysql/service_logger.h>
+#include <mysql/service_thd_autoinc.h>
+#include <mysql/service_thd_error_context.h>
#ifdef __cplusplus
}
diff --git a/include/mysql_async.h b/include/mysql_async.h
index 2c84d5bc1b6..2728b9c1dc7 100644
--- a/include/mysql_async.h
+++ b/include/mysql_async.h
@@ -20,14 +20,14 @@
extern int my_connect_async(struct mysql_async_context *b, my_socket fd,
const struct sockaddr *name, uint namelen,
- uint timeout);
+ int vio_timeout);
extern ssize_t my_recv_async(struct mysql_async_context *b, int fd,
- unsigned char *buf, size_t size, uint timeout);
+ unsigned char *buf, size_t size, int timeout);
extern ssize_t my_send_async(struct mysql_async_context *b, int fd,
const unsigned char *buf, size_t size,
- uint timeout);
-extern my_bool my_poll_read_async(struct mysql_async_context *b,
- uint timeout);
+ int timeout);
+extern my_bool my_io_wait_async(struct mysql_async_context *b,
+ enum enum_vio_io_event event, int timeout);
#ifdef HAVE_OPENSSL
extern int my_ssl_read_async(struct mysql_async_context *b, SSL *ssl,
void *buf, int size);
diff --git a/include/mysql_com.h b/include/mysql_com.h
index df9681e02a4..7853aa0195a 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -64,10 +64,11 @@
/*
Maximum length of comments
*/
-#define TABLE_COMMENT_INLINE_MAXLEN 180 /* pre 6.0: 60 characters */
+#define TABLE_COMMENT_INLINE_MAXLEN 180 /* pre 5.5: 60 characters */
#define TABLE_COMMENT_MAXLEN 2048
#define COLUMN_COMMENT_MAXLEN 1024
#define INDEX_COMMENT_MAXLEN 1024
+#define TABLE_PARTITION_COMMENT_MAXLEN 1024
/*
USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
@@ -110,7 +111,7 @@ enum enum_server_command
#define MYSQL_TYPE_VIRTUAL 245
/*
Length of random string sent by server on handshake; this is also length of
- obfuscated password, recieved from client
+ obfuscated password, received from client
*/
#define SCRAMBLE_LENGTH 20
#define SCRAMBLE_LENGTH_323 8
@@ -142,46 +143,55 @@ enum enum_server_command
#define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */
#define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
#define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
-#define FIELD_IN_ADD_INDEX (1<< 20) /* Intern: Field used in ADD INDEX */
+
+/**
+ Intern: Field in TABLE object for new version of altered table,
+ which participates in a newly added index.
+*/
+#define FIELD_IN_ADD_INDEX (1 << 20)
#define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */
-#define FIELD_FLAGS_STORAGE_MEDIA 22 /* Field storage media, bit 22-23,
- reserved by MySQL Cluster */
-#define FIELD_FLAGS_COLUMN_FORMAT 24 /* Field column format, bit 24-25,
- reserved by MySQL Cluster */
-
-#define REFRESH_GRANT (1UL << 0) /* Refresh grant tables */
-#define REFRESH_LOG (1UL << 1) /* Start on new log file */
-#define REFRESH_TABLES (1UL << 2) /* close all tables */
-#define REFRESH_HOSTS (1UL << 3) /* Flush host cache */
-#define REFRESH_STATUS (1UL << 4) /* Flush status variables */
-#define REFRESH_THREADS (1UL << 5) /* Flush thread cache */
-#define REFRESH_SLAVE (1UL << 6) /* Reset master info and restart slave
+#define FIELD_FLAGS_STORAGE_MEDIA 22 /* Field storage media, bit 22-23 */
+#define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA)
+#define FIELD_FLAGS_COLUMN_FORMAT 24 /* Field column format, bit 24-25 */
+#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
+#define FIELD_IS_DROPPED (1<< 26) /* Intern: Field is being dropped */
+#define HAS_EXPLICIT_VALUE (1 << 27) /* An INSERT/UPDATE operation supplied
+ an explicit default value */
+
+#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 */
+#define REFRESH_HOSTS (1ULL << 3) /* Flush host cache */
+#define REFRESH_STATUS (1ULL << 4) /* Flush status variables */
+#define REFRESH_THREADS (1ULL << 5) /* Flush thread cache */
+#define REFRESH_SLAVE (1ULL << 6) /* Reset master info and restart slave
thread */
-#define REFRESH_MASTER (1UL << 7) /* Remove all bin logs in the index
+#define REFRESH_MASTER (1ULL << 7) /* Remove all bin logs in the index
and truncate the index */
/* The following can't be set with mysql_refresh() */
-#define REFRESH_ERROR_LOG (1UL << 8) /* Rotate only the erorr log */
-#define REFRESH_ENGINE_LOG (1UL << 9) /* Flush all storage engine logs */
-#define REFRESH_BINARY_LOG (1UL << 10) /* Flush the binary log */
-#define REFRESH_RELAY_LOG (1UL << 11) /* Flush the relay log */
-#define REFRESH_GENERAL_LOG (1UL << 12) /* Flush the general log */
-#define REFRESH_SLOW_LOG (1UL << 13) /* Flush the slow query log */
+#define REFRESH_ERROR_LOG (1ULL << 8) /* Rotate only the erorr 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 */
+#define REFRESH_GENERAL_LOG (1ULL << 12) /* Flush the general log */
+#define REFRESH_SLOW_LOG (1ULL << 13) /* Flush the slow query log */
-#define REFRESH_READ_LOCK (1UL << 14) /* Lock tables for read */
-#define REFRESH_CHECKPOINT (1UL << 15) /* With REFRESH_READ_LOCK: block checkpoints too */
+#define REFRESH_READ_LOCK (1ULL << 14) /* Lock tables for read */
+#define REFRESH_CHECKPOINT (1ULL << 15) /* With REFRESH_READ_LOCK: block checkpoints too */
-#define REFRESH_QUERY_CACHE (1UL << 16) /* clear the query cache */
-#define REFRESH_QUERY_CACHE_FREE (1UL << 17) /* pack query cache */
-#define REFRESH_DES_KEY_FILE (1UL << 18)
-#define REFRESH_USER_RESOURCES (1UL << 19)
+#define REFRESH_QUERY_CACHE (1ULL << 16) /* clear the query cache */
+#define REFRESH_QUERY_CACHE_FREE (1ULL << 17) /* pack query cache */
+#define REFRESH_DES_KEY_FILE (1ULL << 18)
+#define REFRESH_USER_RESOURCES (1ULL << 19)
+#define REFRESH_FOR_EXPORT (1ULL << 20) /* FLUSH TABLES ... FOR EXPORT */
-#define REFRESH_TABLE_STATS (1UL << 20) /* Refresh table stats hash table */
-#define REFRESH_INDEX_STATS (1UL << 21) /* Refresh index stats hash table */
-#define REFRESH_USER_STATS (1UL << 22) /* Refresh user stats hash table */
-#define REFRESH_CLIENT_STATS (1UL << 23) /* Refresh client stats hash table */
+#define REFRESH_TABLE_STATS (1ULL << 27) /* Refresh table stats hash table */
+#define REFRESH_INDEX_STATS (1ULL << 28) /* Refresh index stats hash table */
+#define REFRESH_USER_STATS (1ULL << 29) /* Refresh user stats hash table */
+#define REFRESH_CLIENT_STATS (1ULL << 30) /* Refresh client stats hash table */
-#define REFRESH_FAST (1UL << 31) /* Intern flag */
+#define REFRESH_FAST (1ULL << 31) /* Intern flag */
#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
@@ -204,8 +214,15 @@ enum enum_server_command
#define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */
#define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */
-#define CLIENT_PROGRESS (1UL << 29) /* Client support progress indicator */
+#define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */
+#define CLIENT_CONNECT_ATTRS (1UL << 20) /* Client supports connection attributes */
+/* Enable authentication response packet to be larger than 255 bytes. */
+#define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21)
+/* Don't close the connection for a connection with expired password. */
+#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22)
+
+#define CLIENT_PROGRESS (1UL << 29) /* Client support progress indicator */
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
/*
It used to be that if mysql_real_connect() failed, it would delete any
@@ -247,7 +264,14 @@ enum enum_server_command
CLIENT_SSL_VERIFY_SERVER_CERT | \
CLIENT_REMEMBER_OPTIONS | \
CLIENT_PROGRESS | \
- CLIENT_PLUGIN_AUTH)
+ CLIENT_PLUGIN_AUTH | \
+ CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \
+ CLIENT_CONNECT_ATTRS)
+
+/*
+ To be added later:
+ CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS
+*/
/*
Switch off the flags that are optional and depending on build flags
@@ -296,8 +320,18 @@ enum enum_server_command
*/
#define SERVER_PS_OUT_PARAMS 4096
+/**
+ Set at the same time as SERVER_STATUS_IN_TRANS if the started
+ multi-statement transaction is a read-only transaction. Cleared
+ when the transaction commits or aborts. Since this flag is sent
+ to clients in OK and EOF packets, the flag indicates the
+ transaction status at the end of command execution.
+*/
+#define SERVER_STATUS_IN_TRANS_READONLY 8192
+
#define SERVER_STATUS_ANSI_QUOTES 32768
+
/**
Server status flags that must be cleared when starting
execution of a new SQL statement.
@@ -353,8 +387,8 @@ typedef struct st_net {
unsigned char reading_or_writing;
char save_char;
char net_skip_rest_factor;
- my_bool unused1; /* Please remove with the next incompatible ABI change */
- my_bool compress;
+ my_bool thread_specific_malloc;
+ unsigned char compress;
my_bool unused3; /* Please remove with the next incompatible ABI change. */
/*
Pointer to query object in query cache, do not equal NULL (0) for
@@ -388,6 +422,16 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
MYSQL_TYPE_BIT,
+ /*
+ mysql-5.6 compatibility temporal types.
+ They're only used internally for reading RBR
+ mysql-5.6 binary log events and mysql-5.6 frm files.
+ They're never sent to the client.
+ */
+ MYSQL_TYPE_TIMESTAMP2,
+ MYSQL_TYPE_DATETIME2,
+ MYSQL_TYPE_TIME2,
+
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248,
@@ -488,10 +532,10 @@ enum enum_mysql_set_option
extern "C" {
#endif
-my_bool my_net_init(NET *net, Vio* vio);
+my_bool my_net_init(NET *net, Vio* vio, unsigned int my_flags);
void my_net_local_init(NET *net);
void net_end(NET *net);
- void net_clear(NET *net, my_bool clear_buffer);
+void net_clear(NET *net, my_bool clear_buffer);
my_bool net_realloc(NET *net, size_t length);
my_bool net_flush(NET *net);
my_bool my_net_write(NET *net,const unsigned char *packet, size_t len);
@@ -499,9 +543,10 @@ my_bool net_write_command(NET *net,unsigned char command,
const unsigned char *header, size_t head_len,
const unsigned char *packet, size_t len);
int net_real_write(NET *net,const unsigned char *packet, size_t len);
-unsigned long my_net_read(NET *net);
+unsigned long my_net_read_packet(NET *net, my_bool read_from_server);
+#define my_net_read(A) my_net_read_packet((A), 0)
-#ifdef _global_h
+#ifdef MY_GLOBAL_INCLUDED
void my_net_set_write_timeout(NET *net, uint timeout);
void my_net_set_read_timeout(NET *net, uint timeout);
#endif
@@ -575,14 +620,17 @@ void scramble_323(char *to, const char *message, const char *password);
my_bool check_scramble_323(const unsigned char *reply, const char *message,
unsigned long *salt);
void get_salt_from_password_323(unsigned long *res, const char *password);
+#if MYSQL_VERSION_ID < 100100
void make_password_from_salt_323(char *to, const unsigned long *salt);
-
+#endif
void make_scrambled_password(char *to, const char *password);
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);
+#if MYSQL_VERSION_ID < 100100
void make_password_from_salt(char *to, const unsigned char *hash_stage2);
+#endif
char *octet2hex(char *to, const char *str, unsigned int len);
/* end of password.c */
@@ -596,10 +644,12 @@ const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
my_bool my_thread_init(void);
void my_thread_end(void);
-#ifdef _global_h
+#ifdef MY_GLOBAL_INCLUDED
ulong STDCALL net_field_length(uchar **packet);
my_ulonglong net_field_length_ll(uchar **packet);
+my_ulonglong safe_net_field_length_ll(uchar **packet, size_t packet_len);
uchar *net_store_length(uchar *pkg, ulonglong length);
+uchar *safe_net_store_length(uchar *pkg, size_t pkg_len, ulonglong length);
#endif
#ifdef __cplusplus
diff --git a/include/mysql_com_server.h b/include/mysql_com_server.h
new file mode 100644
index 00000000000..1ea040207d4
--- /dev/null
+++ b/include/mysql_com_server.h
@@ -0,0 +1,41 @@
+/* Copyright (c) 2011, 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 */
+
+/*
+ Definitions private to the server,
+ used in the networking layer to notify specific events.
+*/
+
+#ifndef _mysql_com_server_h
+#define _mysql_com_server_h
+
+struct st_net_server;
+
+typedef void (*before_header_callback_fn)
+ (struct st_net *net, void *user_data, size_t count);
+
+typedef void (*after_header_callback_fn)
+ (struct st_net *net, void *user_data, size_t count, my_bool rc);
+
+struct st_net_server
+{
+ before_header_callback_fn m_before_header;
+ after_header_callback_fn m_after_header;
+ void *m_user_data;
+};
+
+typedef struct st_net_server NET_SERVER;
+
+#endif
diff --git a/include/mysql_time.h b/include/mysql_time.h
index 6ccae8d5dc2..24fd7ed6102 100644
--- a/include/mysql_time.h
+++ b/include/mysql_time.h
@@ -18,6 +18,17 @@
#define _mysql_time_h_
/*
+ Portable time_t replacement.
+ Should be signed and hold seconds for 1902 -- 2038-01-19 range
+ i.e at least a 32bit variable
+
+ Using the system built in time_t is not an option as
+ we rely on the above requirements in the time functions
+*/
+typedef long my_time_t;
+
+
+/*
Time declarations shared between the server and client API:
you should not add anything to this header unless it's used
(and hence should be visible) in mysql.h.
diff --git a/include/probes_mysql_nodtrace.h.in b/include/probes_mysql_nodtrace.h.in
index a84bf7726c3..2155e8489da 100644
--- a/include/probes_mysql_nodtrace.h.in
+++ b/include/probes_mysql_nodtrace.h.in
@@ -6,124 +6,124 @@
#define _PROBES_MYSQL_D
#ifdef __cplusplus
-#define MYSQL_PROBES_FALSE false
extern "C" {
+#define MYSQL_DTRACE_DISABLED false
#else
-#define MYSQL_PROBES_FALSE 0
+#define MYSQL_DTRACE_DISABLED 0
#endif
#define MYSQL_CONNECTION_START(arg0, arg1, arg2)
-#define MYSQL_CONNECTION_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_CONNECTION_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_CONNECTION_DONE(arg0, arg1)
-#define MYSQL_CONNECTION_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_CONNECTION_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_COMMAND_START(arg0, arg1, arg2, arg3)
-#define MYSQL_COMMAND_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_COMMAND_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_COMMAND_DONE(arg0)
-#define MYSQL_COMMAND_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_COMMAND_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_START(arg0, arg1, arg2, arg3, arg4)
-#define MYSQL_QUERY_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_QUERY_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_DONE(arg0)
-#define MYSQL_QUERY_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_QUERY_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_PARSE_START(arg0)
-#define MYSQL_QUERY_PARSE_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_QUERY_PARSE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_PARSE_DONE(arg0)
-#define MYSQL_QUERY_PARSE_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_QUERY_PARSE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_CACHE_HIT(arg0, arg1)
-#define MYSQL_QUERY_CACHE_HIT_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_QUERY_CACHE_HIT_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_CACHE_MISS(arg0)
-#define MYSQL_QUERY_CACHE_MISS_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_QUERY_CACHE_MISS_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_EXEC_START(arg0, arg1, arg2, arg3, arg4, arg5)
-#define MYSQL_QUERY_EXEC_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_QUERY_EXEC_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_EXEC_DONE(arg0)
-#define MYSQL_QUERY_EXEC_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_QUERY_EXEC_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_ROW_START(arg0, arg1)
-#define MYSQL_INSERT_ROW_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_INSERT_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_ROW_DONE(arg0)
-#define MYSQL_INSERT_ROW_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_INSERT_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_UPDATE_ROW_START(arg0, arg1)
-#define MYSQL_UPDATE_ROW_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_UPDATE_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_UPDATE_ROW_DONE(arg0)
-#define MYSQL_UPDATE_ROW_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_UPDATE_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_DELETE_ROW_START(arg0, arg1)
-#define MYSQL_DELETE_ROW_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_DELETE_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_DELETE_ROW_DONE(arg0)
-#define MYSQL_DELETE_ROW_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_DELETE_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_READ_ROW_START(arg0, arg1, arg2)
-#define MYSQL_READ_ROW_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_READ_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_READ_ROW_DONE(arg0)
-#define MYSQL_READ_ROW_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_READ_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INDEX_READ_ROW_START(arg0, arg1)
-#define MYSQL_INDEX_READ_ROW_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_INDEX_READ_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INDEX_READ_ROW_DONE(arg0)
-#define MYSQL_INDEX_READ_ROW_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_INDEX_READ_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_RDLOCK_START(arg0, arg1)
-#define MYSQL_HANDLER_RDLOCK_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_HANDLER_RDLOCK_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_WRLOCK_START(arg0, arg1)
-#define MYSQL_HANDLER_WRLOCK_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_HANDLER_WRLOCK_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_UNLOCK_START(arg0, arg1)
-#define MYSQL_HANDLER_UNLOCK_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_HANDLER_UNLOCK_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_RDLOCK_DONE(arg0)
-#define MYSQL_HANDLER_RDLOCK_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_HANDLER_RDLOCK_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_WRLOCK_DONE(arg0)
-#define MYSQL_HANDLER_WRLOCK_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_HANDLER_WRLOCK_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_UNLOCK_DONE(arg0)
-#define MYSQL_HANDLER_UNLOCK_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_HANDLER_UNLOCK_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_FILESORT_START(arg0, arg1)
-#define MYSQL_FILESORT_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_FILESORT_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_FILESORT_DONE(arg0, arg1)
-#define MYSQL_FILESORT_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_FILESORT_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_SELECT_START(arg0)
-#define MYSQL_SELECT_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_SELECT_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_SELECT_DONE(arg0, arg1)
-#define MYSQL_SELECT_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_SELECT_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_START(arg0)
-#define MYSQL_INSERT_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_INSERT_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_DONE(arg0, arg1)
-#define MYSQL_INSERT_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_INSERT_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_SELECT_START(arg0)
-#define MYSQL_INSERT_SELECT_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_INSERT_SELECT_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_SELECT_DONE(arg0, arg1)
-#define MYSQL_INSERT_SELECT_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_INSERT_SELECT_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_UPDATE_START(arg0)
-#define MYSQL_UPDATE_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_UPDATE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_UPDATE_DONE(arg0, arg1, arg2)
-#define MYSQL_UPDATE_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_UPDATE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_MULTI_UPDATE_START(arg0)
-#define MYSQL_MULTI_UPDATE_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_MULTI_UPDATE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2)
-#define MYSQL_MULTI_UPDATE_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_MULTI_UPDATE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_DELETE_START(arg0)
-#define MYSQL_DELETE_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_DELETE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_DELETE_DONE(arg0, arg1)
-#define MYSQL_DELETE_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_DELETE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_MULTI_DELETE_START(arg0)
-#define MYSQL_MULTI_DELETE_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_MULTI_DELETE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_MULTI_DELETE_DONE(arg0, arg1)
-#define MYSQL_MULTI_DELETE_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_MULTI_DELETE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_NET_READ_START()
-#define MYSQL_NET_READ_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_NET_READ_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_NET_READ_DONE(arg0, arg1)
-#define MYSQL_NET_READ_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_NET_READ_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_NET_WRITE_START(arg0)
-#define MYSQL_NET_WRITE_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_NET_WRITE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_NET_WRITE_DONE(arg0)
-#define MYSQL_NET_WRITE_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_NET_WRITE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_START(arg0, arg1, arg2, arg3)
-#define MYSQL_KEYCACHE_READ_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_KEYCACHE_READ_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_BLOCK(arg0)
-#define MYSQL_KEYCACHE_READ_BLOCK_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_KEYCACHE_READ_BLOCK_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_HIT()
-#define MYSQL_KEYCACHE_READ_HIT_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_KEYCACHE_READ_HIT_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_MISS()
-#define MYSQL_KEYCACHE_READ_MISS_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_KEYCACHE_READ_MISS_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_DONE(arg0, arg1)
-#define MYSQL_KEYCACHE_READ_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_KEYCACHE_READ_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_WRITE_START(arg0, arg1, arg2, arg3)
-#define MYSQL_KEYCACHE_WRITE_START_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_KEYCACHE_WRITE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_WRITE_BLOCK(arg0)
-#define MYSQL_KEYCACHE_WRITE_BLOCK_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_KEYCACHE_WRITE_BLOCK_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_WRITE_DONE(arg0, arg1)
-#define MYSQL_KEYCACHE_WRITE_DONE_ENABLED() (MYSQL_PROBES_FALSE)
+#define MYSQL_KEYCACHE_WRITE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#ifdef __cplusplus
}
diff --git a/include/queues.h b/include/queues.h
index 4fef72b149c..f341bbb8148 100644
--- a/include/queues.h
+++ b/include/queues.h
@@ -51,6 +51,7 @@ typedef struct st_queue {
#define queue_first_element(queue) 1
#define queue_last_element(queue) (queue)->elements
+#define queue_empty(queue) ((queue)->elements == 0)
#define queue_top(queue) ((queue)->root[1])
#define queue_element(queue,index) ((queue)->root[index])
#define queue_end(queue) ((queue)->root[(queue)->elements])
diff --git a/include/service_versions.h b/include/service_versions.h
index 21dc9c8f21d..ce4a0c931f7 100644
--- a/include/service_versions.h
+++ b/include/service_versions.h
@@ -1,4 +1,5 @@
-/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2009, 2010, Oracle and/or its affiliates.
+ Copyright (c) 2012, 2013, Monty Program Ab
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 +20,15 @@
#define SERVICE_VERSION void *
#endif
+#define VERSION_debug_sync 0x1000
+#define VERSION_kill_statement 0x1000
+
#define VERSION_my_snprintf 0x0100
#define VERSION_thd_alloc 0x0100
#define VERSION_thd_wait 0x0100
-#define VERSION_my_thread_scheduler 0x0100
#define VERSION_progress_report 0x0100
-#define VERSION_debug_sync 0x1000
-#define VERSION_kill_statement 0x1000
+#define VERSION_thd_timezone 0x0100
+#define VERSION_my_sha1 0x0100
#define VERSION_logger 0x0100
-
+#define VERSION_thd_autoinc 0x0100
+#define VERSION_thd_error_context 0x0200
diff --git a/include/sha1.h b/include/sha1.h
index c3469333c27..d927cd26ad9 100644
--- a/include/sha1.h
+++ b/include/sha1.h
@@ -1,8 +1,7 @@
#ifndef SHA1_INCLUDED
#define SHA1_INCLUDED
-/* Copyright (c) 2002, 2006 MySQL AB, 2009 Sun Microsystems, Inc.
- Use is subject to license terms.
+/* Copyright (c) 2013, Monty Program Ab
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
@@ -18,88 +17,9 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/*
- This is the header file for code which implements the Secure
- Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
- April 17, 1995.
-
- Many of the variable names in this code, especially the
- single character names, were used because those were the names
- used in the publication.
-
- Please read the file sha1.c for more information.
-
- Modified 2002 by Peter Zaitsev to better follow MySQL standards
-
- Original Source from: http://www.faqs.org/rfcs/rfc3174.html
-
- Copyright (C) The Internet Society (2001). All Rights Reserved.
-
- This document and translations of it may be copied and furnished to
- others, and derivative works that comment on or otherwise explain it
- or assist in its implementation may be prepared, copied, published
- and distributed, in whole or in part, without restriction of any
- kind, provided that the above copyright notice and this paragraph are
- included on all such copies and derivative works. However, this
- document itself may not be modified in any way, such as by removing
- the copyright notice or references to the Internet Society or other
- Internet organizations, except as needed for the purpose of
- developing Internet standards in which case the procedures for
- copyrights defined in the Internet Standards process must be
- followed, or as required to translate it into languages other than
- English.
-
- The limited permissions granted above are perpetual and will not be
- revoked by the Internet Society or its successors or assigns.
-
- This document and the information contained herein is provided on an
- "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
- TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
- BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
- HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-
- Acknowledgement
- Funding for the RFC Editor function is currently provided by the
- Internet Society.
-*/
-
-
-enum sha_result_codes
-{
- SHA_SUCCESS = 0,
- SHA_NULL, /* Null pointer parameter */
- SHA_INPUT_TOO_LONG, /* input data too long */
- SHA_STATE_ERROR /* called Input after Result */
-};
-
-#define SHA1_HASH_SIZE 20 /* Hash size in bytes */
-
-/*
- This structure will hold context information for the SHA-1
- hashing operation
-*/
-
-typedef struct SHA1_CONTEXT
-{
- ulonglong Length; /* Message length in bits */
- uint32 Intermediate_Hash[SHA1_HASH_SIZE/4]; /* Message Digest */
- int Computed; /* Is the digest computed? */
- int Corrupted; /* Is the message digest corrupted? */
- int16 Message_Block_Index; /* Index into message block array */
- uint8 Message_Block[64]; /* 512-bit message blocks */
-} SHA1_CONTEXT;
-
-/*
- Function Prototypes
-*/
-
-C_MODE_START
-
-int mysql_sha1_reset(SHA1_CONTEXT*);
-int mysql_sha1_input(SHA1_CONTEXT*, const uint8 *, unsigned int);
-int mysql_sha1_result(SHA1_CONTEXT* , uint8 Message_Digest[SHA1_HASH_SIZE]);
-
-C_MODE_END
+#include <mysql/service_sha1.h>
+#define SHA1_HASH_SIZE MY_SHA1_HASH_SIZE
+#define compute_sha1_hash(A,B,C) my_sha1(A,B,C)
+#define compute_sha1_hash_multi(A,B,C,D,E) my_sha1_multi(A,B,C,D,E,NULL)
#endif /* SHA__INCLUDED */
diff --git a/include/sql_common.h b/include/sql_common.h
index a1c9faac82d..39b8ce18517 100644
--- a/include/sql_common.h
+++ b/include/sql_common.h
@@ -21,6 +21,7 @@ extern "C" {
#endif
#include <mysql.h>
+#include <hash.h>
extern const char *unknown_sqlstate;
extern const char *cant_connect_sqlstate;
@@ -32,6 +33,8 @@ struct mysql_async_context;
struct st_mysql_options_extention {
char *plugin_dir;
char *default_auth;
+ char *ssl_crl; /* PEM CRL file */
+ char *ssl_crlpath; /* PEM directory of CRL-s? */
void (*report_progress)(const MYSQL *mysql,
unsigned int stage,
unsigned int max_stage,
@@ -39,6 +42,8 @@ struct st_mysql_options_extention {
const char *proc_info,
uint proc_info_length);
struct mysql_async_context *async_context;
+ HASH connection_attributes;
+ size_t connection_attributes_length;
};
typedef struct st_mysql_methods
@@ -112,6 +117,7 @@ int mysql_client_plugin_init();
void mysql_client_plugin_deinit();
struct st_mysql_client_plugin;
extern struct st_mysql_client_plugin *mysql_client_builtins[];
+uchar * send_client_connect_attrs(MYSQL *mysql, uchar *buf);
/* Non-blocking client API. */
void my_context_install_suspend_resume_hook(struct mysql_async_context *b,
diff --git a/include/sslopt-case.h b/include/sslopt-case.h
index 2da5ff317e1..4a8c65948cb 100644
--- a/include/sslopt-case.h
+++ b/include/sslopt-case.h
@@ -22,11 +22,18 @@
case OPT_SSL_CA:
case OPT_SSL_CAPATH:
case OPT_SSL_CIPHER:
+ case OPT_SSL_CRL:
+ case OPT_SSL_CRLPATH:
/*
Enable use of SSL if we are using any ssl option
One can disable SSL later by using --skip-ssl or --ssl=0
*/
opt_use_ssl= 1;
+ /* crl has no effect in yaSSL */
+#ifdef HAVE_YASSL
+ opt_ssl_crl= NULL;
+ opt_ssl_crlpath= NULL;
+#endif
break;
#endif
#endif /* SSLOPT_CASE_INCLUDED */
diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h
index 81d03e54016..e605d0134e7 100644
--- a/include/sslopt-longopts.h
+++ b/include/sslopt-longopts.h
@@ -39,6 +39,13 @@
{"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl).",
&opt_ssl_key, &opt_ssl_key, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
+ {"ssl-crl", OPT_SSL_KEY, "Certificate revocation list (implies --ssl).",
+ &opt_ssl_crl, &opt_ssl_crl, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
+ {"ssl-crlpath", OPT_SSL_KEY,
+ "Certificate revocation list path (implies --ssl).",
+ &opt_ssl_crlpath, &opt_ssl_crlpath, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
#ifdef MYSQL_CLIENT
{"ssl-verify-server-cert", OPT_SSL_VERIFY_SERVER_CERT,
"Verify server's \"Common Name\" in its cert against hostname used "
diff --git a/include/sslopt-vars.h b/include/sslopt-vars.h
index 01093feceaf..8e669760faf 100644
--- a/include/sslopt-vars.h
+++ b/include/sslopt-vars.h
@@ -22,12 +22,14 @@
#else
#define SSL_STATIC static
#endif
-SSL_STATIC my_bool opt_use_ssl = 0;
-SSL_STATIC char *opt_ssl_ca = 0;
-SSL_STATIC char *opt_ssl_capath = 0;
-SSL_STATIC char *opt_ssl_cert = 0;
-SSL_STATIC char *opt_ssl_cipher = 0;
-SSL_STATIC char *opt_ssl_key = 0;
+SSL_STATIC my_bool opt_use_ssl = 0;
+SSL_STATIC char *opt_ssl_ca = 0;
+SSL_STATIC char *opt_ssl_capath = 0;
+SSL_STATIC char *opt_ssl_cert = 0;
+SSL_STATIC char *opt_ssl_cipher = 0;
+SSL_STATIC char *opt_ssl_key = 0;
+SSL_STATIC char *opt_ssl_crl = 0;
+SSL_STATIC char *opt_ssl_crlpath = 0;
#ifdef MYSQL_CLIENT
SSL_STATIC my_bool opt_ssl_verify_server_cert= 0;
#endif
diff --git a/include/thread_pool_priv.h b/include/thread_pool_priv.h
index a199923ff00..4270c32c826 100644
--- a/include/thread_pool_priv.h
+++ b/include/thread_pool_priv.h
@@ -49,9 +49,6 @@ void thd_set_killed(THD *thd);
void thd_clear_errors(THD *thd);
void thd_set_thread_stack(THD *thd, char *stack_start);
void thd_lock_thread_count(THD *thd);
-void thd_unlock_thread_count(THD *thd);
-void thd_lock_thread_remove(THD *thd);
-void thd_unlock_thread_remove(THD *thd);
void thd_close_connection(THD *thd);
THD *thd_get_current_thd();
void thd_lock_data(THD *thd);
diff --git a/include/violite.h b/include/violite.h
index da58de4373c..a7165ca91a9 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -1,4 +1,5 @@
-/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+ Copyright (c) 2012 Monty Program Ab
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
@@ -10,8 +11,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/*
* Vio Lite.
@@ -21,8 +22,8 @@
#ifndef vio_violite_h_
#define vio_violite_h_
-#include "my_net.h" /* needed because of struct in_addr */
-
+#include "my_net.h" /* needed because of struct in_addr */
+#include <mysql/psi/mysql_socket.h>
/* Simple vio interface in C; The functions are implemented in violite.c */
@@ -40,12 +41,23 @@ enum enum_vio_type
VIO_TYPE_SSL, VIO_TYPE_SHARED_MEMORY
};
+/**
+ VIO I/O events.
+*/
+enum enum_vio_io_event
+{
+ VIO_IO_EVENT_READ,
+ VIO_IO_EVENT_WRITE,
+ VIO_IO_EVENT_CONNECT
+};
#define VIO_LOCALHOST 1 /* a localhost connection */
#define VIO_BUFFERED_READ 2 /* use buffered read */
#define VIO_READ_BUFFER_SIZE 16384 /* size of read buffer */
+#define VIO_DESCRIPTION_SIZE 30 /* size of description */
-Vio* vio_new(my_socket sd, enum enum_vio_type type, uint flags);
+Vio* vio_new(my_socket sd, enum enum_vio_type type, uint flags);
+Vio* mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum enum_vio_type type, uint flags);
#ifdef __WIN__
Vio* vio_new_win32pipe(HANDLE hPipe);
Vio* vio_new_win32shared_memory(HANDLE handle_file_map,
@@ -59,13 +71,10 @@ Vio* vio_new_win32shared_memory(HANDLE handle_file_map,
#define HANDLE void *
#endif /* __WIN__ */
-/* backport from 5.6 where it is part of PSI, not vio_*() */
-int mysql_socket_shutdown(my_socket mysql_socket, int how);
-
void vio_delete(Vio* vio);
int vio_close(Vio* vio);
-void vio_reset(Vio* vio, enum enum_vio_type type,
- my_socket sd, HANDLE hPipe, uint flags);
+my_bool vio_reset(Vio* vio, enum enum_vio_type type,
+ my_socket sd, void *ssl, uint flags);
size_t vio_read(Vio *vio, uchar * buf, size_t size);
size_t vio_read_buff(Vio *vio, uchar * buf, size_t size);
size_t vio_write(Vio *vio, const uchar * buf, size_t size);
@@ -78,7 +87,7 @@ int vio_keepalive(Vio *vio, my_bool onoff);
/* Whenever we should retry the last read/write operation. */
my_bool vio_should_retry(Vio *vio);
/* Check that operation was timed out */
-my_bool vio_was_interrupted(Vio *vio);
+my_bool vio_was_timeout(Vio *vio);
/* Short text description of the socket for those, who are curious.. */
const char* vio_description(Vio *vio);
/* Return the type of the connection */
@@ -89,9 +98,19 @@ int vio_errno(Vio*vio);
my_socket vio_fd(Vio*vio);
/* Remote peer's address and name in text form */
my_bool vio_peer_addr(Vio *vio, char *buf, uint16 *port, size_t buflen);
-my_bool vio_poll_read(Vio *vio, uint timeout);
+/* 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),
+ void (*after_wait)(void));
+/* Connect to a peer. */
+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,
char *ip_string, size_t ip_string_size);
@@ -111,6 +130,10 @@ int vio_getnameinfo(const struct sockaddr *sa,
#define DES_set_key_unchecked(k,ks) des_set_key_unchecked((k),*(ks))
#define DES_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e) des_ede3_cbc_encrypt((i),(o),(l),*(k1),*(k2),*(k3),(iv),(e))
#endif
+/* apple deprecated openssl in MacOSX Lion */
+#ifdef __APPLE__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
#define HEADER_DES_LOCL_H dummy_something
#define YASSL_MYSQL_COMPATIBLE
@@ -131,7 +154,7 @@ enum enum_ssl_init_error
{
SSL_INITERR_NOERROR= 0, SSL_INITERR_CERT, SSL_INITERR_KEY,
SSL_INITERR_NOMATCH, SSL_INITERR_BAD_PATHS, SSL_INITERR_CIPHERS,
- SSL_INITERR_MEMFAIL, SSL_INITERR_LASTERR
+ SSL_INITERR_MEMFAIL, SSL_INITERR_DH, SSL_INITERR_LASTERR
};
const char* sslGetErrString(enum enum_ssl_init_error err);
@@ -146,11 +169,13 @@ int sslconnect(struct st_VioSSLFd*, Vio *, long timeout, unsigned long *errptr);
struct st_VioSSLFd
*new_VioSSLConnectorFd(const char *key_file, const char *cert_file,
const char *ca_file, const char *ca_path,
- const char *cipher, enum enum_ssl_init_error* error);
+ const char *cipher, enum enum_ssl_init_error *error,
+ const char *crl_file, const char *crl_path);
struct st_VioSSLFd
*new_VioSSLAcceptorFd(const char *key_file, const char *cert_file,
const char *ca_file,const char *ca_path,
- const char *cipher, enum enum_ssl_init_error* error);
+ const char *cipher, enum enum_ssl_init_error *error,
+ const char *crl_file, const char *crl_path);
void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd);
#endif /* HAVE_OPENSSL */
@@ -171,12 +196,11 @@ void vio_end(void);
#define vio_fastsend(vio) (vio)->fastsend(vio)
#define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive)
#define vio_should_retry(vio) (vio)->should_retry(vio)
-#define vio_was_interrupted(vio) (vio)->was_interrupted(vio)
+#define vio_was_timeout(vio) (vio)->was_timeout(vio)
#define vio_close(vio) ((vio)->vioclose)(vio)
#define vio_shutdown(vio,how) ((vio)->shutdown)(vio,how)
#define vio_peer_addr(vio, buf, prt, buflen) (vio)->peer_addr(vio, buf, prt, buflen)
-#define vio_timeout(vio, which, seconds) (vio)->timeout(vio, which, seconds)
-#define vio_poll_read(vio, timeout) (vio)->poll_read(vio, timeout)
+#define vio_io_wait(vio, event, timeout) (vio)->io_wait(vio, event, timeout)
#define vio_is_connected(vio) (vio)->is_connected(vio)
#endif /* !defined(DONT_MAP_VIO) */
@@ -212,26 +236,27 @@ enum SSL_type
/* This structure is for every connection on both sides */
struct st_vio
{
- my_socket sd; /* my_socket - real or imaginary */
- HANDLE hPipe;
+ MYSQL_SOCKET mysql_socket; /* Instrumented socket */
my_bool localhost; /* Are we from localhost? */
int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
- struct sockaddr_storage local; /* Local internet address */
- struct sockaddr_storage remote; /* Remote internet address */
+ 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 */
- char desc[30]; /* String description */
+ const char *desc; /* String description */
char *read_buffer; /* buffer for vio_read_buff */
char *read_pos; /* start of unfetched data in the
read buffer */
char *read_end; /* end of unfetched data */
struct mysql_async_context *async_context; /* For non-blocking API */
- uint read_timeout, write_timeout;
+ int read_timeout; /* Timeout value (ms) for read ops. */
+ int write_timeout; /* Timeout value (ms) for write ops. */
/* function pointers. They are similar for socket/SSL/whatever */
void (*viodelete)(Vio*);
int (*vioerrno)(Vio*);
size_t (*read)(Vio*, uchar *, size_t);
size_t (*write)(Vio*, const uchar *, size_t);
+ int (*timeout)(Vio*, uint, my_bool);
int (*vioblocking)(Vio*, my_bool, my_bool *);
my_bool (*is_blocking)(Vio*);
int (*viokeepalive)(Vio*, my_bool);
@@ -239,13 +264,13 @@ struct st_vio
my_bool (*peer_addr)(Vio*, char *, uint16*, size_t);
void (*in_addr)(Vio*, struct sockaddr_storage*);
my_bool (*should_retry)(Vio*);
- my_bool (*was_interrupted)(Vio*);
+ my_bool (*was_timeout)(Vio*);
int (*vioclose)(Vio*);
- void (*timeout)(Vio*, unsigned int which, unsigned int timeout);
- my_bool (*poll_read)(Vio *vio, uint timeout);
my_bool (*is_connected)(Vio*);
int (*shutdown)(Vio *, int);
my_bool (*has_data) (Vio*);
+ int (*io_wait)(Vio*, enum enum_vio_io_event, int);
+ my_bool (*connect)(Vio*, struct sockaddr *, socklen_t, int);
#ifdef HAVE_OPENSSL
void *ssl_arg;
#endif
@@ -261,8 +286,9 @@ struct st_vio
char *shared_memory_pos;
#endif /* HAVE_SMEM */
#ifdef _WIN32
+ HANDLE hPipe;
+ OVERLAPPED overlapped;
DWORD thread_id; /* Used on XP only by vio_shutdown() */
- OVERLAPPED pipe_overlapped;
DWORD read_timeout_ms;
DWORD write_timeout_ms;
#endif