summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/hash.h17
-rw-r--r--include/heap.h1
-rw-r--r--include/my_alloc.h6
-rw-r--r--include/my_bit.h48
-rw-r--r--include/my_compiler.h8
-rw-r--r--include/my_cpu.h1
-rw-r--r--include/my_pthread.h13
-rw-r--r--include/my_stack_alloc.h4
-rw-r--r--include/my_sys.h44
-rw-r--r--include/mysql.h11
-rw-r--r--include/mysql.h.pp18
-rw-r--r--include/mysql/psi/mysql_file.h481
-rw-r--r--include/mysql/psi/mysql_idle.h6
-rw-r--r--include/mysql/psi/mysql_mdl.h143
-rw-r--r--include/mysql/psi/mysql_memory.h79
-rw-r--r--include/mysql/psi/mysql_ps.h108
-rw-r--r--include/mysql/psi/mysql_socket.h116
-rw-r--r--include/mysql/psi/mysql_sp.h104
-rw-r--r--include/mysql/psi/mysql_stage.h134
-rw-r--r--include/mysql/psi/mysql_statement.h25
-rw-r--r--include/mysql/psi/mysql_table.h91
-rw-r--r--include/mysql/psi/mysql_thread.h72
-rw-r--r--include/mysql/psi/mysql_transaction.h220
-rw-r--r--include/mysql/psi/psi.h899
-rw-r--r--include/mysql/psi/psi_abi_v0.h2
-rw-r--r--include/mysql/psi/psi_abi_v0.h.pp53
-rw-r--r--include/mysql/psi/psi_abi_v1.h.pp283
-rw-r--r--include/mysql/psi/psi_abi_v2.h2
-rw-r--r--include/mysql/psi/psi_abi_v2.h.pp91
-rw-r--r--include/mysql/psi/psi_base.h33
-rw-r--r--include/mysql/psi/psi_memory.h18
-rw-r--r--include/mysql_com.h20
-rw-r--r--include/pfs_file_provider.h92
-rw-r--r--include/pfs_idle_provider.h48
-rw-r--r--include/pfs_memory_provider.h57
-rw-r--r--include/pfs_metadata_provider.h67
-rw-r--r--include/pfs_socket_provider.h71
-rw-r--r--include/pfs_stage_provider.h52
-rw-r--r--include/pfs_statement_provider.h118
-rw-r--r--include/pfs_table_provider.h83
-rw-r--r--include/pfs_thread_provider.h170
-rw-r--r--include/pfs_transaction_provider.h79
-rw-r--r--include/thread_pool_priv.h6
-rw-r--r--include/violite.h5
44 files changed, 3379 insertions, 620 deletions
diff --git a/include/hash.h b/include/hash.h
index fd64bf4c5df..00ffca503fc 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -63,13 +63,12 @@ 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_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);
+#define my_hash_init(A,B,C,D,E,F,G,H,I) my_hash_init2(A,B,0,C,D,E,F,G,0,H,I)
+my_bool my_hash_init2(PSI_memory_key psi_key, 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);
void my_hash_reset(HASH *hash);
uchar *my_hash_element(HASH *hash, size_t idx);
@@ -99,8 +98,8 @@ 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,B,C,D,E,F,G,H))
+#define my_hash_init_opt(A,B,C,D,E,F,G,H,I) \
+ (!my_hash_inited(B) && my_hash_init(A,B,C,D,E,F,G,H,I))
#ifdef __cplusplus
}
diff --git a/include/heap.h b/include/heap.h
index ca6efa48f1b..b734f8ae88d 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -153,7 +153,6 @@ typedef struct st_heap_share
char * name; /* Name of "memory-file" */
time_t create_time;
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;
diff --git a/include/my_alloc.h b/include/my_alloc.h
index 9b0aad26956..181f637c093 100644
--- a/include/my_alloc.h
+++ b/include/my_alloc.h
@@ -20,6 +20,8 @@
#ifndef _my_alloc_h
#define _my_alloc_h
+#include <mysql/psi/psi_memory.h>
+
#define ALLOC_MAX_BLOCK_TO_DROP 4096
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
@@ -43,7 +45,6 @@ typedef struct st_mem_root
/* if block have less memory it will be put in 'used' list */
size_t min_malloc;
size_t block_size; /* initial block size */
- size_t total_alloc;
unsigned int block_num; /* allocated blocks counter */
/*
first free block in queue test counter (if it exceed
@@ -52,7 +53,8 @@ typedef struct st_mem_root
unsigned int first_block_usage;
void (*error_handler)(void);
- const char *name;
+
+ PSI_memory_key m_psi_key;
} MEM_ROOT;
#ifdef __cplusplus
diff --git a/include/my_bit.h b/include/my_bit.h
index ccdf5a069e1..ca51c9825b6 100644
--- a/include/my_bit.h
+++ b/include/my_bit.h
@@ -25,16 +25,50 @@ C_MODE_START
extern const uchar _my_bits_reverse_table[256];
+
/*
- Find smallest X in 2^X >= value
- This can be used to divide a number with value by doing a shift instead
-*/
+ my_bit_log2_xxx()
+
+ In the given value, find the highest bit set,
+ which is the smallest X that satisfies the condition: (2^X >= value).
+ Can be used as a reverse operation for (1<<X), to find X.
+
+ Examples:
+ - returns 0 for (1<<0)
+ - returns 1 for (1<<1)
+ - returns 2 for (1<<2)
+ - returns 2 for 3, which has (1<<2) as the highest bit set.
-static inline uint my_bit_log2(ulong value)
+ Note, the behaviour of log2(0) is not defined.
+ Let's return 0 for the input 0, for the code simplicity.
+ See the 000x branch. It covers both (1<<0) and 0.
+*/
+static inline CONSTEXPR uint my_bit_log2_hex_digit(uint8 value)
{
- uint bit;
- for (bit=0 ; value > 1 ; value>>=1, bit++) ;
- return bit;
+ return value & 0x0C ? /*1100*/ (value & 0x08 ? /*1000*/ 3 : /*0100*/ 2) :
+ /*0010*/ (value & 0x02 ? /*0010*/ 1 : /*000x*/ 0);
+}
+static inline CONSTEXPR uint my_bit_log2_uint8(uint8 value)
+{
+ return value & 0xF0 ? my_bit_log2_hex_digit(value >> 4) + 4:
+ my_bit_log2_hex_digit(value);
+}
+static inline CONSTEXPR uint my_bit_log2_uint16(uint16 value)
+{
+ return value & 0xFF00 ? my_bit_log2_uint8((uint8) (value >> 8)) + 8 :
+ my_bit_log2_uint8((uint8) value);
+}
+static inline CONSTEXPR uint my_bit_log2_uint32(uint32 value)
+{
+ return value & 0xFFFF0000UL ?
+ my_bit_log2_uint16((uint16) (value >> 16)) + 16 :
+ my_bit_log2_uint16((uint16) value);
+}
+static inline CONSTEXPR uint my_bit_log2_uint64(ulonglong value)
+{
+ return value & 0xFFFFFFFF00000000ULL ?
+ my_bit_log2_uint32((uint32) (value >> 32)) + 32 :
+ my_bit_log2_uint32((uint32) value);
}
diff --git a/include/my_compiler.h b/include/my_compiler.h
index 902ef6992a2..8e37f8bcd19 100644
--- a/include/my_compiler.h
+++ b/include/my_compiler.h
@@ -28,6 +28,14 @@
Compiler-dependent internal convenience macros.
*/
+/* C vs C++ */
+#ifdef __cplusplus
+#define CONSTEXPR constexpr
+#else
+#define CONSTEXPR
+#endif /* __cplusplus */
+
+
/* GNU C/C++ */
#if defined __GNUC__
/* Convenience macro to test the minimum required GCC version. */
diff --git a/include/my_cpu.h b/include/my_cpu.h
index b7d7008a8e3..fba04ccea66 100644
--- a/include/my_cpu.h
+++ b/include/my_cpu.h
@@ -54,6 +54,7 @@
#elif defined HAVE_PAUSE_INSTRUCTION
#elif defined(_ARCH_PWR8)
#else
+# include "my_global.h"
# include "my_atomic.h"
#endif
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 17813047ce5..0c67dc95765 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -116,7 +116,7 @@ int pthread_cancel(pthread_t thread);
#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
#define pthread_key_delete(A) TlsFree(A)
#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
-#define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
+#define pthread_setspecific(A,B) (!TlsSetValue((A),(LPVOID)(B)))
#define pthread_getspecific(A) (TlsGetValue(A))
#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V))
@@ -739,18 +739,7 @@ extern uint my_thread_end_wait_time;
extern my_bool safe_mutex_deadlock_detector;
#define my_thread_var (_my_thread_var())
#define my_errno my_thread_var->thr_errno
-/*
- Keep track of shutdown,signal, and main threads so that my_end() will not
- report errors with them
-*/
-
-/* Which kind of thread library is in use */
-
-#define THD_LIB_OTHER 1
-#define THD_LIB_NPTL 2
-#define THD_LIB_LT 4
-extern uint thd_lib_detected;
/*
thread_safe_xxx functions are for critical statistic or counters.
diff --git a/include/my_stack_alloc.h b/include/my_stack_alloc.h
index 2d5a721856d..95e746d6fe7 100644
--- a/include/my_stack_alloc.h
+++ b/include/my_stack_alloc.h
@@ -68,14 +68,14 @@ do \
else \
{ \
(must_be_freed)= 1; \
- (res)= my_malloc(size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
+ (res)= my_malloc(PSI_INSTRUMENT_ME, size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
} \
} while(0)
#else
#define alloc_on_stack(stack_end, res, must_be_freed, size) \
do { \
(must_be_freed)= 1; \
- (res)= my_malloc(size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
+ (res)= my_malloc(PSI_INSTRUMENT_ME, size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
} while(0)
#endif /* HAVE_ALLOCA */
diff --git a/include/my_sys.h b/include/my_sys.h
index 31e59b6bf47..3d271c93a17 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -18,6 +18,7 @@
#define _my_sys_h
#include <m_string.h>
+#include <mysql/psi/mysql_memory.h>
C_MODE_START
@@ -89,14 +90,12 @@ typedef struct my_aio_result {
#define MY_ZEROFILL 32U /* my_malloc(), fill array with zero */
#define MY_ALLOW_ZERO_PTR 64U /* my_realloc() ; zero ptr -> malloc */
#define MY_FREE_ON_ERROR 128U /* my_realloc() ; Free old ptr on error */
-#define MY_HOLD_ON_ERROR 256U /* my_realloc() ; Return old ptr on error */
#define MY_DONT_OVERWRITE_FILE 2048U /* my_copy: Don't overwrite file */
#define MY_THREADSAFE 2048U /* my_seek(): lock fd mutex */
#define MY_SYNC 4096U /* my_copy(): sync dst file */
#define MY_SYNC_DIR 32768U /* my_create/delete/rename: sync directory */
#define MY_SYNC_FILESIZE 65536U /* my_sync(): safe sync when file is extended */
#define MY_THREAD_SPECIFIC 0x10000U /* my_malloc(): thread specific */
-#define MY_THREAD_MOVE 0x20000U /* realloc(); Memory can move */
/* Tree that should delete things automatically */
#define MY_TREE_WITH_DELETE 0x40000U
@@ -168,14 +167,14 @@ 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_malloc(PSI_memory_key key, size_t size, myf MyFlags);
+extern void *my_multi_malloc(PSI_memory_key key, myf MyFlags, ...);
+extern void *my_multi_malloc_large(PSI_memory_key key, myf MyFlags, ...);
+extern void *my_realloc(PSI_memory_key key, void *ptr, 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 void *my_memdup(PSI_memory_key key, const void *from,size_t length,myf MyFlags);
+extern char *my_strdup(PSI_memory_key key, const char *from,myf MyFlags);
+extern char *my_strndup(PSI_memory_key key, const char *from, size_t length, myf MyFlags);
#ifdef HAVE_LINUX_LARGE_PAGES
extern uint my_get_large_page_size(void);
@@ -211,11 +210,11 @@ extern my_bool my_may_have_atomic_write;
#define MAX_ALLOCA_SZ 4096
#define my_safe_alloca(size) (((size) <= MAX_ALLOCA_SZ) ? \
my_alloca(size) : \
- my_malloc((size), MYF(MY_THREAD_SPECIFIC|MY_WME)))
+ my_malloc(PSI_NOT_INSTRUMENTED, (size), MYF(MY_THREAD_SPECIFIC|MY_WME)))
#define my_safe_afree(ptr, size) \
do { if ((size) > MAX_ALLOCA_SZ) my_free(ptr); } while(0)
#else
-#define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE))
+#define my_alloca(SZ) my_malloc(PSI_NOT_INSTRUMENTED, SZ,MYF(MY_FAE))
#define my_afree(PTR) my_free(PTR)
#define my_safe_alloca(size) my_alloca(size)
#define my_safe_afree(ptr, size) my_afree(ptr)
@@ -353,6 +352,7 @@ typedef struct st_dynamic_array
uint elements,max_element;
uint alloc_increment;
uint size_of_element;
+ PSI_memory_key m_psi_key;
myf malloc_flags;
} DYNAMIC_ARRAY;
@@ -508,6 +508,8 @@ typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
extern my_error_reporter my_charset_error_reporter;
+extern PSI_file_key key_file_io_cache;
+
/* inline functions for mf_iocache */
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
@@ -800,6 +802,10 @@ my_off_t my_get_ptr(uchar *ptr, size_t pack_length);
extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize,
enum cache_type type,my_off_t seek_offset,
my_bool use_async_io, myf cache_myflags);
+extern int init_io_cache_ext(IO_CACHE *info, File file, size_t cachesize,
+ enum cache_type type, my_off_t seek_offset,
+ pbool use_async_io, myf cache_myflags,
+ PSI_file_key file_key);
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
my_off_t seek_offset, my_bool use_async_io,
my_bool clear_cache);
@@ -835,11 +841,12 @@ 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,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, myf my_flags);
+#define my_init_dynamic_array(A,B,C,D,E,F) init_dynamic_array2(A,B,C,NULL,D,E,F)
+#define my_init_dynamic_array2(A,B,C,D,E,F,G) init_dynamic_array2(A,B,C,D,E,F,G)
+extern my_bool init_dynamic_array2(PSI_memory_key psi_key, DYNAMIC_ARRAY *array,
+ uint element_size, void *init_buffer,
+ uint init_alloc, 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*);
@@ -886,13 +893,14 @@ extern uint32 copy_and_convert_extended(char *to, uint32 to_length,
extern void *my_malloc_lock(size_t length,myf flags);
extern void my_free_lock(void *ptr);
#else
-#define my_malloc_lock(A,B) my_malloc((A),(B))
+#define my_malloc_lock(A,B) my_malloc(PSI_INSTRUMENT_ME, (A),(B))
#define my_free_lock(A) my_free((A))
#endif
+#define root_name(A) ""
#define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
-extern void init_alloc_root(MEM_ROOT *mem_root, const char *name,
+extern void init_alloc_root(PSI_memory_key key, MEM_ROOT *mem_root,
size_t block_size, size_t pre_alloc_size,
myf my_flags);
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
diff --git a/include/mysql.h b/include/mysql.h
index ec49ca0482a..6ff4c6d3fad 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -97,6 +97,9 @@ extern char *mysql_unix_port;
#define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING)
+typedef struct st_mysql_const_lex_string MARIADB_CONST_STRING;
+
+
typedef struct st_mysql_field {
char *name; /* Name of column */
char *org_name; /* Original column name, if an alias */
@@ -411,6 +414,14 @@ MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res);
MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res);
+
+
+
+int STDCALL mariadb_field_attr(MARIADB_CONST_STRING *attr,
+ const MYSQL_FIELD *field,
+ enum mariadb_field_attr_t type);
+
+
unsigned int STDCALL mysql_field_count(MYSQL *mysql);
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index 4fcfab4aea4..051821c2d37 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -28,6 +28,11 @@ enum enum_indicator_type
STMT_INDICATOR_DEFAULT,
STMT_INDICATOR_IGNORE
};
+enum mariadb_field_attr_t
+{
+ MARIADB_FIELD_ATTR_DATA_TYPE_NAME= 0,
+ MARIADB_FIELD_ATTR_FORMAT_NAME= 1
+};
struct st_vio;
typedef struct st_vio Vio;
typedef struct st_net {
@@ -207,6 +212,7 @@ extern int list_walk(LIST *,list_walk_action action,unsigned char * argument);
extern unsigned int mariadb_deinitialize_ssl;
extern unsigned int mysql_port;
extern char *mysql_unix_port;
+typedef struct st_mysql_const_lex_string MARIADB_CONST_STRING;
typedef struct st_mysql_field {
char *name;
char *org_name;
@@ -234,6 +240,12 @@ typedef char **MYSQL_ROW;
typedef unsigned int MYSQL_FIELD_OFFSET;
typedef unsigned long long my_ulonglong;
extern "C" {
+}
+extern "C" {
+struct PSI_thread;
+typedef unsigned int PSI_memory_key;
+}
+extern "C" {
typedef struct st_used_mem
{
struct st_used_mem *next;
@@ -247,11 +259,10 @@ typedef struct st_mem_root
USED_MEM *pre_alloc;
size_t min_malloc;
size_t block_size;
- size_t total_alloc;
unsigned int block_num;
unsigned int first_block_usage;
void (*error_handler)(void);
- const char *name;
+ PSI_memory_key m_psi_key;
} MEM_ROOT;
}
typedef struct st_typelib {
@@ -436,6 +447,9 @@ MYSQL_FIELD * mysql_fetch_field_direct(MYSQL_RES *res,
MYSQL_FIELD * mysql_fetch_fields(MYSQL_RES *res);
MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *res);
MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES *res);
+int mariadb_field_attr(MARIADB_CONST_STRING *attr,
+ const MYSQL_FIELD *field,
+ enum mariadb_field_attr_t type);
unsigned int mysql_field_count(MYSQL *mysql);
my_ulonglong mysql_affected_rows(MYSQL *mysql);
my_ulonglong mysql_insert_id(MYSQL *mysql);
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h
index 1d2ec34fc98..761482d0165 100644
--- a/include/mysql/psi/mysql_file.h
+++ b/include/mysql/psi/mysql_file.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2017, 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, version 2.0,
@@ -48,6 +48,10 @@
#include "mysql/psi/psi.h"
+#ifndef PSI_FILE_CALL
+#define PSI_FILE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup File_instrumentation File Instrumentation
@ingroup Instrumentation_interface
@@ -295,7 +299,7 @@
*/
#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)
+ inline_mysql_file_create_temp(K, __FILE__, __LINE__, T, D, P, M, F)
#else
#define mysql_file_create_temp(K, T, D, P, M, F) \
inline_mysql_file_create_temp(T, D, P, M, F)
@@ -536,7 +540,7 @@ inline_mysql_file_fgets(
{
char *result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -564,7 +568,7 @@ inline_mysql_file_fgetc(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -592,7 +596,7 @@ inline_mysql_file_fputs(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -622,7 +626,7 @@ inline_mysql_file_fputc(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -650,7 +654,7 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...)
int result;
va_list args;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -682,7 +686,7 @@ inline_mysql_file_vfprintf(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -710,7 +714,7 @@ inline_mysql_file_fflush(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -744,18 +748,15 @@ inline_mysql_file_fstat(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr, PSI_FILE_FSTAT);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr, PSI_FILE_FSTAT);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_fstat(filenr, stat_area, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ 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
@@ -772,18 +773,15 @@ inline_mysql_file_stat(
{
MY_STAT *result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STAT, path, &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STAT, path, &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- result= my_stat(path, stat_area, flags);
- PSI_FILE_CALL(end_file_open_wait)(locker, result);
- return result;
- }
+ 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
@@ -800,19 +798,16 @@ inline_mysql_file_chsize(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CHSIZE);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CHSIZE);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) newlength, src_file,
- src_line);
- result= my_chsize(file, newlength, filler, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) newlength);
- return result;
- }
+ 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
@@ -828,28 +823,26 @@ inline_mysql_file_fopen(
const char *filename, int flags, myf myFlags)
{
MYSQL_FILE *that;
- that= (MYSQL_FILE*) my_malloc(sizeof(MYSQL_FILE), MYF(MY_WME));
+ that= (MYSQL_FILE*) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(MYSQL_FILE), MYF(MY_WME));
if (likely(that != NULL))
{
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ 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 (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STREAM_OPEN,
- filename, that);
- if (likely(locker != NULL))
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ that->m_file= my_fopen(filename, flags, myFlags);
+ that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
+ if (unlikely(that->m_file == NULL))
{
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- that->m_file= my_fopen(filename, flags, myFlags);
- that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
- if (unlikely(that->m_file == NULL))
- {
- my_free(that);
- return NULL;
- }
- return that;
+ my_free(that);
+ return NULL;
}
+ return that;
}
#endif
@@ -875,7 +868,7 @@ inline_mysql_file_fclose(
if (likely(file != NULL))
{
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -907,7 +900,7 @@ inline_mysql_file_fread(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -940,7 +933,7 @@ inline_mysql_file_fwrite(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -973,7 +966,7 @@ inline_mysql_file_fseek(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -1001,7 +994,7 @@ inline_mysql_file_ftell(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -1029,19 +1022,16 @@ inline_mysql_file_create(
{
File file;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
+ &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
- &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- file= my_create(filename, create_flags, access_flags, myFlags);
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
- return file;
- }
+ 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
@@ -1052,20 +1042,27 @@ inline_mysql_file_create(
static inline File
inline_mysql_file_create_temp(
#ifdef HAVE_PSI_FILE_INTERFACE
- PSI_file_key key,
+ PSI_file_key key, const char *src_file, uint src_line,
#endif
char *to, const char *dir, const char *pfx, int mode, myf myFlags)
{
File file;
- /*
- TODO: This event is instrumented, but not timed.
- The problem is that the file name is now known
- before the create_temp_file call.
- */
- file= create_temp_file(to, dir, pfx, mode, myFlags);
#ifdef HAVE_PSI_FILE_INTERFACE
- PSI_FILE_CALL(create_file)(key, to, file);
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_CREATE, NULL, &locker);
+ if (psi_likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ /* The file name is generated by create_temp_file(). */
+ file= create_temp_file(to, dir, pfx, mode, myFlags);
+ PSI_FILE_CALL(end_temp_file_open_wait_and_bind_to_descriptor)(locker, file, (const char*)to);
+ return file;
+ }
#endif
+
+ file= create_temp_file(to, dir, pfx, mode, myFlags);
return file;
}
@@ -1078,19 +1075,16 @@ inline_mysql_file_open(
{
File file;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_OPEN, filename,
+ &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_OPEN, filename,
- &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- file= my_open(filename, flags, myFlags);
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
- return file;
- }
+ 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
@@ -1107,18 +1101,15 @@ inline_mysql_file_close(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CLOSE);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CLOSE);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_close(file, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
- }
+ 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
@@ -1135,23 +1126,20 @@ inline_mysql_file_read(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_read;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_read(file, buffer, count, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_read= (result == 0) ? count : 0;
- else
- bytes_read= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_read(file, buffer, count, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_read= (result == 0) ? count : 0;
+ else
+ bytes_read= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
}
#endif
@@ -1168,23 +1156,20 @@ inline_mysql_file_write(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_written;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_write(file, buffer, count, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_written= (result == 0) ? count : 0;
- else
- bytes_written= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_write(file, buffer, count, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_written= (result == 0) ? count : 0;
+ else
+ bytes_written= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
}
#endif
@@ -1201,23 +1186,20 @@ inline_mysql_file_pread(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_read;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_pread(file, buffer, count, offset, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_read= (result == 0) ? count : 0;
- else
- bytes_read= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_pread(file, buffer, count, offset, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_read= (result == 0) ? count : 0;
+ else
+ bytes_read= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
}
#endif
@@ -1234,23 +1216,20 @@ inline_mysql_file_pwrite(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_written;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_pwrite(file, buffer, count, offset, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_written= (result == 0) ? count : 0;
- else
- bytes_written= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_pwrite(file, buffer, count, offset, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_written= (result == 0) ? count : 0;
+ else
+ bytes_written= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
}
#endif
@@ -1267,18 +1246,15 @@ inline_mysql_file_seek(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_SEEK);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_SEEK);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_seek(file, pos, whence, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ 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
@@ -1295,18 +1271,15 @@ inline_mysql_file_tell(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_TELL);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_TELL);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_tell(file, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ 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
@@ -1323,18 +1296,15 @@ inline_mysql_file_delete(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, name, &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, name, &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_delete(name, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
- }
+ 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
@@ -1351,18 +1321,16 @@ inline_mysql_file_rename(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_RENAME, from, &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_rename(from, to, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ 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_rename_wait)(locker, from, to, result);
+ return result;
}
#endif
@@ -1381,20 +1349,17 @@ inline_mysql_file_create_with_symlink(
{
File file;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
+ &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
- &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- file= my_create_with_symlink(linkname, filename, create_flags, access_flags,
- flags);
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
- return file;
- }
+ 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
@@ -1415,19 +1380,16 @@ inline_mysql_file_delete_with_symlink(
char buf[FN_REFLEN];
char *fullname= fn_format(buf, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, fullname,
+ &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, fullname,
- &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_handler_delete_with_symlink(fullname, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
- }
+ 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
@@ -1445,18 +1407,16 @@ inline_mysql_file_rename_with_symlink(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_RENAME, from, &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_rename_with_symlink(from, to, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ 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_rename_wait)(locker, from, to, result);
+ return result;
}
#endif
@@ -1473,18 +1433,15 @@ inline_mysql_file_sync(
{
int result= 0;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd, PSI_FILE_SYNC);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd, PSI_FILE_SYNC);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_sync(fd, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_sync(fd, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
}
#endif
diff --git a/include/mysql/psi/mysql_idle.h b/include/mysql/psi/mysql_idle.h
index 1eb19f8f684..f8085073af6 100644
--- a/include/mysql/psi/mysql_idle.h
+++ b/include/mysql/psi/mysql_idle.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- Copyright (c) 2017, MariaDB Corporation.
+ Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -31,6 +31,10 @@
#include "mysql/psi/psi.h"
+#ifndef PSI_IDLE_CALL
+#define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup Idle_instrumentation Idle Instrumentation
@ingroup Instrumentation_interface
diff --git a/include/mysql/psi/mysql_mdl.h b/include/mysql/psi/mysql_mdl.h
new file mode 100644
index 00000000000..20d6c94c57c
--- /dev/null
+++ b/include/mysql/psi/mysql_mdl.h
@@ -0,0 +1,143 @@
+/* Copyright (c) 2012, 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, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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_MDL_H
+#define MYSQL_MDL_H
+
+/**
+ @file mysql/psi/mysql_mdl.h
+ Instrumentation helpers for metadata locks.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+
+#ifndef PSI_METADATA_CALL
+#define PSI_METADATA_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#define PSI_CALL_start_metadata_wait(A,B,C,D) PSI_METADATA_CALL(start_metadata_wait)(A,B,C,D)
+#define PSI_CALL_end_metadata_wait(A,B) PSI_METADATA_CALL(end_metadata_wait)(A,B)
+#define PSI_CALL_create_metadata_lock(A,B,C,D,E,F,G) PSI_METADATA_CALL(create_metadata_lock)(A,B,C,D,E,F,G)
+#define PSI_CALL_set_metadata_lock_status(A,B) PSI_METADATA_CALL(set_metadata_lock_status)(A,B)
+#define PSI_CALL_destroy_metadata_lock(A) PSI_METADATA_CALL(destroy_metadata_lock)(A)
+#else
+#define PSI_CALL_start_metadata_wait(A,B,C,D) 0
+#define PSI_CALL_end_metadata_wait(A,B) do { } while(0)
+#define PSI_CALL_create_metadata_lock(A,B,C,D,E,F,G) 0
+#define PSI_CALL_set_metadata_lock_status(A,B) do {} while(0)
+#define PSI_CALL_destroy_metadata_lock(A) do {} while(0)
+#endif
+
+/**
+ @defgroup Thread_instrumentation Metadata Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ @def mysql_mdl_create(K, M, A)
+ Instrumented metadata lock creation.
+ @param I Metadata lock identity
+ @param K Metadata key
+ @param T Metadata lock type
+ @param D Metadata lock duration
+ @param S Metadata lock status
+ @param F request source file
+ @param L request source line
+*/
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+ #define mysql_mdl_create(I, K, T, D, S, F, L) \
+ inline_mysql_mdl_create(I, K, T, D, S, F, L)
+#else
+ #define mysql_mdl_create(I, K, T, D, S, F, L) NULL
+#endif
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+ #define mysql_mdl_set_status(L, S) \
+ inline_mysql_mdl_set_status(L, S)
+#else
+ #define mysql_mdl_set_status(L, S) \
+ do {} while (0)
+#endif
+
+
+/**
+ @def mysql_mdl_destroy(M)
+ Instrumented metadata lock destruction.
+ @param M Metadata lock
+*/
+#ifdef HAVE_PSI_METADATA_INTERFACE
+ #define mysql_mdl_destroy(M) \
+ inline_mysql_mdl_destroy(M, __FILE__, __LINE__)
+#else
+ #define mysql_mdl_destroy(M) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+
+static inline PSI_metadata_lock *
+inline_mysql_mdl_create(void *identity,
+ const MDL_key *mdl_key,
+ enum_mdl_type mdl_type,
+ enum_mdl_duration mdl_duration,
+ MDL_ticket::enum_psi_status mdl_status,
+ const char *src_file, uint src_line)
+{
+ PSI_metadata_lock *result;
+
+ /* static_cast: Fit a round C++ enum peg into a square C int hole ... */
+ result= PSI_METADATA_CALL(create_metadata_lock)
+ (identity,
+ mdl_key,
+ static_cast<opaque_mdl_type> (mdl_type),
+ static_cast<opaque_mdl_duration> (mdl_duration),
+ static_cast<opaque_mdl_status> (mdl_status),
+ src_file, src_line);
+
+ return result;
+}
+
+static inline void inline_mysql_mdl_set_status(
+ PSI_metadata_lock *psi,
+ MDL_ticket::enum_psi_status mdl_status)
+{
+ if (psi != NULL)
+ PSI_METADATA_CALL(set_metadata_lock_status)(psi, mdl_status);
+}
+
+static inline void inline_mysql_mdl_destroy(
+ PSI_metadata_lock *psi,
+ const char *src_file, uint src_line)
+{
+ if (psi != NULL)
+ PSI_METADATA_CALL(destroy_metadata_lock)(psi);
+}
+#endif /* HAVE_PSI_METADATA_INTERFACE */
+
+/** @} (end of group Metadata_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/mysql_memory.h b/include/mysql/psi/mysql_memory.h
new file mode 100644
index 00000000000..a79579c2e56
--- /dev/null
+++ b/include/mysql/psi/mysql_memory.h
@@ -0,0 +1,79 @@
+/* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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_MEMORY_H
+#define MYSQL_MEMORY_H
+
+/**
+ @file mysql/psi/mysql_memory.h
+ Instrumentation helpers for memory allocation.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifdef HAVE_PSI_MEMORY_INTERFACE
+#define PSI_CALL_memory_alloc(A1,A2,A3) PSI_MEMORY_CALL(memory_alloc)(A1,A2,A3)
+#define PSI_CALL_memory_free(A1,A2,A3) PSI_MEMORY_CALL(memory_free)(A1,A2,A3)
+#define PSI_CALL_memory_realloc(A1,A2,A3,A4) PSI_MEMORY_CALL(memory_realloc)(A1,A2,A3,A4)
+#define PSI_CALL_register_memory(A1,A2,A3) PSI_MEMORY_CALL(register_memory)(A1,A2,A3)
+#else
+#define PSI_CALL_memory_alloc(A1,A2,A3) 0
+#define PSI_CALL_memory_free(A1,A2,A3) do { } while(0)
+#define PSI_CALL_memory_realloc(A1,A2,A3,A4) 0
+#define PSI_CALL_register_memory(A1,A2,A3) do { } while(0)
+#endif
+
+#ifndef PSI_MEMORY_CALL
+#define PSI_MEMORY_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+/**
+ @defgroup Memory_instrumentation Memory Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ @def mysql_memory_register(P1, P2, P3)
+ Memory registration.
+*/
+#define mysql_memory_register(P1, P2, P3) \
+ inline_mysql_memory_register(P1, P2, P3)
+
+static inline void inline_mysql_memory_register(
+#ifdef HAVE_PSI_MEMORY_INTERFACE
+ const char *category,
+ PSI_memory_info *info,
+ int count)
+#else
+ const char *category __attribute__((unused)),
+ void *info __attribute__((unused)),
+ int count __attribute__((unused)))
+#endif
+{
+ PSI_CALL_register_memory(category, info, count);
+}
+
+/** @} (end of group Memory_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/mysql_ps.h b/include/mysql/psi/mysql_ps.h
new file mode 100644
index 00000000000..f0b2733297a
--- /dev/null
+++ b/include/mysql/psi/mysql_ps.h
@@ -0,0 +1,108 @@
+/* Copyright (c) 2014, 2017, 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, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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_PS_H
+#define MYSQL_PS_H
+
+/**
+ @file mysql/psi/mysql_ps.h
+ Instrumentation helpers for prepared statements.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifndef PSI_PS_CALL
+#define PSI_PS_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifdef HAVE_PSI_PS_INTERFACE
+ #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH) \
+ inline_mysql_create_prepared_stmt(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH)
+ #define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \
+ inline_mysql_execute_prepared_stmt(LOCKER, PREPARED_STMT)
+ #define MYSQL_DESTROY_PS(PREPARED_STMT) \
+ inline_mysql_destroy_prepared_stmt(PREPARED_STMT)
+ #define MYSQL_REPREPARE_PS(PREPARED_STMT) \
+ inline_mysql_reprepare_prepared_stmt(PREPARED_STMT)
+ #define MYSQL_SET_PS_TEXT(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) \
+ inline_mysql_set_prepared_stmt_text(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH)
+#else
+ #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH) \
+ NULL
+ #define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \
+ do {} while (0)
+ #define MYSQL_DESTROY_PS(PREPARED_STMT) \
+ do {} while (0)
+ #define MYSQL_REPREPARE_PS(PREPARED_STMT) \
+ do {} while (0)
+ #define MYSQL_SET_PS_TEXT(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_PS_INTERFACE
+static inline struct PSI_prepared_stmt*
+inline_mysql_create_prepared_stmt(void *identity, uint stmt_id,
+ PSI_statement_locker *locker,
+ const char *stmt_name, size_t stmt_name_length)
+{
+ if (locker == NULL)
+ return NULL;
+ return PSI_PS_CALL(create_prepared_stmt)(identity, stmt_id,
+ locker,
+ stmt_name, stmt_name_length);
+}
+
+static inline void
+inline_mysql_execute_prepared_stmt(PSI_statement_locker *locker,
+ PSI_prepared_stmt* prepared_stmt)
+{
+ if (prepared_stmt != NULL && locker != NULL)
+ PSI_PS_CALL(execute_prepared_stmt)(locker, prepared_stmt);
+}
+
+static inline void
+inline_mysql_destroy_prepared_stmt(PSI_prepared_stmt *prepared_stmt)
+{
+ if (prepared_stmt != NULL)
+ PSI_PS_CALL(destroy_prepared_stmt)(prepared_stmt);
+}
+
+static inline void
+inline_mysql_reprepare_prepared_stmt(PSI_prepared_stmt *prepared_stmt)
+{
+ if (prepared_stmt != NULL)
+ PSI_PS_CALL(reprepare_prepared_stmt)(prepared_stmt);
+}
+
+static inline void
+inline_mysql_set_prepared_stmt_text(PSI_prepared_stmt *prepared_stmt,
+ const char *text,
+ uint text_len)
+{
+ if (prepared_stmt != NULL)
+ {
+ PSI_PS_CALL(set_prepared_stmt_text)(prepared_stmt, text, text_len);
+ }
+}
+#endif
+
+#endif
diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h
index d0302edd09b..765c5aa7793 100644
--- a/include/mysql/psi/mysql_socket.h
+++ b/include/mysql/psi/mysql_socket.h
@@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
/* For my_chsize */
#include <my_sys.h>
/* For socket api */
-#ifdef __WIN__
+#ifdef _WIN32
#include <ws2def.h>
#include <winsock2.h>
#include <MSWSock.h>
@@ -47,6 +47,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
#include "mysql/psi/psi.h"
+#ifndef PSI_SOCKET_CALL
+#define PSI_SOCKET_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup Socket_instrumentation Socket Instrumentation
@ingroup Instrumentation_interface
@@ -65,6 +69,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
do {} while (0)
#endif
+/** An instrumented socket. */
struct st_mysql_socket
{
/** The real socket descriptor. */
@@ -107,9 +112,8 @@ mysql_socket_invalid()
/**
Set socket descriptor and address.
@param socket nstrumented socket
- @param fd socket descriptor
@param addr unformatted socket address
- @param adr_len length of socket address
+ @param addr_len length of socket address
*/
static inline void
@@ -134,7 +138,6 @@ mysql_socket_set_address(
/**
Set socket descriptor and address.
@param socket instrumented socket
- @param thread instrumented owning thread
*/
static inline void
mysql_socket_set_thread_owner(
@@ -201,7 +204,6 @@ mysql_socket_setfd(MYSQL_SOCKET *mysql_socket, my_socket fd)
@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.
*/
@@ -230,6 +232,13 @@ mysql_socket_setfd(MYSQL_SOCKET *mysql_socket, my_socket fd)
do {} while (0)
#endif
+/**
+ @def MYSQL_SOCKET_SET_STATE
+ Set the state (IDLE, ACTIVE) of an instrumented socket.
+ @param SOCKET the instrumented socket
+ @param STATE the new state
+ @sa PSI_socket_state
+*/
#ifdef HAVE_PSI_SOCKET_INTERFACE
#define MYSQL_SOCKET_SET_STATE(SOCKET, STATE) \
inline_mysql_socket_set_state(SOCKET, STATE)
@@ -325,8 +334,8 @@ inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
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
+ @param AP Pointer to returned address of local host in @c sockaddr structure
+ @param LP Pointer to length of @c sockaddr structure
*/
#ifdef HAVE_PSI_SOCKET_INTERFACE
#define mysql_socket_getsockname(FD, AP, LP) \
@@ -430,7 +439,7 @@ inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
@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
+ @param LP Size of sockaddr_storage structure
*/
#ifdef HAVE_PSI_SOCKET_INTERFACE
#define mysql_socket_recvfrom(FD, B, N, FL, AP, LP) \
@@ -477,6 +486,19 @@ inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
#endif
/**
+ @def mysql_sock_set_nonblocking
+ Set socket to non-blocking.
+ @param FD instrumented socket descriptor
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_sock_set_nonblocking(FD) \
+ inline_mysql_sock_set_nonblocking(__FILE__, __LINE__, FD)
+#else
+ #define mysql_sock_set_nonblocking(FD) \
+ inline_mysql_sock_set_nonblocking(FD)
+#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.
@@ -972,6 +994,78 @@ inline_mysql_socket_setsockopt
return result;
}
+/** set_socket_nonblock */
+static inline int
+set_socket_nonblock(my_socket fd)
+{
+ int ret= 0;
+#ifdef _WIN32
+ {
+ u_long nonblocking= 1;
+ ret= ioctlsocket(fd, FIONBIO, &nonblocking);
+ }
+#else
+ {
+ int fd_flags;
+ fd_flags= fcntl(fd, F_GETFL, 0);
+ if (fd_flags < 0)
+ return errno;
+#if defined(O_NONBLOCK)
+ fd_flags |= O_NONBLOCK;
+#elif defined(O_NDELAY)
+ fd_flags |= O_NDELAY;
+#elif defined(O_FNDELAY)
+ fd_flags |= O_FNDELAY;
+#else
+#error "No definition of non-blocking flag found."
+#endif /* O_NONBLOCK */
+ if (fcntl(fd, F_SETFL, fd_flags) == -1)
+ ret= errno;
+ }
+#endif /* _WIN32 */
+ return ret;
+}
+
+/** mysql_socket_set_nonblocking */
+
+static inline int
+inline_mysql_sock_set_nonblocking
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket
+)
+{
+ int result= 0;
+
+#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= set_socket_nonblock(mysql_socket.fd);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= set_socket_nonblock(mysql_socket.fd);
+
+ return result;
+}
+
/** mysql_socket_listen */
static inline int
@@ -1136,7 +1230,7 @@ inline_mysql_socket_shutdown
{
int result;
-#ifdef __WIN__
+#ifdef _WIN32
static LPFN_DISCONNECTEX DisconnectEx = NULL;
if (DisconnectEx == NULL)
{
@@ -1159,7 +1253,7 @@ inline_mysql_socket_shutdown
(&state, mysql_socket.m_psi, PSI_SOCKET_SHUTDOWN, (size_t)0, src_file, src_line);
/* Instrumented code */
-#ifdef __WIN__
+#ifdef _WIN32
if (DisconnectEx)
result= (DisconnectEx(mysql_socket.fd, (LPOVERLAPPED) NULL,
(DWORD) 0, (DWORD) 0) == TRUE) ? 0 : -1;
@@ -1176,7 +1270,7 @@ inline_mysql_socket_shutdown
#endif
/* Non instrumented code */
-#ifdef __WIN__
+#ifdef _WIN32
if (DisconnectEx)
result= (DisconnectEx(mysql_socket.fd, (LPOVERLAPPED) NULL,
(DWORD) 0, (DWORD) 0) == TRUE) ? 0 : -1;
diff --git a/include/mysql/psi/mysql_sp.h b/include/mysql/psi/mysql_sp.h
new file mode 100644
index 00000000000..5eeea37f4c4
--- /dev/null
+++ b/include/mysql/psi/mysql_sp.h
@@ -0,0 +1,104 @@
+/* Copyright (c) 2013, 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, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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_SP_H
+#define MYSQL_SP_H
+
+/**
+ @file mysql/psi/mysql_sp.h
+ Instrumentation helpers for stored programs.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifndef PSI_SP_CALL
+#define PSI_SP_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifdef HAVE_PSI_SP_INTERFACE
+ #define MYSQL_START_SP(STATE, SP_SHARE) \
+ inline_mysql_start_sp(STATE, SP_SHARE)
+#else
+ #define MYSQL_START_SP(STATE, SP_SHARE) \
+ NULL
+#endif
+
+
+#ifdef HAVE_PSI_SP_INTERFACE
+ #define MYSQL_END_SP(LOCKER) \
+ inline_mysql_end_sp(LOCKER)
+#else
+ #define MYSQL_END_SP(LOCKER) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_SP_INTERFACE
+ #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
+ inline_mysql_drop_sp(OT, SN, SNL, ON, ONL)
+#else
+ #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_SP_INTERFACE
+ #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
+ inline_mysql_get_sp_share(OT, SN, SNL, ON, ONL)
+#else
+ #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
+ NULL
+#endif
+
+#ifdef HAVE_PSI_SP_INTERFACE
+static inline struct PSI_sp_locker*
+inline_mysql_start_sp(PSI_sp_locker_state *state, PSI_sp_share *sp_share)
+{
+ return PSI_SP_CALL(start_sp)(state, sp_share);
+}
+
+static inline void inline_mysql_end_sp(PSI_sp_locker *locker)
+{
+ if (likely(locker != NULL))
+ PSI_SP_CALL(end_sp)(locker);
+}
+
+static inline void
+inline_mysql_drop_sp(uint sp_type,
+ const char* schema_name, uint shcema_name_length,
+ const char* object_name, uint object_name_length)
+{
+ PSI_SP_CALL(drop_sp)(sp_type,
+ schema_name, shcema_name_length,
+ object_name, object_name_length);
+}
+
+static inline PSI_sp_share*
+inline_mysql_get_sp_share(uint sp_type,
+ const char* schema_name, uint shcema_name_length,
+ const char* object_name, uint object_name_length)
+{
+ return PSI_SP_CALL(get_sp_share)(sp_type,
+ schema_name, shcema_name_length,
+ object_name, object_name_length);
+}
+#endif
+
+#endif
diff --git a/include/mysql/psi/mysql_stage.h b/include/mysql/psi/mysql_stage.h
index 1dbaed6c682..732df6bd357 100644
--- a/include/mysql/psi/mysql_stage.h
+++ b/include/mysql/psi/mysql_stage.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -30,6 +30,10 @@
#include "mysql/psi/psi.h"
+#ifndef PSI_STAGE_CALL
+#define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup Stage_instrumentation Stage Instrumentation
@ingroup Instrumentation_interface
@@ -48,12 +52,48 @@
do {} while (0)
#endif
+/**
+ @def MYSQL_SET_STAGE
+ Set the current stage.
+ Use this API when the file and line
+ is passed from the caller.
+ @param K the stage key
+ @param F the source file name
+ @param L the source file line
+ @return the current stage progress
+*/
#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)
+ NULL
+#endif
+
+/**
+ @def mysql_set_stage
+ Set the current stage.
+ @param K the stage key
+ @return the current stage progress
+*/
+#ifdef HAVE_PSI_STAGE_INTERFACE
+ #define mysql_set_stage(K) \
+ inline_mysql_set_stage(K, __FILE__, __LINE__)
+#else
+ #define mysql_set_stage(K) \
+ NULL
+#endif
+
+/**
+ @def mysql_end_stage
+ End the last stage
+*/
+#ifdef HAVE_PSI_STAGE_INTERFACE
+ #define mysql_end_stage() \
+ inline_mysql_end_stage()
+#else
+ #define mysql_end_stage() \
+ do {} while (0)
#endif
#ifdef HAVE_PSI_STAGE_INTERFACE
@@ -65,11 +105,97 @@ static inline void inline_mysql_stage_register(
#endif
#ifdef HAVE_PSI_STAGE_INTERFACE
-static inline void
+static inline PSI_stage_progress*
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);
+ return PSI_STAGE_CALL(start_stage)(key, src_file, src_line);
+}
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void
+inline_mysql_end_stage()
+{
+ PSI_STAGE_CALL(end_stage)();
+}
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+#define mysql_stage_set_work_completed(P1, P2) \
+ inline_mysql_stage_set_work_completed(P1, P2)
+
+#define mysql_stage_get_work_completed(P1) \
+ inline_mysql_stage_get_work_completed(P1)
+#else
+#define mysql_stage_set_work_completed(P1, P2) \
+ do {} while (0)
+
+#define mysql_stage_get_work_completed(P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+#define mysql_stage_inc_work_completed(P1, P2) \
+ inline_mysql_stage_inc_work_completed(P1, P2)
+#else
+#define mysql_stage_inc_work_completed(P1, P2) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+#define mysql_stage_set_work_estimated(P1, P2) \
+ inline_mysql_stage_set_work_estimated(P1, P2)
+
+#define mysql_stage_get_work_estimated(P1) \
+ inline_mysql_stage_get_work_estimated(P1)
+#else
+#define mysql_stage_set_work_estimated(P1, P2) \
+ do {} while (0)
+
+#define mysql_stage_get_work_estimated(P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void
+inline_mysql_stage_set_work_completed(PSI_stage_progress *progress,
+ ulonglong val)
+{
+ if (progress != NULL)
+ progress->m_work_completed= val;
+}
+
+static inline ulonglong
+inline_mysql_stage_get_work_completed(PSI_stage_progress *progress)
+{
+ return progress->m_work_completed;
+}
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void
+inline_mysql_stage_inc_work_completed(PSI_stage_progress *progress,
+ ulonglong val)
+{
+ if (progress != NULL)
+ progress->m_work_completed+= val;
+}
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void
+inline_mysql_stage_set_work_estimated(PSI_stage_progress *progress,
+ ulonglong val)
+{
+ if (progress != NULL)
+ progress->m_work_estimated= val;
+}
+
+static inline ulonglong
+inline_mysql_stage_get_work_estimated(PSI_stage_progress *progress)
+{
+ return progress->m_work_estimated;
}
#endif
diff --git a/include/mysql/psi/mysql_statement.h b/include/mysql/psi/mysql_statement.h
index 6d38131ea99..fab23d2c5c2 100644
--- a/include/mysql/psi/mysql_statement.h
+++ b/include/mysql/psi/mysql_statement.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
- Copyright (c) 2017, MariaDB Corporation.
+ Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -31,6 +31,17 @@
#include "mysql/psi/psi.h"
+class Diagnostics_area;
+typedef const struct charset_info_st CHARSET_INFO;
+
+#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
+
/**
@defgroup Statement_instrumentation Statement Instrumentation
@ingroup Instrumentation_interface
@@ -66,10 +77,10 @@
#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__)
+ #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS, SPS) \
+ inline_mysql_start_statement(STATE, K, DB, DB_LEN, CS, SPS, __FILE__, __LINE__)
#else
- #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS) \
+ #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS, SPS) \
NULL
#endif
@@ -153,11 +164,13 @@ static inline struct PSI_statement_locker *
inline_mysql_start_statement(PSI_statement_locker_state *state,
PSI_statement_key key,
const char *db, size_t db_len,
- const CHARSET_INFO *charset,
+ CHARSET_INFO *charset,
+ PSI_sp_share *sp_share,
const char *src_file, uint src_line)
{
PSI_statement_locker *locker;
- locker= PSI_STATEMENT_CALL(get_thread_statement_locker)(state, key, charset);
+ locker= PSI_STATEMENT_CALL(get_thread_statement_locker)(state, key, charset,
+ sp_share);
if (psi_likely(locker != NULL))
PSI_STATEMENT_CALL(start_statement)(locker, db, (uint)db_len, src_file, src_line);
return locker;
diff --git a/include/mysql/psi/mysql_table.h b/include/mysql/psi/mysql_table.h
index c1244e38866..5bbe8cef929 100644
--- a/include/mysql/psi/mysql_table.h
+++ b/include/mysql/psi/mysql_table.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
- Copyright (c) 2017, MariaDB Corporation.
+/* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -31,6 +31,10 @@
#include "mysql/psi/psi.h"
+#ifndef PSI_TABLE_CALL
+#define PSI_TABLE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup Table_instrumentation Table Instrumentation
@ingroup Instrumentation_interface
@@ -54,7 +58,7 @@
#define PSI_CALL_unbind_table(A1) do { } while(0)
#define PSI_CALL_rebind_table(A1,A2,A3) NULL
-#define PSI_CALL_close_table(A1) do { } while(0)
+#define PSI_CALL_close_table(A1,A2) do { } while(0)
#define PSI_CALL_open_table(A1,A2) NULL
#define PSI_CALL_get_table_share(A1,A2) NULL
#define PSI_CALL_release_table_share(A1) do { } while(0)
@@ -82,72 +86,6 @@
#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_likely(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_likely(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.
@@ -183,6 +121,14 @@
#endif
#ifdef HAVE_PSI_TABLE_INTERFACE
+ #define MYSQL_UNLOCK_TABLE(T) \
+ inline_mysql_unlock_table(T)
+#else
+ #define MYSQL_UNLOCK_TABLE(T) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TABLE_INTERFACE
/**
Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
@sa MYSQL_END_TABLE_LOCK_WAIT.
@@ -213,6 +159,13 @@ inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
if (psi_likely(locker != NULL))
PSI_TABLE_CALL(end_table_lock_wait)(locker);
}
+
+static inline void
+inline_mysql_unlock_table(struct PSI_table *table)
+{
+ if (table != NULL)
+ PSI_TABLE_CALL(unlock_table)(table);
+}
#endif
/** @} (end of group Table_instrumentation) */
diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h
index eab87402140..711520dba78 100644
--- a/include/mysql/psi/mysql_thread.h
+++ b/include/mysql/psi/mysql_thread.h
@@ -62,6 +62,27 @@
*/
#include "mysql/psi/psi.h"
+#ifdef MYSQL_SERVER
+#ifndef MYSQL_DYNAMIC_PLUGIN
+#include "pfs_thread_provider.h"
+#endif
+#endif
+
+#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
/**
@defgroup Thread_instrumentation Thread Instrumentation
@@ -75,26 +96,32 @@
#define PSI_CALL_new_thread PSI_THREAD_CALL(new_thread)
#define PSI_CALL_register_thread PSI_THREAD_CALL(register_thread)
#define PSI_CALL_set_thread PSI_THREAD_CALL(set_thread)
+#define PSI_CALL_set_thread_THD PSI_THREAD_CALL(set_thread_THD)
#define PSI_CALL_set_thread_connect_attrs PSI_THREAD_CALL(set_thread_connect_attrs)
#define PSI_CALL_set_thread_db PSI_THREAD_CALL(set_thread_db)
#define PSI_CALL_set_thread_id PSI_THREAD_CALL(set_thread_id)
+#define PSI_CALL_set_thread_os_id PSI_THREAD_CALL(set_thread_os_id)
#define PSI_CALL_set_thread_info PSI_THREAD_CALL(set_thread_info)
#define PSI_CALL_set_thread_start_time PSI_THREAD_CALL(set_thread_start_time)
-#define PSI_CALL_set_thread_user_host PSI_THREAD_CALL(set_thread_user_host)
+#define PSI_CALL_set_thread_account PSI_THREAD_CALL(set_thread_account)
#define PSI_CALL_spawn_thread PSI_THREAD_CALL(spawn_thread)
+#define PSI_CALL_set_connection_type PSI_THREAD_CALL(set_connection_type)
#else
#define PSI_CALL_delete_current_thread() do { } while(0)
#define PSI_CALL_get_thread() NULL
#define PSI_CALL_new_thread(A1,A2,A3) NULL
#define PSI_CALL_register_thread(A1,A2,A3) do { } while(0)
#define PSI_CALL_set_thread(A1) do { } while(0)
+#define PSI_CALL_set_thread_THD(A1,A2) do { } while(0)
#define PSI_CALL_set_thread_connect_attrs(A1,A2,A3) 0
#define PSI_CALL_set_thread_db(A1,A2) do { } while(0)
#define PSI_CALL_set_thread_id(A1,A2) do { } while(0)
+#define PSI_CALL_set_thread_os_id(A1) do { } while(0)
#define PSI_CALL_set_thread_info(A1, A2) do { } while(0)
#define PSI_CALL_set_thread_start_time(A1) do { } while(0)
-#define PSI_CALL_set_thread_user_host(A1, A2, A3, A4) do { } while(0)
+#define PSI_CALL_set_thread_account(A1, A2, A3, A4) do { } while(0)
#define PSI_CALL_spawn_thread(A1, A2, A3, A4, A5) 0
+#define PSI_CALL_set_connection_type(A) do { } while(0)
#endif
@@ -256,11 +283,19 @@ typedef struct st_mysql_cond mysql_cond_t;
#define mysql_mutex_setflags(M, F) \
safe_mutex_setflags(&(M)->m_mutex, (F))
-/** Wrappers for instrumented prlock objects. */
-
+/**
+ @def mysql_prlock_assert_write_owner(M)
+ Drop-in replacement
+ for @c rw_pr_lock_assert_write_owner.
+*/
#define mysql_prlock_assert_write_owner(M) \
rw_pr_lock_assert_write_owner(&(M)->m_prlock)
+/**
+ @def mysql_prlock_assert_not_write_owner(M)
+ Drop-in replacement
+ for @c rw_pr_lock_assert_not_write_owner.
+*/
#define mysql_prlock_assert_not_write_owner(M) \
rw_pr_lock_assert_not_write_owner(&(M)->m_prlock)
@@ -538,7 +573,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.
*/
-#ifdef HAVE_PSI_COND_INTERFACE
+#if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
#define mysql_cond_wait(C, M) \
inline_mysql_cond_wait(C, M, __FILE__, __LINE__)
#else
@@ -552,7 +587,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_cond_timedwait is a drop-in replacement
for @c pthread_cond_timedwait.
*/
-#ifdef HAVE_PSI_COND_INTERFACE
+#if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
#define mysql_cond_timedwait(C, M, W) \
inline_mysql_cond_timedwait(C, M, W, __FILE__, __LINE__)
#else
@@ -618,6 +653,17 @@ typedef struct st_mysql_cond mysql_cond_t;
#define mysql_thread_set_psi_id(I) do {} while (0)
#endif
+/**
+ @def mysql_thread_set_psi_THD(T)
+ Set the thread sql session for the instrumentation.
+ @param I The thread identifier
+*/
+#ifdef HAVE_PSI_THREAD_INTERFACE
+ #define mysql_thread_set_psi_THD(T) inline_mysql_thread_set_psi_THD(T)
+#else
+ #define mysql_thread_set_psi_THD(T) do {} while (0)
+#endif
+
static inline void inline_mysql_mutex_register(
#ifdef HAVE_PSI_MUTEX_INTERFACE
const char *category,
@@ -1154,7 +1200,7 @@ static inline int inline_mysql_cond_destroy(
static inline int inline_mysql_cond_wait(
mysql_cond_t *that,
mysql_mutex_t *mutex
-#ifdef HAVE_PSI_COND_INTERFACE
+#if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
, const char *src_file, uint src_line
#endif
)
@@ -1191,7 +1237,7 @@ static inline int inline_mysql_cond_timedwait(
mysql_cond_t *that,
mysql_mutex_t *mutex,
const struct timespec *abstime
-#ifdef HAVE_PSI_COND_INTERFACE
+#if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
, const char *src_file, uint src_line
#endif
)
@@ -1281,6 +1327,16 @@ static inline void inline_mysql_thread_set_psi_id(my_thread_id id)
struct PSI_thread *psi= PSI_THREAD_CALL(get_thread)();
PSI_THREAD_CALL(set_thread_id)(psi, id);
}
+
+#ifdef __cplusplus
+class THD;
+static inline void inline_mysql_thread_set_psi_THD(THD *thd)
+{
+ struct PSI_thread *psi= PSI_THREAD_CALL(get_thread)();
+ PSI_THREAD_CALL(set_thread_THD)(psi, thd);
+}
+#endif /* __cplusplus */
+
#endif
#endif /* DISABLE_MYSQL_THREAD_H */
diff --git a/include/mysql/psi/mysql_transaction.h b/include/mysql/psi/mysql_transaction.h
new file mode 100644
index 00000000000..6de794d95bb
--- /dev/null
+++ b/include/mysql/psi/mysql_transaction.h
@@ -0,0 +1,220 @@
+/* Copyright (c) 2013, 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, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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_TRANSACTION_H
+#define MYSQL_TRANSACTION_H
+
+/**
+ @file mysql/psi/mysql_transaction.h
+ Instrumentation helpers for transactions.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifndef PSI_TRANSACTION_CALL
+#define PSI_TRANSACTION_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+/**
+ @defgroup Transaction_instrumentation Transaction Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_START_TRANSACTION(STATE, XID, TRXID, ISO, RO, AC) \
+ inline_mysql_start_transaction(STATE, XID, TRXID, ISO, RO, AC, __FILE__, __LINE__)
+#else
+ #define MYSQL_START_TRANSACTION(STATE, XID, TRXID, ISO, RO, AC) \
+ 0
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_SET_TRANSACTION_GTID(LOCKER, P1, P2) \
+ inline_mysql_set_transaction_gtid(LOCKER, P1, P2)
+#else
+ #define MYSQL_SET_TRANSACTION_GTID(LOCKER, P1, P2) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_SET_TRANSACTION_XID(LOCKER, P1, P2) \
+ inline_mysql_set_transaction_xid(LOCKER, P1, P2)
+#else
+ #define MYSQL_SET_TRANSACTION_XID(LOCKER, P1, P2) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_SET_TRANSACTION_XA_STATE(LOCKER, P1) \
+ inline_mysql_set_transaction_xa_state(LOCKER, P1)
+#else
+ #define MYSQL_SET_TRANSACTION_XA_STATE(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_SET_TRANSACTION_TRXID(LOCKER, P1) \
+ inline_mysql_set_transaction_trxid(LOCKER, P1)
+#else
+ #define MYSQL_SET_TRANSACTION_TRXID(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_INC_TRANSACTION_SAVEPOINTS(LOCKER, P1) \
+ inline_mysql_inc_transaction_savepoints(LOCKER, P1)
+#else
+ #define MYSQL_INC_TRANSACTION_SAVEPOINTS(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_INC_TRANSACTION_ROLLBACK_TO_SAVEPOINT(LOCKER, P1) \
+ inline_mysql_inc_transaction_rollback_to_savepoint(LOCKER, P1)
+#else
+ #define MYSQL_INC_TRANSACTION_ROLLBACK_TO_SAVEPOINT(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_INC_TRANSACTION_RELEASE_SAVEPOINT(LOCKER, P1) \
+ inline_mysql_inc_transaction_release_savepoint(LOCKER, P1)
+#else
+ #define MYSQL_INC_TRANSACTION_RELEASE_SAVEPOINT(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_ROLLBACK_TRANSACTION(LOCKER) \
+ inline_mysql_rollback_transaction(LOCKER)
+#else
+ #define MYSQL_ROLLBACK_TRANSACTION(LOCKER) \
+ do { } while(0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_COMMIT_TRANSACTION(LOCKER) \
+ inline_mysql_commit_transaction(LOCKER)
+#else
+ #define MYSQL_COMMIT_TRANSACTION(LOCKER) \
+ do { } while(0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+static inline struct PSI_transaction_locker *
+inline_mysql_start_transaction(PSI_transaction_locker_state *state,
+ const void *xid,
+ ulonglong trxid,
+ int isolation_level,
+ my_bool read_only,
+ my_bool autocommit,
+ const char *src_file, int src_line)
+{
+ PSI_transaction_locker *locker;
+ locker= PSI_TRANSACTION_CALL(get_thread_transaction_locker)(state,
+ xid, trxid,
+ isolation_level,
+ read_only,
+ autocommit);
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(start_transaction)(locker, src_file, src_line);
+ return locker;
+}
+
+static inline void
+inline_mysql_set_transaction_gtid(PSI_transaction_locker *locker,
+ const void *sid,
+ const void *gtid_spec)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(set_transaction_gtid)(locker, sid, gtid_spec);
+}
+
+static inline void
+inline_mysql_set_transaction_xid(PSI_transaction_locker *locker,
+ const void *xid,
+ int xa_state)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(set_transaction_xid)(locker, xid, xa_state);
+}
+
+static inline void
+inline_mysql_set_transaction_xa_state(PSI_transaction_locker *locker,
+ int xa_state)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(set_transaction_xa_state)(locker, xa_state);
+}
+
+static inline void
+inline_mysql_set_transaction_trxid(PSI_transaction_locker *locker,
+ const ulonglong *trxid)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(set_transaction_trxid)(locker, trxid);
+}
+
+static inline void
+inline_mysql_inc_transaction_savepoints(PSI_transaction_locker *locker,
+ ulong count)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(inc_transaction_savepoints)(locker, count);
+}
+
+static inline void
+inline_mysql_inc_transaction_rollback_to_savepoint(PSI_transaction_locker *locker,
+ ulong count)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(inc_transaction_rollback_to_savepoint)(locker, count);
+}
+
+static inline void
+inline_mysql_inc_transaction_release_savepoint(PSI_transaction_locker *locker,
+ ulong count)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(inc_transaction_release_savepoint)(locker, count);
+}
+
+static inline void
+inline_mysql_rollback_transaction(struct PSI_transaction_locker *locker)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(end_transaction)(locker, false);
+}
+
+static inline void
+inline_mysql_commit_transaction(struct PSI_transaction_locker *locker)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(end_transaction)(locker, true);
+}
+#endif
+
+/** @} (end of group Transaction_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h
index 238471c7af1..958a086f05a 100644
--- a/include/mysql/psi/psi.h
+++ b/include/mysql/psi/psi.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2017, 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, version 2.0,
@@ -23,19 +23,6 @@
#ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
#define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_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.
@@ -61,13 +48,58 @@
#define psi_unlikely(A) likely(A)
#endif
+#include "psi_base.h"
+#include "psi_memory.h"
+
+#ifdef _WIN32
+typedef struct thread_attr pthread_attr_t;
+typedef DWORD pthread_t;
+typedef DWORD pthread_key_t;
+#endif
+
+/*
+ MAINTAINER:
+ The following pattern:
+ typedef struct XYZ XYZ;
+ is not needed in C++, but required for C.
+*/
C_MODE_START
+/** @sa MDL_key. */
+struct MDL_key;
+typedef struct MDL_key MDL_key;
+
+/** @sa enum_mdl_type. */
+typedef int opaque_mdl_type;
+
+/** @sa enum_mdl_duration. */
+typedef int opaque_mdl_duration;
+
+/** @sa MDL_wait::enum_wait_status. */
+typedef int opaque_mdl_status;
+
+/** @sa enum_vio_type. */
+typedef int opaque_vio_type;
+
struct TABLE_SHARE;
struct sql_digest_storage;
+#ifdef __cplusplus
+ class THD;
+#else
+ /*
+ Phony declaration when compiling C code.
+ This is ok, because the C code will never have a THD anyway.
+ */
+ struct opaque_THD
+ {
+ int dummy;
+ };
+ typedef struct opaque_THD THD;
+#endif
+
/**
@file mysql/psi/psi.h
Performance schema instrumentation interface.
@@ -134,6 +166,13 @@ struct PSI_socket;
typedef struct PSI_socket PSI_socket;
/**
+ Interface for an instrumented prepared statement.
+ This is an opaque structure.
+*/
+struct PSI_prepared_stmt;
+typedef struct PSI_prepared_stmt PSI_prepared_stmt;
+
+/**
Interface for an instrumented table operation.
This is an opaque structure.
*/
@@ -148,6 +187,13 @@ struct PSI_statement_locker;
typedef struct PSI_statement_locker PSI_statement_locker;
/**
+ Interface for an instrumented transaction.
+ This is an opaque structure.
+*/
+struct PSI_transaction_locker;
+typedef struct PSI_transaction_locker PSI_transaction_locker;
+
+/**
Interface for an instrumented idle operation.
This is an opaque structure.
*/
@@ -161,6 +207,90 @@ typedef struct PSI_idle_locker PSI_idle_locker;
struct PSI_digest_locker;
typedef struct PSI_digest_locker PSI_digest_locker;
+/**
+ Interface for an instrumented stored procedure share.
+ This is an opaque structure.
+*/
+struct PSI_sp_share;
+typedef struct PSI_sp_share PSI_sp_share;
+
+/**
+ Interface for an instrumented stored program.
+ This is an opaque structure.
+*/
+struct PSI_sp_locker;
+typedef struct PSI_sp_locker PSI_sp_locker;
+
+/**
+ Interface for an instrumented metadata lock.
+ This is an opaque structure.
+*/
+struct PSI_metadata_lock;
+typedef struct PSI_metadata_lock PSI_metadata_lock;
+
+/**
+ Interface for an instrumented stage progress.
+ This is a public structure, for efficiency.
+*/
+struct PSI_stage_progress
+{
+ ulonglong m_work_completed;
+ ulonglong m_work_estimated;
+};
+typedef struct PSI_stage_progress PSI_stage_progress;
+
+/** 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;
+
+/**
+ 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 start_table_io_wait_v1_t
+ @sa start_table_lock_wait_v1_t
+*/
+struct PSI_table_locker_state
+{
+ /** 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;
+};
+typedef struct PSI_table_locker_state PSI_table_locker_state;
+
/** Entry point for the performance schema interface. */
struct PSI_bootstrap
{
@@ -183,14 +313,84 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#ifdef HAVE_PSI_INTERFACE
+#ifdef DISABLE_ALL_PSI
+
+#ifndef DISABLE_PSI_THREAD
+#define DISABLE_PSI_THREAD
+#endif
+
+#ifndef DISABLE_PSI_MUTEX
+#define DISABLE_PSI_MUTEX
+#endif
+
+#ifndef DISABLE_PSI_RWLOCK
+#define DISABLE_PSI_RWLOCK
+#endif
+
+#ifndef DISABLE_PSI_COND
+#define DISABLE_PSI_COND
+#endif
+
+#ifndef DISABLE_PSI_FILE
+#define DISABLE_PSI_FILE
+#endif
+
+#ifndef DISABLE_PSI_TABLE
+#define DISABLE_PSI_TABLE
+#endif
+
+#ifndef DISABLE_PSI_SOCKET
+#define DISABLE_PSI_SOCKET
+#endif
+
+#ifndef DISABLE_PSI_STAGE
+#define DISABLE_PSI_STAGE
+#endif
+
+#ifndef DISABLE_PSI_STATEMENT
+#define DISABLE_PSI_STATEMENT
+#endif
+
+#ifndef DISABLE_PSI_SP
+#define DISABLE_PSI_SP
+#endif
+
+#ifndef DISABLE_PSI_IDLE
+#define DISABLE_PSI_IDLE
+#endif
+
+#ifndef DISABLE_PSI_STATEMENT_DIGEST
+#define DISABLE_PSI_STATEMENT_DIGEST
+#endif
+
+#ifndef DISABLE_PSI_METADATA
+#define DISABLE_PSI_METADATA
+#endif
+
+#ifndef DISABLE_PSI_MEMORY
+#define DISABLE_PSI_MEMORY
+#endif
+
+#ifndef DISABLE_PSI_TRANSACTION
+#define DISABLE_PSI_TRANSACTION
+#endif
+
+#ifndef DISABLE_PSI_SP
+#define DISABLE_PSI_SP
+#endif
+
+#ifndef DISABLE_PSI_PS
+#define DISABLE_PSI_PS
+#endif
+
+#endif
+
/**
@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
@@ -198,8 +398,13 @@ typedef struct PSI_bootstrap PSI_bootstrap;
@sa DISABLE_PSI_TABLE
@sa DISABLE_PSI_STAGE
@sa DISABLE_PSI_STATEMENT
+ @sa DISABLE_PSI_SP
+ @sa DISABLE_PSI_STATEMENT_DIGEST
@sa DISABLE_PSI_SOCKET
+ @sa DISABLE_PSI_MEMORY
@sa DISABLE_PSI_IDLE
+ @sa DISABLE_PSI_METADATA
+ @sa DISABLE PSI_TRANSACTION
*/
#ifndef DISABLE_PSI_MUTEX
@@ -276,6 +481,26 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#endif
/**
+ @def DISABLE_PSI_SP
+ Compiling option to disable the stored program instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+#ifndef DISABLE_PSI_SP
+#define HAVE_PSI_SP_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_PS
+ Compiling option to disable the prepared statement instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+#ifndef DISABLE_PSI_STATEMENT
+#ifndef DISABLE_PSI_PS
+#define HAVE_PSI_PS_INTERFACE
+#endif
+#endif
+
+/**
@def DISABLE_PSI_STATEMENT_DIGEST
Compiling option to disable the statement digest instrumentation.
*/
@@ -287,6 +512,16 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#endif
/**
+ @def DISABLE_PSI_TRANSACTION
+ Compiling option to disable the transaction instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_TRANSACTION
+#define HAVE_PSI_TRANSACTION_INTERFACE
+#endif
+
+/**
@def DISABLE_PSI_SOCKET
Compiling option to disable the statement instrumentation.
@sa DISABLE_PSI_MUTEX
@@ -297,6 +532,16 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#endif
/**
+ @def DISABLE_PSI_MEMORY
+ Compiling option to disable the memory instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_MEMORY
+#define HAVE_PSI_MEMORY_INTERFACE
+#endif
+
+/**
@def DISABLE_PSI_IDLE
Compiling option to disable the idle instrumentation.
@sa DISABLE_PSI_MUTEX
@@ -307,6 +552,16 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#endif
/**
+ @def DISABLE_PSI_METADATA
+ Compiling option to disable the metadata instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_METADATA
+#define HAVE_PSI_METADATA_INTERFACE
+#endif
+
+/**
@def PSI_VERSION_1
Performance Schema Interface number for version 1.
This version is supported.
@@ -368,6 +623,13 @@ typedef struct PSI_file_locker PSI_file_locker;
struct PSI_socket_locker;
typedef struct PSI_socket_locker PSI_socket_locker;
+/**
+ Interface for an instrumented MDL operation.
+ This is an opaque structure.
+*/
+struct PSI_metadata_locker;
+typedef struct PSI_metadata_locker PSI_metadata_locker;
+
/** Operation performed on an instrumented mutex. */
enum PSI_mutex_operation
{
@@ -378,7 +640,12 @@ enum PSI_mutex_operation
};
typedef enum PSI_mutex_operation PSI_mutex_operation;
-/** Operation performed on an instrumented rwlock. */
+/**
+ Operation performed on an instrumented rwlock.
+ For basic READ / WRITE lock,
+ operations are "READ" or "WRITE".
+ For SX-locks, operations are "SHARED", "SHARED-EXCLUSIVE" or "EXCLUSIVE".
+*/
enum PSI_rwlock_operation
{
/** Read lock. */
@@ -388,7 +655,21 @@ enum PSI_rwlock_operation
/** Read lock attempt. */
PSI_RWLOCK_TRYREADLOCK= 2,
/** Write lock attempt. */
- PSI_RWLOCK_TRYWRITELOCK= 3
+ PSI_RWLOCK_TRYWRITELOCK= 3,
+
+ /** Shared lock. */
+ PSI_RWLOCK_SHAREDLOCK= 4,
+ /** Shared Exclusive lock. */
+ PSI_RWLOCK_SHAREDEXCLUSIVELOCK= 5,
+ /** Exclusive lock. */
+ PSI_RWLOCK_EXCLUSIVELOCK= 6,
+ /** Shared lock attempt. */
+ PSI_RWLOCK_TRYSHAREDLOCK= 7,
+ /** Shared Exclusive lock attempt. */
+ PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK= 8,
+ /** Exclusive lock attempt. */
+ PSI_RWLOCK_TRYEXCLUSIVELOCK= 9
+
};
typedef enum PSI_rwlock_operation PSI_rwlock_operation;
@@ -448,20 +729,6 @@ enum PSI_file_operation
};
typedef enum PSI_file_operation PSI_file_operation;
-/** 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
{
@@ -518,6 +785,7 @@ enum PSI_socket_operation
};
typedef enum PSI_socket_operation PSI_socket_operation;
+#endif
/**
Instrumented mutex key.
To instrument a mutex, a mutex key must be obtained using @c register_mutex.
@@ -577,44 +845,6 @@ typedef unsigned int PSI_statement_key;
*/
typedef unsigned int PSI_socket_key;
-/**
- @def USE_PSI_1
- Define USE_PSI_1 to use the interface version 1.
-*/
-
-/**
- @def USE_PSI_2
- Define USE_PSI_2 to use the interface version 2.
-*/
-
-/**
- @def HAVE_PSI_1
- Define HAVE_PSI_1 if the interface version 1 needs to be compiled in.
-*/
-
-/**
- @def HAVE_PSI_2
- Define HAVE_PSI_2 if the interface version 2 needs to be compiled in.
-*/
-
-/**
- Global flag.
- This flag indicate that an instrumentation point is a global variable,
- or a singleton.
-*/
-#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
-
#ifdef HAVE_PSI_1
/**
@@ -644,6 +874,7 @@ struct PSI_mutex_info_v1
*/
int m_flags;
};
+typedef struct PSI_mutex_info_v1 PSI_mutex_info_v1;
/**
Rwlock information.
@@ -666,6 +897,7 @@ struct PSI_rwlock_info_v1
*/
int m_flags;
};
+typedef struct PSI_rwlock_info_v1 PSI_rwlock_info_v1;
/**
Condition information.
@@ -688,6 +920,7 @@ struct PSI_cond_info_v1
*/
int m_flags;
};
+typedef struct PSI_cond_info_v1 PSI_cond_info_v1;
/**
Thread instrument information.
@@ -710,6 +943,7 @@ struct PSI_thread_info_v1
*/
int m_flags;
};
+typedef struct PSI_thread_info_v1 PSI_thread_info_v1;
/**
File instrument information.
@@ -732,6 +966,7 @@ struct PSI_file_info_v1
*/
int m_flags;
};
+typedef struct PSI_file_info_v1 PSI_file_info_v1;
/**
Stage instrument information.
@@ -747,6 +982,7 @@ struct PSI_stage_info_v1
/** The flags of the stage instrument to register. */
int m_flags;
};
+typedef struct PSI_stage_info_v1 PSI_stage_info_v1;
/**
Statement instrument information.
@@ -762,6 +998,7 @@ struct PSI_statement_info_v1
/** The flags of the statement instrument to register. */
int m_flags;
};
+typedef struct PSI_statement_info_v1 PSI_statement_info_v1;
/**
Socket instrument information.
@@ -784,6 +1021,7 @@ struct PSI_socket_info_v1
*/
int m_flags;
};
+typedef struct PSI_socket_info_v1 PSI_socket_info_v1;
/**
State data storage for @c start_idle_wait_v1_t.
@@ -807,6 +1045,7 @@ struct PSI_idle_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state_v1;
/**
State data storage for @c start_mutex_wait_v1_t.
@@ -834,6 +1073,7 @@ struct PSI_mutex_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state_v1;
/**
State data storage for @c start_rwlock_rdwait_v1_t, @c start_rwlock_wrwait_v1_t.
@@ -862,6 +1102,7 @@ struct PSI_rwlock_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state_v1;
/**
State data storage for @c start_cond_wait_v1_t.
@@ -891,6 +1132,7 @@ struct PSI_cond_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state_v1;
/**
State data storage for @c get_thread_file_name_locker_v1_t.
@@ -926,28 +1168,23 @@ struct PSI_file_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_file_locker_state_v1 PSI_file_locker_state_v1;
/**
- 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.
+ State data storage for @c start_metadata_wait_v1_t.
+ This structure provide temporary storage to a metadata 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_table_io_wait_v1_t
- @sa start_table_lock_wait_v1_t
+ @sa start_metadata_wait_v1_t
*/
-struct PSI_table_locker_state_v1
+struct PSI_metadata_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 metadata lock. */
+ struct PSI_metadata_lock *m_metadata_lock;
/** Current thread. */
struct PSI_thread *m_thread;
/** Timer start. */
@@ -956,13 +1193,8 @@ struct PSI_table_locker_state_v1
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;
};
+typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state_v1;
/* Duplicate of NAME_LEN, to avoid dependency on mysql_com.h */
#define PSI_SCHEMA_NAME_LEN (64 * 3)
@@ -981,6 +1213,8 @@ struct PSI_statement_locker_state_v1
{
/** Discarded flag. */
my_bool m_discarded;
+ /** In prepare flag. */
+ my_bool m_in_prepare;
/** Metric, no index used flag. */
uchar m_no_index_used;
/** Metric, no good index used flag. */
@@ -1033,7 +1267,50 @@ struct PSI_statement_locker_state_v1
uint m_schema_name_length;
/** Statement character set number. */
uint m_cs_number;
+ PSI_sp_share *m_parent_sp_share;
+ PSI_prepared_stmt *m_parent_prepared_stmt;
};
+typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state_v1;
+
+/**
+ State data storage for @c get_thread_transaction_locker_v1_t,
+ @c get_thread_transaction_locker_v1_t.
+ This structure provide temporary storage to a transaction 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_transaction_locker_v1_t
+*/
+struct PSI_transaction_locker_state_v1
+{
+ /** Internal state. */
+ uint m_flags;
+ /** Instrumentation class. */
+ void *m_class;
+ /** Current thread. */
+ struct PSI_thread *m_thread;
+ /** Timer start. */
+ ulonglong m_timer_start;
+ /** Timer function. */
+ ulonglong (*m_timer)(void);
+ /** Internal data. */
+ void *m_transaction;
+ /** True if read-only transaction, false if read-write. */
+ my_bool m_read_only;
+ /** True if transaction is autocommit. */
+ my_bool m_autocommit;
+ /** Number of statements. */
+ ulong m_statement_count;
+ /** Total number of savepoints. */
+ ulong m_savepoint_count;
+ /** Number of rollback_to_savepoint. */
+ ulong m_rollback_to_savepoint_count;
+ /** Number of release_savepoint. */
+ ulong m_release_savepoint_count;
+};
+
+typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state_v1;
/**
State data storage for @c start_socket_wait_v1_t.
@@ -1067,6 +1344,22 @@ struct PSI_socket_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state_v1;
+
+struct PSI_sp_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);
+ /** Stored Procedure share. */
+ PSI_sp_share* m_sp_share;
+};
+typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state_v1;
/* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */
@@ -1263,7 +1556,8 @@ typedef PSI_table* (*rebind_table_v1_t)
Note that the table handle is invalid after this call.
@param table the table handle to close
*/
-typedef void (*close_table_v1_t)(struct PSI_table *table);
+typedef void (*close_table_v1_t)(struct TABLE_SHARE *server_share,
+ struct PSI_table *table);
/**
Create a file instrumentation for a created file.
@@ -1300,6 +1594,14 @@ typedef struct PSI_thread* (*new_thread_v1_t)
(PSI_thread_key key, const void *identity, ulonglong thread_id);
/**
+ Assign a THD to an instrumented thread.
+ @param thread the instrumented thread
+ @param THD the sql layer THD to assign
+*/
+typedef void (*set_thread_THD_v1_t)(struct PSI_thread *thread,
+ THD *thd);
+
+/**
Assign an id to an instrumented thread.
@param thread the instrumented thread
@param id the id to assign
@@ -1308,6 +1610,13 @@ typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
ulonglong id);
/**
+ Assign the current operating system thread id to an instrumented thread.
+ The operating system task id is obtained from @c gettid()
+ @param thread the instrumented thread
+*/
+typedef void (*set_thread_os_id_v1_t)(struct PSI_thread *thread);
+
+/**
Get the instrumentation for the running thread.
For this function to return a result,
the thread instrumentation must have been attached to the
@@ -1330,8 +1639,8 @@ typedef void (*set_thread_user_v1_t)(const char *user, int user_len);
@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);
+typedef void (*set_thread_account_v1_t)(const char *user, int user_len,
+ const char *host, int host_len);
/**
Assign a current database to the instrumented thread.
@@ -1347,6 +1656,13 @@ typedef void (*set_thread_db_v1_t)(const char* db, int db_len);
typedef void (*set_thread_command_v1_t)(int command);
/**
+ Assign a connection type to the instrumented thread.
+ @param conn_type the connection type
+*/
+typedef void (*set_connection_type_v1_t)(opaque_vio_type conn_type);
+
+
+/**
Assign a start time to the instrumented thread.
@param start_time the thread start time
*/
@@ -1446,9 +1762,20 @@ typedef void (*signal_cond_v1_t)
typedef void (*broadcast_cond_v1_t)
(struct PSI_cond *cond);
+/**
+ Record an idle instrumentation wait start event.
+ @param state data storage for the locker
+ @param file the source file name
+ @param line the source line number
+ @return an idle locker, or NULL
+*/
typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
(struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
+/**
+ Record an idle instrumentation wait end event.
+ @param locker a thread locker for the running thread
+*/
typedef void (*end_idle_wait_v1_t)
(struct PSI_idle_locker *locker);
@@ -1540,7 +1867,7 @@ typedef void (*end_cond_wait_v1_t)
@param line the source line number
*/
typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
- (struct PSI_table_locker_state_v1 *state,
+ (struct PSI_table_locker_state *state,
struct PSI_table *table,
enum PSI_table_io_operation op,
uint index,
@@ -1549,8 +1876,11 @@ typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
/**
Record a table instrumentation io wait end event.
@param locker a table locker for the running thread
+ @param numrows the number of rows involved in io
*/
-typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*end_table_io_wait_v1_t)
+ (struct PSI_table_locker *locker,
+ ulonglong numrows);
/**
Record a table instrumentation lock wait start event.
@@ -1559,7 +1889,7 @@ typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
@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_locker_state *state,
struct PSI_table *table,
enum PSI_table_lock_operation op,
ulong flags,
@@ -1571,6 +1901,8 @@ typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
*/
typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*unlock_table_v1_t)(struct PSI_table *table);
+
/**
Start a file instrumentation open operation.
@param locker the file locker
@@ -1599,6 +1931,15 @@ typedef void (*end_file_open_wait_and_bind_to_descriptor_v1_t)
(struct PSI_file_locker *locker, File file);
/**
+ End a file instrumentation open operation, for non stream temporary files.
+ @param locker the file locker.
+ @param file the file number assigned by open() or create() for this file.
+ @param filename the file name generated during temporary file creation.
+*/
+typedef void (*end_temp_file_open_wait_and_bind_to_descriptor_v1_t)
+ (struct PSI_file_locker *locker, File file, const char *filename);
+
+/**
Record a file instrumentation start event.
@param locker a file locker for the running thread
@param op file operation to be performed
@@ -1645,14 +1986,28 @@ typedef void (*end_file_close_wait_v1_t)
(struct PSI_file_locker *locker, int rc);
/**
+ Rename a file instrumentation close operation.
+ @param locker the file locker.
+ @param old_name name of the file to be renamed.
+ @param new_name name of the file after rename.
+ @param rc the rename operation return code (0 for success).
+*/
+typedef void (*end_file_rename_wait_v1_t)
+ (struct PSI_file_locker *locker, const char *old_name,
+ const char *new_name, 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
+ @return the new stage progress
*/
-typedef void (*start_stage_v1_t)
+typedef PSI_stage_progress* (*start_stage_v1_t)
(PSI_stage_key key, const char *src_file, int src_line);
+typedef PSI_stage_progress* (*get_current_stage_progress_v1_t)(void);
+
/** End the current stage. */
typedef void (*end_stage_v1_t) (void);
@@ -1665,7 +2020,7 @@ 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);
+ PSI_statement_key key, const void *charset, PSI_sp_share *sp_share);
/**
Refine a statement locker to a more specific key.
@@ -1839,6 +2194,102 @@ typedef void (*end_statement_v1_t)
(struct PSI_statement_locker *locker, void *stmt_da);
/**
+ Get a transaction instrumentation locker.
+ @param state data storage for the locker
+ @param xid the xid for this transaction
+ @param trxid the InnoDB transaction id
+ @param iso_level isolation level for this transaction
+ @param read_only true if transaction access mode is read-only
+ @param autocommit true if transaction is autocommit
+ @return a transaction locker, or NULL
+*/
+typedef struct PSI_transaction_locker* (*get_thread_transaction_locker_v1_t)
+ (struct PSI_transaction_locker_state_v1 *state, const void *xid,
+ ulonglong trxid, int isolation_level, my_bool read_only,
+ my_bool autocommit);
+
+/**
+ Start a new transaction event.
+ @param locker the transaction locker for this event
+ @param src_file source file name
+ @param src_line source line number
+*/
+typedef void (*start_transaction_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const char *src_file, uint src_line);
+
+/**
+ Set the transaction xid.
+ @param locker the transaction locker for this event
+ @param xid the id of the XA transaction
+ #param xa_state is the state of the XA transaction
+*/
+typedef void (*set_transaction_xid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const void *xid, int xa_state);
+
+/**
+ Set the state of the XA transaction.
+ @param locker the transaction locker for this event
+ @param xa_state the new state of the xa transaction
+*/
+typedef void (*set_transaction_xa_state_v1_t)
+ (struct PSI_transaction_locker *locker,
+ int xa_state);
+
+/**
+ Set the transaction gtid.
+ @param locker the transaction locker for this event
+ @param sid the source id for the transaction, mapped from sidno
+ @param gtid_spec the gtid specifier for the transaction
+*/
+typedef void (*set_transaction_gtid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const void *sid, const void *gtid_spec);
+
+/**
+ Set the transaction trx_id.
+ @param locker the transaction locker for this event
+ @param trxid the storage engine transaction ID
+*/
+typedef void (*set_transaction_trxid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const ulonglong *trxid);
+
+/**
+ Increment a transaction event savepoint count.
+ @param locker the transaction locker
+ @param count the increment value
+*/
+typedef void (*inc_transaction_savepoints_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+
+/**
+ Increment a transaction event rollback to savepoint count.
+ @param locker the transaction locker
+ @param count the increment value
+*/
+typedef void (*inc_transaction_rollback_to_savepoint_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+
+/**
+ Increment a transaction event release savepoint count.
+ @param locker the transaction locker
+ @param count the increment value
+*/
+typedef void (*inc_transaction_release_savepoint_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+
+/**
+ Commit or rollback the transaction.
+ @param locker the transaction locker for this event
+ @param commit true if transaction was committed, false if rolled back
+*/
+typedef void (*end_transaction_v1_t)
+ (struct PSI_transaction_locker *locker,
+ my_bool commit);
+
+/**
Record a socket instrumentation start event.
@param locker a socket locker for the running thread
@param op socket operation to be performed
@@ -1894,23 +2345,119 @@ typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
/**
+ Get a prepare statement.
+ @param locker a statement locker for the running thread.
+*/
+typedef PSI_prepared_stmt* (*create_prepared_stmt_v1_t)
+ (void *identity, uint stmt_id, PSI_statement_locker *locker,
+ const char *stmt_name, size_t stmt_name_length);
+
+/**
+ destroy a prepare statement.
+ @param prepared_stmt prepared statement.
+*/
+typedef void (*destroy_prepared_stmt_v1_t)
+ (PSI_prepared_stmt *prepared_stmt);
+
+/**
+ repreare a prepare statement.
+ @param prepared_stmt prepared statement.
+*/
+typedef void (*reprepare_prepared_stmt_v1_t)
+ (PSI_prepared_stmt *prepared_stmt);
+
+/**
+ Record a prepare statement instrumentation execute event.
+ @param locker a statement locker for the running thread.
+ @param prepared_stmt prepared statement.
+*/
+typedef void (*execute_prepared_stmt_v1_t)
+ (PSI_statement_locker *locker, PSI_prepared_stmt* prepared_stmt);
+
+/**
+ Set the statement text for a prepared statment event.
+ @param prepared_stmt prepared statement.
+ @param text the prepared statement text
+ @param text_len the prepared statement text length
+*/
+typedef void (*set_prepared_stmt_text_v1_t)(PSI_prepared_stmt *prepared_stmt,
+ const char *text,
+ uint text_len);
+/**
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);
+/**
+ Add a token to the current digest instrumentation.
+ @param locker a digest locker for the current statement
+ @param token the lexical token to add
+ @param yylval the lexical token attributes
+*/
typedef void (*digest_end_v1_t)
(struct PSI_digest_locker *locker, const struct sql_digest_storage *digest);
+typedef PSI_sp_locker* (*start_sp_v1_t)
+ (struct PSI_sp_locker_state_v1 *state, struct PSI_sp_share* sp_share);
+
+typedef void (*end_sp_v1_t)
+ (struct PSI_sp_locker *locker);
+
+typedef void (*drop_sp_v1_t)
+ (uint object_type,
+ const char *schema_name, uint schema_name_length,
+ const char *object_name, uint object_name_length);
+
+/**
+ Acquire a sp share instrumentation.
+ @param type of stored program
+ @param schema name of stored program
+ @param name of stored program
+ @return a stored program share instrumentation, or NULL
+*/
+typedef struct PSI_sp_share* (*get_sp_share_v1_t)
+ (uint object_type,
+ const char *schema_name, uint schema_name_length,
+ const char *object_name, uint object_name_length);
+
+/**
+ Release a stored program share.
+ @param info the stored program share to release
+*/
+typedef void (*release_sp_share_v1_t)(struct PSI_sp_share *share);
+
+typedef PSI_metadata_lock* (*create_metadata_lock_v1_t)
+ (void *identity,
+ const MDL_key *key,
+ opaque_mdl_type mdl_type,
+ opaque_mdl_duration mdl_duration,
+ opaque_mdl_status mdl_status,
+ const char *src_file,
+ uint src_line);
+
+typedef void (*set_metadata_lock_status_v1_t)(PSI_metadata_lock *lock,
+ opaque_mdl_status mdl_status);
+
+typedef void (*destroy_metadata_lock_v1_t)(PSI_metadata_lock *lock);
+
+typedef struct PSI_metadata_locker* (*start_metadata_wait_v1_t)
+ (struct PSI_metadata_locker_state_v1 *state,
+ struct PSI_metadata_lock *mdl,
+ const char *src_file, uint src_line);
+
+typedef void (*end_metadata_wait_v1_t)
+ (struct PSI_metadata_locker *locker, int rc);
+
/**
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
+ @param length length of the data in buffer
+ @param from_cs charset in which @c buffer is encoded
@return state
- @retval non-0 attributes truncated
+ @retval non_0 attributes truncated
@retval 0 stored the attribute
*/
typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
@@ -1954,6 +2501,7 @@ struct PSI_v1
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. */
@@ -1976,16 +2524,22 @@ struct PSI_v1
new_thread_v1_t new_thread;
/** @sa set_thread_id_v1_t. */
set_thread_id_v1_t set_thread_id;
+ /** @sa set_thread_THD_v1_t. */
+ set_thread_THD_v1_t set_thread_THD;
+ /** @sa set_thread_os_id_v1_t. */
+ set_thread_os_id_v1_t set_thread_os_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_account_v1_t. */
+ set_thread_account_v1_t set_thread_account;
/** @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_connection_type_v1_t. */
+ set_connection_type_v1_t set_connection_type;
/** @sa set_thread_start_time_v1_t. */
set_thread_start_time_v1_t set_thread_start_time;
/** @sa set_thread_state_v1_t. */
@@ -2047,6 +2601,9 @@ struct PSI_v1
/** @sa end_file_open_wait_and_bind_to_descriptor_v1_t. */
end_file_open_wait_and_bind_to_descriptor_v1_t
end_file_open_wait_and_bind_to_descriptor;
+ /** @sa end_temp_file_open_wait_and_bind_to_descriptor_v1_t. */
+ end_temp_file_open_wait_and_bind_to_descriptor_v1_t
+ end_temp_file_open_wait_and_bind_to_descriptor;
/** @sa start_file_wait_v1_t. */
start_file_wait_v1_t start_file_wait;
/** @sa end_file_wait_v1_t. */
@@ -2055,8 +2612,12 @@ struct PSI_v1
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 rename_file_close_wait_v1_t. */
+ end_file_rename_wait_v1_t end_file_rename_wait;
/** @sa start_stage_v1_t. */
start_stage_v1_t start_stage;
+ /** @sa get_current_stage_progress_v1_t. */
+ get_current_stage_progress_v1_t get_current_stage_progress;
/** @sa end_stage_v1_t. */
end_stage_v1_t end_stage;
/** @sa get_thread_statement_locker_v1_t. */
@@ -2101,6 +2662,26 @@ struct PSI_v1
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 get_thread_transaction_locker_v1_t. */
+ get_thread_transaction_locker_v1_t get_thread_transaction_locker;
+ /** @sa start_transaction_v1_t. */
+ start_transaction_v1_t start_transaction;
+ /** @sa set_transaction_xid_v1_t. */
+ set_transaction_xid_v1_t set_transaction_xid;
+ /** @sa set_transaction_xa_state_v1_t. */
+ set_transaction_xa_state_v1_t set_transaction_xa_state;
+ /** @sa set_transaction_gtid_v1_t. */
+ set_transaction_gtid_v1_t set_transaction_gtid;
+ /** @sa set_transaction_trxid_v1_t. */
+ set_transaction_trxid_v1_t set_transaction_trxid;
+ /** @sa inc_transaction_savepoints_v1_t. */
+ inc_transaction_savepoints_v1_t inc_transaction_savepoints;
+ /** @sa inc_transaction_rollback_to_savepoint_v1_t. */
+ inc_transaction_rollback_to_savepoint_v1_t inc_transaction_rollback_to_savepoint;
+ /** @sa inc_transaction_release_savepoint_v1_t. */
+ inc_transaction_release_savepoint_v1_t inc_transaction_release_savepoint;
+ /** @sa end_transaction_v1_t. */
+ end_transaction_v1_t end_transaction;
/** @sa start_socket_wait_v1_t. */
start_socket_wait_v1_t start_socket_wait;
/** @sa end_socket_wait_v1_t. */
@@ -2111,12 +2692,51 @@ struct PSI_v1
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 create_prepared_stmt_v1_t. */
+ create_prepared_stmt_v1_t create_prepared_stmt;
+ /** @sa destroy_prepared_stmt_v1_t. */
+ destroy_prepared_stmt_v1_t destroy_prepared_stmt;
+ /** @sa reprepare_prepared_stmt_v1_t. */
+ reprepare_prepared_stmt_v1_t reprepare_prepared_stmt;
+ /** @sa execute_prepared_stmt_v1_t. */
+ execute_prepared_stmt_v1_t execute_prepared_stmt;
+ /** @sa set_prepared_stmt_text_v1_t. */
+ set_prepared_stmt_text_v1_t set_prepared_stmt_text;
/** @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;
+ /** @sa start_sp_v1_t. */
+ start_sp_v1_t start_sp;
+ /** @sa start_sp_v1_t. */
+ end_sp_v1_t end_sp;
+ /** @sa drop_sp_v1_t. */
+ drop_sp_v1_t drop_sp;
+ /** @sa get_sp_share_v1_t. */
+ get_sp_share_v1_t get_sp_share;
+ /** @sa release_sp_share_v1_t. */
+ release_sp_share_v1_t release_sp_share;
+ /** @sa register_memory_v1_t. */
+ register_memory_v1_t register_memory;
+ /** @sa memory_alloc_v1_t. */
+ memory_alloc_v1_t memory_alloc;
+ /** @sa memory_realloc_v1_t. */
+ memory_realloc_v1_t memory_realloc;
+ /** @sa memory_claim_v1_t. */
+ memory_claim_v1_t memory_claim;
+ /** @sa memory_free_v1_t. */
+ memory_free_v1_t memory_free;
+
+ unlock_table_v1_t unlock_table;
+
+ create_metadata_lock_v1_t create_metadata_lock;
+ set_metadata_lock_status_v1_t set_metadata_lock_status;
+ destroy_metadata_lock_v1_t destroy_metadata_lock;
+
+ start_metadata_wait_v1_t start_metadata_wait;
+ end_metadata_wait_v1_t end_metadata_wait;
};
/** @} (end of group Group_PSI_v1) */
@@ -2197,6 +2817,13 @@ struct PSI_statement_info_v2
};
/** Placeholder */
+struct PSI_transaction_info_v2
+{
+ /** Placeholder */
+ int placeholder;
+};
+
+/** Placeholder */
struct PSI_idle_locker_state_v2
{
/** Placeholder */
@@ -2232,14 +2859,14 @@ struct PSI_file_locker_state_v2
};
/** Placeholder */
-struct PSI_table_locker_state_v2
+struct PSI_statement_locker_state_v2
{
/** Placeholder */
int placeholder;
};
/** Placeholder */
-struct PSI_statement_locker_state_v2
+struct PSI_transaction_locker_state_v2
{
/** Placeholder */
int placeholder;
@@ -2252,6 +2879,11 @@ struct PSI_socket_locker_state_v2
int placeholder;
};
+struct PSI_metadata_locker_state_v2
+{
+ int placeholder;
+};
+
/** @} (end of group Group_PSI_v2) */
#endif /* HAVE_PSI_2 */
@@ -2297,15 +2929,18 @@ 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_transaction_info_v1 PSI_transaction_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_transaction_locker_state_v1 PSI_transaction_locker_state;
typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
+typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state;
+typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state;
#endif
#ifdef USE_PSI_2
@@ -2317,18 +2952,21 @@ 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_transaction_info_v2 PSI_transaction_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_transaction_locker_state_v2 PSI_transaction_locker_state;
typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
+typedef struct PSI_sp_locker_state_v2 PSI_sp_locker_state;
+typedef struct PSI_metadata_locker_state_v2 PSI_metadata_locker_state;
#endif
-#else /* HAVE_PSI_INTERFACE */
+#ifndef HAVE_PSI_INTERFACE
/**
Dummy structure, used to declare PSI_server when no instrumentation
@@ -2365,10 +3003,13 @@ struct PSI_stage_info_none
with HAVE_PSI_INTERFACE.
*/
typedef struct PSI_stage_info_none PSI_stage_info;
+typedef struct PSI_stage_info_none PSI_statement_info;
+typedef struct PSI_stage_info_none PSI_sp_locker_state;
+typedef struct PSI_stage_info_none PSI_metadata_locker_state;
+typedef struct PSI_stage_info_none PSI_metadata_locker;
#endif /* HAVE_PSI_INTERFACE */
-extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
/*
@@ -2378,50 +3019,6 @@ extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
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
/** @} */
diff --git a/include/mysql/psi/psi_abi_v0.h b/include/mysql/psi/psi_abi_v0.h
index ca4373f847b..5c879fb8536 100644
--- a/include/mysql/psi/psi_abi_v0.h
+++ b/include/mysql/psi/psi_abi_v0.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2013, 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, version 2.0,
diff --git a/include/mysql/psi/psi_abi_v0.h.pp b/include/mysql/psi/psi_abi_v0.h.pp
index 17d61016a68..47dc72b7ecb 100644
--- a/include/mysql/psi/psi_abi_v0.h.pp
+++ b/include/mysql/psi/psi_abi_v0.h.pp
@@ -1,7 +1,23 @@
#include "mysql/psi/psi.h"
+#include "psi_base.h"
+#include "psi_memory.h"
+#include "psi_base.h"
+struct PSI_thread;
+typedef unsigned int PSI_memory_key;
C_MODE_START
+struct MDL_key;
+typedef struct MDL_key MDL_key;
+typedef int opaque_mdl_type;
+typedef int opaque_mdl_duration;
+typedef int opaque_mdl_status;
+typedef int opaque_vio_type;
struct TABLE_SHARE;
struct sql_digest_storage;
+ struct opaque_THD
+ {
+ int dummy;
+ };
+ typedef struct opaque_THD THD;
struct PSI_mutex;
typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
@@ -18,14 +34,51 @@ struct PSI_file;
typedef struct PSI_file PSI_file;
struct PSI_socket;
typedef struct PSI_socket PSI_socket;
+struct PSI_prepared_stmt;
+typedef struct PSI_prepared_stmt PSI_prepared_stmt;
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_transaction_locker;
+typedef struct PSI_transaction_locker PSI_transaction_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_sp_share;
+typedef struct PSI_sp_share PSI_sp_share;
+struct PSI_sp_locker;
+typedef struct PSI_sp_locker PSI_sp_locker;
+struct PSI_metadata_lock;
+typedef struct PSI_metadata_lock PSI_metadata_lock;
+struct PSI_stage_progress
+{
+ ulonglong m_work_completed;
+ ulonglong m_work_estimated;
+};
+typedef struct PSI_stage_progress PSI_stage_progress;
+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;
+struct PSI_table_locker_state
+{
+ uint m_flags;
+ enum PSI_table_io_operation m_io_operation;
+ struct PSI_table *m_table;
+ struct PSI_table_share *m_table_share;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_wait;
+ uint m_index;
+};
+typedef struct PSI_table_locker_state PSI_table_locker_state;
struct PSI_bootstrap
{
void* (*get_interface)(int version);
diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp
index ef18f59e4a9..60a6a8031a6 100644
--- a/include/mysql/psi/psi_abi_v1.h.pp
+++ b/include/mysql/psi/psi_abi_v1.h.pp
@@ -1,6 +1,37 @@
+extern "C" {
+}
+extern "C" {
+struct PSI_thread;
+typedef unsigned int PSI_memory_key;
+struct PSI_memory_info_v1
+{
+ PSI_memory_key *m_key;
+ const char *m_name;
+ int m_flags;
+};
+typedef struct PSI_memory_info_v1 PSI_memory_info_v1;
+typedef void (*register_memory_v1_t)
+ (const char *category, struct PSI_memory_info_v1 *info, int count);
+typedef PSI_memory_key (*memory_alloc_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread ** owner);
+typedef PSI_memory_key (*memory_realloc_v1_t)
+ (PSI_memory_key key, size_t old_size, size_t new_size, struct PSI_thread ** owner);
+typedef PSI_memory_key (*memory_claim_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread ** owner);
+typedef void (*memory_free_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread * owner);
+typedef struct PSI_memory_info_v1 PSI_memory_info;
+}
C_MODE_START
+struct MDL_key;
+typedef struct MDL_key MDL_key;
+typedef int opaque_mdl_type;
+typedef int opaque_mdl_duration;
+typedef int opaque_mdl_status;
+typedef int opaque_vio_type;
struct TABLE_SHARE;
struct sql_digest_storage;
+ class THD;
struct PSI_mutex;
typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
@@ -17,14 +48,51 @@ struct PSI_file;
typedef struct PSI_file PSI_file;
struct PSI_socket;
typedef struct PSI_socket PSI_socket;
+struct PSI_prepared_stmt;
+typedef struct PSI_prepared_stmt PSI_prepared_stmt;
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_transaction_locker;
+typedef struct PSI_transaction_locker PSI_transaction_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_sp_share;
+typedef struct PSI_sp_share PSI_sp_share;
+struct PSI_sp_locker;
+typedef struct PSI_sp_locker PSI_sp_locker;
+struct PSI_metadata_lock;
+typedef struct PSI_metadata_lock PSI_metadata_lock;
+struct PSI_stage_progress
+{
+ ulonglong m_work_completed;
+ ulonglong m_work_estimated;
+};
+typedef struct PSI_stage_progress PSI_stage_progress;
+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;
+struct PSI_table_locker_state
+{
+ uint m_flags;
+ enum PSI_table_io_operation m_io_operation;
+ struct PSI_table *m_table;
+ struct PSI_table_share *m_table_share;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_wait;
+ uint m_index;
+};
+typedef struct PSI_table_locker_state PSI_table_locker_state;
struct PSI_bootstrap
{
void* (*get_interface)(int version);
@@ -40,6 +108,8 @@ struct PSI_file_locker;
typedef struct PSI_file_locker PSI_file_locker;
struct PSI_socket_locker;
typedef struct PSI_socket_locker PSI_socket_locker;
+struct PSI_metadata_locker;
+typedef struct PSI_metadata_locker PSI_metadata_locker;
enum PSI_mutex_operation
{
PSI_MUTEX_LOCK= 0,
@@ -51,7 +121,13 @@ enum PSI_rwlock_operation
PSI_RWLOCK_READLOCK= 0,
PSI_RWLOCK_WRITELOCK= 1,
PSI_RWLOCK_TRYREADLOCK= 2,
- PSI_RWLOCK_TRYWRITELOCK= 3
+ PSI_RWLOCK_TRYWRITELOCK= 3,
+ PSI_RWLOCK_SHAREDLOCK= 4,
+ PSI_RWLOCK_SHAREDEXCLUSIVELOCK= 5,
+ PSI_RWLOCK_EXCLUSIVELOCK= 6,
+ PSI_RWLOCK_TRYSHAREDLOCK= 7,
+ PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK= 8,
+ PSI_RWLOCK_TRYEXCLUSIVELOCK= 9
};
typedef enum PSI_rwlock_operation PSI_rwlock_operation;
enum PSI_cond_operation
@@ -81,14 +157,6 @@ enum PSI_file_operation
PSI_FILE_SYNC= 16
};
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,
@@ -134,48 +202,56 @@ struct PSI_mutex_info_v1
const char *m_name;
int m_flags;
};
+typedef struct PSI_mutex_info_v1 PSI_mutex_info_v1;
struct PSI_rwlock_info_v1
{
PSI_rwlock_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_rwlock_info_v1 PSI_rwlock_info_v1;
struct PSI_cond_info_v1
{
PSI_cond_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_cond_info_v1 PSI_cond_info_v1;
struct PSI_thread_info_v1
{
PSI_thread_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_thread_info_v1 PSI_thread_info_v1;
struct PSI_file_info_v1
{
PSI_file_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_file_info_v1 PSI_file_info_v1;
struct PSI_stage_info_v1
{
PSI_stage_key m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_stage_info_v1 PSI_stage_info_v1;
struct PSI_statement_info_v1
{
PSI_statement_key m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_statement_info_v1 PSI_statement_info_v1;
struct PSI_socket_info_v1
{
PSI_socket_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_socket_info_v1 PSI_socket_info_v1;
struct PSI_idle_locker_state_v1
{
uint m_flags;
@@ -184,6 +260,7 @@ struct PSI_idle_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
+typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state_v1;
struct PSI_mutex_locker_state_v1
{
uint m_flags;
@@ -194,6 +271,7 @@ struct PSI_mutex_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
+typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state_v1;
struct PSI_rwlock_locker_state_v1
{
uint m_flags;
@@ -204,6 +282,7 @@ struct PSI_rwlock_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
+typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state_v1;
struct PSI_cond_locker_state_v1
{
uint m_flags;
@@ -215,6 +294,7 @@ struct PSI_cond_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
+typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state_v1;
struct PSI_file_locker_state_v1
{
uint m_flags;
@@ -228,21 +308,21 @@ struct PSI_file_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
-struct PSI_table_locker_state_v1
+typedef struct PSI_file_locker_state_v1 PSI_file_locker_state_v1;
+struct PSI_metadata_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;
+ struct PSI_metadata_lock *m_metadata_lock;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
void *m_wait;
- uint m_index;
};
+typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state_v1;
struct PSI_statement_locker_state_v1
{
my_bool m_discarded;
+ my_bool m_in_prepare;
uchar m_no_index_used;
uchar m_no_good_index_used;
uint m_flags;
@@ -269,7 +349,26 @@ struct PSI_statement_locker_state_v1
char m_schema_name[(64 * 3)];
uint m_schema_name_length;
uint m_cs_number;
+ PSI_sp_share *m_parent_sp_share;
+ PSI_prepared_stmt *m_parent_prepared_stmt;
+};
+typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state_v1;
+struct PSI_transaction_locker_state_v1
+{
+ uint m_flags;
+ void *m_class;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_transaction;
+ my_bool m_read_only;
+ my_bool m_autocommit;
+ ulong m_statement_count;
+ ulong m_savepoint_count;
+ ulong m_rollback_to_savepoint_count;
+ ulong m_release_savepoint_count;
};
+typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state_v1;
struct PSI_socket_locker_state_v1
{
uint m_flags;
@@ -283,6 +382,16 @@ struct PSI_socket_locker_state_v1
int m_src_line;
void *m_wait;
};
+typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state_v1;
+struct PSI_sp_locker_state_v1
+{
+ uint m_flags;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ PSI_sp_share* m_sp_share;
+};
+typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state_v1;
typedef void (*register_mutex_v1_t)
(const char *category, struct PSI_mutex_info_v1 *info, int count);
typedef void (*register_rwlock_v1_t)
@@ -324,7 +433,8 @@ 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 (*close_table_v1_t)(struct TABLE_SHARE *server_share,
+ struct PSI_table *table);
typedef void (*create_file_v1_t)(PSI_file_key key, const char *name,
File file);
typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
@@ -333,14 +443,18 @@ typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
void *(*start_routine)(void*), void *arg);
typedef struct PSI_thread* (*new_thread_v1_t)
(PSI_thread_key key, const void *identity, ulonglong thread_id);
+typedef void (*set_thread_THD_v1_t)(struct PSI_thread *thread,
+ THD *thd);
typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
ulonglong id);
+typedef void (*set_thread_os_id_v1_t)(struct PSI_thread *thread);
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_account_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_connection_type_v1_t)(opaque_vio_type conn_type);
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);
@@ -399,25 +513,30 @@ typedef struct PSI_cond_locker* (*start_cond_wait_v1_t)
typedef void (*end_cond_wait_v1_t)
(struct PSI_cond_locker *locker, int rc);
typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
- (struct PSI_table_locker_state_v1 *state,
+ (struct PSI_table_locker_state *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 void (*end_table_io_wait_v1_t)
+ (struct PSI_table_locker *locker,
+ ulonglong numrows);
typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
- (struct PSI_table_locker_state_v1 *state,
+ (struct PSI_table_locker_state *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 (*unlock_table_v1_t)(struct PSI_table *table);
typedef void (*start_file_open_wait_v1_t)
(struct PSI_file_locker *locker, const char *src_file, uint src_line);
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 (*end_temp_file_open_wait_and_bind_to_descriptor_v1_t)
+ (struct PSI_file_locker *locker, File file, const char *filename);
typedef void (*start_file_wait_v1_t)
(struct PSI_file_locker *locker, size_t count,
const char *src_file, uint src_line);
@@ -427,12 +546,16 @@ 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)
+typedef void (*end_file_rename_wait_v1_t)
+ (struct PSI_file_locker *locker, const char *old_name,
+ const char *new_name, int rc);
+typedef PSI_stage_progress* (*start_stage_v1_t)
(PSI_stage_key key, const char *src_file, int src_line);
+typedef PSI_stage_progress* (*get_current_stage_progress_v1_t)(void);
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);
+ PSI_statement_key key, const void *charset, PSI_sp_share *sp_share);
typedef struct PSI_statement_locker* (*refine_statement_v1_t)
(struct PSI_statement_locker *locker,
PSI_statement_key key);
@@ -477,6 +600,34 @@ 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_transaction_locker* (*get_thread_transaction_locker_v1_t)
+ (struct PSI_transaction_locker_state_v1 *state, const void *xid,
+ ulonglong trxid, int isolation_level, my_bool read_only,
+ my_bool autocommit);
+typedef void (*start_transaction_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const char *src_file, uint src_line);
+typedef void (*set_transaction_xid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const void *xid, int xa_state);
+typedef void (*set_transaction_xa_state_v1_t)
+ (struct PSI_transaction_locker *locker,
+ int xa_state);
+typedef void (*set_transaction_gtid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const void *sid, const void *gtid_spec);
+typedef void (*set_transaction_trxid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const ulonglong *trxid);
+typedef void (*inc_transaction_savepoints_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+typedef void (*inc_transaction_rollback_to_savepoint_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+typedef void (*inc_transaction_release_savepoint_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+typedef void (*end_transaction_v1_t)
+ (struct PSI_transaction_locker *locker,
+ my_bool commit);
typedef struct PSI_socket_locker* (*start_socket_wait_v1_t)
(struct PSI_socket_locker_state_v1 *state,
struct PSI_socket *socket,
@@ -492,10 +643,52 @@ typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
const struct sockaddr *addr,
socklen_t addr_len);
typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
+typedef PSI_prepared_stmt* (*create_prepared_stmt_v1_t)
+ (void *identity, uint stmt_id, PSI_statement_locker *locker,
+ const char *stmt_name, size_t stmt_name_length);
+typedef void (*destroy_prepared_stmt_v1_t)
+ (PSI_prepared_stmt *prepared_stmt);
+typedef void (*reprepare_prepared_stmt_v1_t)
+ (PSI_prepared_stmt *prepared_stmt);
+typedef void (*execute_prepared_stmt_v1_t)
+ (PSI_statement_locker *locker, PSI_prepared_stmt* prepared_stmt);
+typedef void (*set_prepared_stmt_text_v1_t)(PSI_prepared_stmt *prepared_stmt,
+ const char *text,
+ uint text_len);
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 PSI_sp_locker* (*start_sp_v1_t)
+ (struct PSI_sp_locker_state_v1 *state, struct PSI_sp_share* sp_share);
+typedef void (*end_sp_v1_t)
+ (struct PSI_sp_locker *locker);
+typedef void (*drop_sp_v1_t)
+ (uint object_type,
+ const char *schema_name, uint schema_name_length,
+ const char *object_name, uint object_name_length);
+typedef struct PSI_sp_share* (*get_sp_share_v1_t)
+ (uint object_type,
+ const char *schema_name, uint schema_name_length,
+ const char *object_name, uint object_name_length);
+typedef void (*release_sp_share_v1_t)(struct PSI_sp_share *share);
+typedef PSI_metadata_lock* (*create_metadata_lock_v1_t)
+ (void *identity,
+ const MDL_key *key,
+ opaque_mdl_type mdl_type,
+ opaque_mdl_duration mdl_duration,
+ opaque_mdl_status mdl_status,
+ const char *src_file,
+ uint src_line);
+typedef void (*set_metadata_lock_status_v1_t)(PSI_metadata_lock *lock,
+ opaque_mdl_status mdl_status);
+typedef void (*destroy_metadata_lock_v1_t)(PSI_metadata_lock *lock);
+typedef struct PSI_metadata_locker* (*start_metadata_wait_v1_t)
+ (struct PSI_metadata_locker_state_v1 *state,
+ struct PSI_metadata_lock *mdl,
+ const char *src_file, uint src_line);
+typedef void (*end_metadata_wait_v1_t)
+ (struct PSI_metadata_locker *locker, int rc);
typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
const void *from_cs);
struct PSI_v1
@@ -527,11 +720,14 @@ struct PSI_v1
spawn_thread_v1_t spawn_thread;
new_thread_v1_t new_thread;
set_thread_id_v1_t set_thread_id;
+ set_thread_THD_v1_t set_thread_THD;
+ set_thread_os_id_v1_t set_thread_os_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_account_v1_t set_thread_account;
set_thread_db_v1_t set_thread_db;
set_thread_command_v1_t set_thread_command;
+ set_connection_type_v1_t set_connection_type;
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;
@@ -563,11 +759,15 @@ struct PSI_v1
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;
+ end_temp_file_open_wait_and_bind_to_descriptor_v1_t
+ end_temp_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;
+ end_file_rename_wait_v1_t end_file_rename_wait;
start_stage_v1_t start_stage;
+ get_current_stage_progress_v1_t get_current_stage_progress;
end_stage_v1_t end_stage;
get_thread_statement_locker_v1_t get_thread_statement_locker;
refine_statement_v1_t refine_statement;
@@ -590,14 +790,45 @@ struct PSI_v1
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;
+ get_thread_transaction_locker_v1_t get_thread_transaction_locker;
+ start_transaction_v1_t start_transaction;
+ set_transaction_xid_v1_t set_transaction_xid;
+ set_transaction_xa_state_v1_t set_transaction_xa_state;
+ set_transaction_gtid_v1_t set_transaction_gtid;
+ set_transaction_trxid_v1_t set_transaction_trxid;
+ inc_transaction_savepoints_v1_t inc_transaction_savepoints;
+ inc_transaction_rollback_to_savepoint_v1_t inc_transaction_rollback_to_savepoint;
+ inc_transaction_release_savepoint_v1_t inc_transaction_release_savepoint;
+ end_transaction_v1_t end_transaction;
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;
+ create_prepared_stmt_v1_t create_prepared_stmt;
+ destroy_prepared_stmt_v1_t destroy_prepared_stmt;
+ reprepare_prepared_stmt_v1_t reprepare_prepared_stmt;
+ execute_prepared_stmt_v1_t execute_prepared_stmt;
+ set_prepared_stmt_text_v1_t set_prepared_stmt_text;
digest_start_v1_t digest_start;
digest_end_v1_t digest_end;
set_thread_connect_attrs_v1_t set_thread_connect_attrs;
+ start_sp_v1_t start_sp;
+ end_sp_v1_t end_sp;
+ drop_sp_v1_t drop_sp;
+ get_sp_share_v1_t get_sp_share;
+ release_sp_share_v1_t release_sp_share;
+ register_memory_v1_t register_memory;
+ memory_alloc_v1_t memory_alloc;
+ memory_realloc_v1_t memory_realloc;
+ memory_claim_v1_t memory_claim;
+ memory_free_v1_t memory_free;
+ unlock_table_v1_t unlock_table;
+ create_metadata_lock_v1_t create_metadata_lock;
+ set_metadata_lock_status_v1_t set_metadata_lock_status;
+ destroy_metadata_lock_v1_t destroy_metadata_lock;
+ start_metadata_wait_v1_t start_metadata_wait;
+ end_metadata_wait_v1_t end_metadata_wait;
};
typedef struct PSI_v1 PSI;
typedef struct PSI_mutex_info_v1 PSI_mutex_info;
@@ -607,15 +838,17 @@ 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_transaction_info_v1 PSI_transaction_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_transaction_locker_state_v1 PSI_transaction_locker_state;
typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
-extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
+typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state;
+typedef struct PSI_metadata_locker_state_v1 PSI_metadata_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 67c054848a1..3495d618b05 100644
--- a/include/mysql/psi/psi_abi_v2.h
+++ b/include/mysql/psi/psi_abi_v2.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2013, 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, version 2.0,
diff --git a/include/mysql/psi/psi_abi_v2.h.pp b/include/mysql/psi/psi_abi_v2.h.pp
index adf1af7cfae..a670e53a8b7 100644
--- a/include/mysql/psi/psi_abi_v2.h.pp
+++ b/include/mysql/psi/psi_abi_v2.h.pp
@@ -1,6 +1,24 @@
+extern "C" {
+}
+extern "C" {
+struct PSI_thread;
+typedef unsigned int PSI_memory_key;
+struct PSI_memory_info_v2
+{
+ int placeholder;
+};
+typedef struct PSI_memory_info_v2 PSI_memory_info;
+}
C_MODE_START
+struct MDL_key;
+typedef struct MDL_key MDL_key;
+typedef int opaque_mdl_type;
+typedef int opaque_mdl_duration;
+typedef int opaque_mdl_status;
+typedef int opaque_vio_type;
struct TABLE_SHARE;
struct sql_digest_storage;
+ class THD;
struct PSI_mutex;
typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
@@ -17,14 +35,51 @@ struct PSI_file;
typedef struct PSI_file PSI_file;
struct PSI_socket;
typedef struct PSI_socket PSI_socket;
+struct PSI_prepared_stmt;
+typedef struct PSI_prepared_stmt PSI_prepared_stmt;
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_transaction_locker;
+typedef struct PSI_transaction_locker PSI_transaction_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_sp_share;
+typedef struct PSI_sp_share PSI_sp_share;
+struct PSI_sp_locker;
+typedef struct PSI_sp_locker PSI_sp_locker;
+struct PSI_metadata_lock;
+typedef struct PSI_metadata_lock PSI_metadata_lock;
+struct PSI_stage_progress
+{
+ ulonglong m_work_completed;
+ ulonglong m_work_estimated;
+};
+typedef struct PSI_stage_progress PSI_stage_progress;
+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;
+struct PSI_table_locker_state
+{
+ uint m_flags;
+ enum PSI_table_io_operation m_io_operation;
+ struct PSI_table *m_table;
+ struct PSI_table_share *m_table_share;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_wait;
+ uint m_index;
+};
+typedef struct PSI_table_locker_state PSI_table_locker_state;
struct PSI_bootstrap
{
void* (*get_interface)(int version);
@@ -40,6 +95,8 @@ struct PSI_file_locker;
typedef struct PSI_file_locker PSI_file_locker;
struct PSI_socket_locker;
typedef struct PSI_socket_locker PSI_socket_locker;
+struct PSI_metadata_locker;
+typedef struct PSI_metadata_locker PSI_metadata_locker;
enum PSI_mutex_operation
{
PSI_MUTEX_LOCK= 0,
@@ -51,7 +108,13 @@ enum PSI_rwlock_operation
PSI_RWLOCK_READLOCK= 0,
PSI_RWLOCK_WRITELOCK= 1,
PSI_RWLOCK_TRYREADLOCK= 2,
- PSI_RWLOCK_TRYWRITELOCK= 3
+ PSI_RWLOCK_TRYWRITELOCK= 3,
+ PSI_RWLOCK_SHAREDLOCK= 4,
+ PSI_RWLOCK_SHAREDEXCLUSIVELOCK= 5,
+ PSI_RWLOCK_EXCLUSIVELOCK= 6,
+ PSI_RWLOCK_TRYSHAREDLOCK= 7,
+ PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK= 8,
+ PSI_RWLOCK_TRYEXCLUSIVELOCK= 9
};
typedef enum PSI_rwlock_operation PSI_rwlock_operation;
enum PSI_cond_operation
@@ -81,14 +144,6 @@ enum PSI_file_operation
PSI_FILE_SYNC= 16
};
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,
@@ -160,6 +215,10 @@ struct PSI_statement_info_v2
{
int placeholder;
};
+struct PSI_transaction_info_v2
+{
+ int placeholder;
+};
struct PSI_idle_locker_state_v2
{
int placeholder;
@@ -180,11 +239,11 @@ struct PSI_file_locker_state_v2
{
int placeholder;
};
-struct PSI_table_locker_state_v2
+struct PSI_statement_locker_state_v2
{
int placeholder;
};
-struct PSI_statement_locker_state_v2
+struct PSI_transaction_locker_state_v2
{
int placeholder;
};
@@ -192,6 +251,10 @@ struct PSI_socket_locker_state_v2
{
int placeholder;
};
+struct PSI_metadata_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;
@@ -200,15 +263,17 @@ 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_transaction_info_v2 PSI_transaction_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_transaction_locker_state_v2 PSI_transaction_locker_state;
typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
-extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
+typedef struct PSI_sp_locker_state_v2 PSI_sp_locker_state;
+typedef struct PSI_metadata_locker_state_v2 PSI_metadata_locker_state;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
C_MODE_END
diff --git a/include/mysql/psi/psi_base.h b/include/mysql/psi/psi_base.h
index 2bb3061d55c..f365e2625ee 100644
--- a/include/mysql/psi/psi_base.h
+++ b/include/mysql/psi/psi_base.h
@@ -1,13 +1,25 @@
-/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ Without limiting anything contained in the foregoing, this file,
+ which is part of C Driver for MySQL (Connector/C), is also subject to the
+ Universal FOSS Exception, version 1.0, a copy of which can be found at
+ http://oss.oracle.com/licenses/universal-foss-exception.
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.
+ GNU General Public License, version 2.0, 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,
@@ -16,6 +28,10 @@
#ifndef MYSQL_PSI_BASE_H
#define MYSQL_PSI_BASE_H
+#ifdef EMBEDDED_LIBRARY
+#define DISABLE_ALL_PSI
+#endif /* EMBEDDED_LIBRARY */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -30,6 +46,7 @@ extern "C" {
*/
#define PSI_INSTRUMENT_ME 0
+#define PSI_INSTRUMENT_MEM ((PSI_memory_key)0)
#define PSI_NOT_INSTRUMENTED 0
@@ -69,6 +86,14 @@ extern "C" {
*/
#define PSI_FLAG_TRANSFER (1 << 5)
+/**
+ Volatility flag.
+ This flag indicate that an instrumented object
+ has a volatility (life cycle) comparable
+ to the volatility of a session.
+*/
+#define PSI_FLAG_VOLATILITY_SESSION (1 << 6)
+
#ifdef HAVE_PSI_INTERFACE
/**
diff --git a/include/mysql/psi/psi_memory.h b/include/mysql/psi/psi_memory.h
index 3c633e6a918..bbe2be32a29 100644
--- a/include/mysql/psi/psi_memory.h
+++ b/include/mysql/psi/psi_memory.h
@@ -1,13 +1,25 @@
/* Copyright (c) 2013, 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.
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ Without limiting anything contained in the foregoing, this file,
+ which is part of C Driver for MySQL (Connector/C), is also subject to the
+ Universal FOSS Exception, version 1.0, a copy of which can be found at
+ http://oss.oracle.com/licenses/universal-foss-exception.
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.
+ GNU General Public License, version 2.0, 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,
diff --git a/include/mysql_com.h b/include/mysql_com.h
index 4eafe148743..de9eb938f69 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -25,8 +25,10 @@
#define HOSTNAME_LENGTH 60
#define SYSTEM_CHARSET_MBMAXLEN 3
-#define NAME_CHAR_LEN 64U /* Field/table name length */
-#define USERNAME_CHAR_LENGTH 128U
+#define NAME_CHAR_LEN 64 /* Field/table name length */
+#define USERNAME_CHAR_LENGTH 128
+#define USERNAME_CHAR_LENGTH_STR STRINGIFY_ARG(USERNAME_CHAR_LENGTH)
+
#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
#define DEFINER_CHAR_LENGTH (USERNAME_CHAR_LENGTH + HOSTNAME_LENGTH + 1)
@@ -206,6 +208,8 @@ enum enum_indicator_type
itself supports it*/
#define LONG_UNIQUE_HASH_FIELD (1<< 30) /* This field will store hash for unique
column */
+#define FIELD_PART_OF_TMP_UNIQUE (1<< 31) /* part of an unique constrain
+ for a tmporary table*/
#define REFRESH_GRANT (1ULL << 0) /* Refresh grant tables */
#define REFRESH_LOG (1ULL << 1) /* Start on new log file */
@@ -296,6 +300,8 @@ enum enum_indicator_type
#define MARIADB_CLIENT_COM_MULTI (1ULL << 33)
/* support of array binding */
#define MARIADB_CLIENT_STMT_BULK_OPERATIONS (1ULL << 34)
+/* support of extended metadata (e.g. type/format information) */
+#define MARIADB_CLIENT_EXTENDED_METADATA (1ULL << 35)
#ifdef HAVE_COMPRESS
#define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
@@ -337,6 +343,7 @@ enum enum_indicator_type
CLIENT_CONNECT_ATTRS |\
MARIADB_CLIENT_COM_MULTI |\
MARIADB_CLIENT_STMT_BULK_OPERATIONS |\
+ MARIADB_CLIENT_EXTENDED_METADATA|\
CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)
/*
@@ -348,6 +355,15 @@ enum enum_indicator_type
& ~CLIENT_COMPRESS) \
& ~CLIENT_SSL_VERIFY_SERVER_CERT)
+enum mariadb_field_attr_t
+{
+ MARIADB_FIELD_ATTR_DATA_TYPE_NAME= 0,
+ MARIADB_FIELD_ATTR_FORMAT_NAME= 1
+};
+
+#define MARIADB_FIELD_ATTR_LAST MARIADB_FIELD_ATTR_FORMAT_NAME
+
+
/**
Is raised when a multi-statement transaction
has been started, either explicitly, by means
diff --git a/include/pfs_file_provider.h b/include/pfs_file_provider.h
new file mode 100644
index 00000000000..3df999894fd
--- /dev/null
+++ b/include/pfs_file_provider.h
@@ -0,0 +1,92 @@
+/* Copyright (c) 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_FILE_PROVIDER_H
+#define PFS_FILE_PROVIDER_H
+
+/**
+ @file include/pfs_file_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_FILE_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_FILE_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_file_v1(const char *category,
+ PSI_file_info_v1 *info,
+ int count);
+
+void pfs_create_file_v1(PSI_file_key key, const char *name, File file);
+
+PSI_file_locker*
+pfs_get_thread_file_name_locker_v1(PSI_file_locker_state *state,
+ PSI_file_key key,
+ PSI_file_operation op,
+ const char *name, const void *identity);
+
+PSI_file_locker*
+pfs_get_thread_file_stream_locker_v1(PSI_file_locker_state *state,
+ PSI_file *file, PSI_file_operation op);
+
+PSI_file_locker*
+pfs_get_thread_file_descriptor_locker_v1(PSI_file_locker_state *state,
+ File file, PSI_file_operation op);
+
+void pfs_start_file_open_wait_v1(PSI_file_locker *locker,
+ const char *src_file,
+ uint src_line);
+
+PSI_file* pfs_end_file_open_wait_v1(PSI_file_locker *locker, void *result);
+
+void pfs_end_file_open_wait_and_bind_to_descriptor_v1
+ (PSI_file_locker *locker, File file);
+
+void pfs_end_temp_file_open_wait_and_bind_to_descriptor_v1
+ (PSI_file_locker *locker, File file, const char *filename);
+
+void pfs_start_file_wait_v1(PSI_file_locker *locker,
+ size_t count,
+ const char *src_file,
+ uint src_line);
+
+void pfs_end_file_wait_v1(PSI_file_locker *locker,
+ size_t byte_count);
+
+void pfs_start_file_close_wait_v1(PSI_file_locker *locker,
+ const char *src_file,
+ uint src_line);
+
+void pfs_end_file_close_wait_v1(PSI_file_locker *locker, int rc);
+
+void pfs_end_file_rename_wait_v1(PSI_file_locker *locker, const char *old_name,
+ const char *new_name, int rc);
+
+C_MODE_END
+
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_FILE_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_idle_provider.h b/include/pfs_idle_provider.h
new file mode 100644
index 00000000000..71d116f7423
--- /dev/null
+++ b/include/pfs_idle_provider.h
@@ -0,0 +1,48 @@
+/* Copyright (c) 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_IDLE_PROVIDER_H
+#define PFS_IDLE_PROVIDER_H
+
+/**
+ @file include/pfs_idle_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_IDLE_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_IDLE_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+PSI_idle_locker*
+pfs_start_idle_wait_v1(PSI_idle_locker_state* state, const char *src_file, uint src_line);
+
+void pfs_end_idle_wait_v1(PSI_idle_locker* locker);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_IDLE_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_memory_provider.h b/include/pfs_memory_provider.h
new file mode 100644
index 00000000000..ea60f9de3be
--- /dev/null
+++ b/include/pfs_memory_provider.h
@@ -0,0 +1,57 @@
+/* Copyright (c) 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_MEMORY_PROVIDER_H
+#define PFS_MEMORY_PROVIDER_H
+
+/**
+ @file include/pfs_memory_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_MEMORY_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_MEMORY_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_memory_v1
+ (const char *category, struct PSI_memory_info_v1 *info, int count);
+
+PSI_memory_key
+pfs_memory_alloc_v1
+ (PSI_memory_key key, size_t size, PSI_thread **owner);
+
+PSI_memory_key
+pfs_memory_realloc_v1
+ (PSI_memory_key key, size_t old_size, size_t new_size, PSI_thread **owner);
+
+void pfs_memory_free_v1
+ (PSI_memory_key key, size_t size, PSI_thread *owner);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_MEMORY_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_metadata_provider.h b/include/pfs_metadata_provider.h
new file mode 100644
index 00000000000..cf3dd0d0dc1
--- /dev/null
+++ b/include/pfs_metadata_provider.h
@@ -0,0 +1,67 @@
+/* Copyright (c) 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_METADATA_PROVIDER_H
+#define PFS_METADATA_PROVIDER_H
+
+/**
+ @file include/pfs_metadata_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_METADATA_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+PSI_metadata_lock* pfs_create_metadata_lock_v1
+ (void *identity,
+ const MDL_key *key,
+ opaque_mdl_type mdl_type,
+ opaque_mdl_duration mdl_duration,
+ opaque_mdl_status mdl_status,
+ const char *src_file,
+ uint src_line);
+
+void pfs_set_metadata_lock_status_v1
+ (PSI_metadata_lock *lock,
+ opaque_mdl_status mdl_status);
+
+void pfs_destroy_metadata_lock_v1(PSI_metadata_lock *lock);
+
+struct PSI_metadata_locker*
+pfs_start_metadata_wait_v1
+ (struct PSI_metadata_locker_state_v1 *state,
+ struct PSI_metadata_lock *mdl,
+ const char *src_file, uint src_line);
+
+void pfs_end_metadata_wait_v1
+ (struct PSI_metadata_locker *locker, int rc);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_METADATA_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_socket_provider.h b/include/pfs_socket_provider.h
new file mode 100644
index 00000000000..bfafdaafb00
--- /dev/null
+++ b/include/pfs_socket_provider.h
@@ -0,0 +1,71 @@
+/* Copyright (c) 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_SOCKET_PROVIDER_H
+#define PFS_SOCKET_PROVIDER_H
+
+/**
+ @file include/pfs_socket_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_SOCKET_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_socket_v1(const char *category,
+ PSI_socket_info_v1 *info,
+ int count);
+
+PSI_socket*
+pfs_init_socket_v1(PSI_socket_key key, const my_socket *fd,
+ const struct sockaddr *addr, socklen_t addr_len);
+
+void pfs_destroy_socket_v1(PSI_socket *socket);
+
+PSI_socket_locker*
+pfs_start_socket_wait_v1(PSI_socket_locker_state *state,
+ PSI_socket *socket,
+ PSI_socket_operation op,
+ size_t count,
+ const char *src_file, uint src_line);
+
+void pfs_end_socket_wait_v1(PSI_socket_locker *locker, size_t byte_count);
+
+void pfs_set_socket_state_v1(PSI_socket *socket, PSI_socket_state state);
+
+void pfs_set_socket_info_v1(PSI_socket *socket,
+ const my_socket *fd,
+ const struct sockaddr *addr,
+ socklen_t addr_len);
+
+void pfs_set_socket_thread_owner_v1(PSI_socket *socket);
+
+C_MODE_END
+
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_SOCKET_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_stage_provider.h b/include/pfs_stage_provider.h
new file mode 100644
index 00000000000..2ad2faab890
--- /dev/null
+++ b/include/pfs_stage_provider.h
@@ -0,0 +1,52 @@
+/* Copyright (c) 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_STAGE_PROVIDER_H
+#define PFS_STAGE_PROVIDER_H
+
+/**
+ @file include/pfs_stage_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_STAGE_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_stage_v1(const char *category,
+ PSI_stage_info_v1 **info_array,
+ int count);
+
+PSI_stage_progress* pfs_start_stage_v1(PSI_stage_key key, const char *src_file, int src_line);
+PSI_stage_progress* pfs_get_current_stage_progress_v1();
+
+void pfs_end_stage_v1();
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_STAGE_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_statement_provider.h b/include/pfs_statement_provider.h
new file mode 100644
index 00000000000..96870d8400d
--- /dev/null
+++ b/include/pfs_statement_provider.h
@@ -0,0 +1,118 @@
+/* Copyright (c) 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_STATEMENT_PROVIDER_H
+#define PFS_STATEMENT_PROVIDER_H
+
+/**
+ @file include/pfs_statement_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_STATEMENT_CALL(M) pfs_ ## M ## _v1
+#define PSI_DIGEST_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_statement_v1(const char *category,
+ PSI_statement_info_v1 *info,
+ int count);
+
+PSI_statement_locker*
+pfs_get_thread_statement_locker_v1(PSI_statement_locker_state *state,
+ PSI_statement_key key,
+ const void *charset,
+ PSI_sp_share *sp_share);
+
+PSI_statement_locker*
+pfs_refine_statement_v1(PSI_statement_locker *locker,
+ PSI_statement_key key);
+
+void pfs_start_statement_v1(PSI_statement_locker *locker,
+ const char *db, uint db_len,
+ const char *src_file, uint src_line);
+
+void pfs_set_statement_text_v1(PSI_statement_locker *locker,
+ const char *text, uint text_len);
+
+void pfs_set_statement_lock_time_v1(PSI_statement_locker *locker,
+ ulonglong count);
+
+void pfs_set_statement_rows_sent_v1(PSI_statement_locker *locker,
+ ulonglong count);
+
+void pfs_set_statement_rows_examined_v1(PSI_statement_locker *locker,
+ ulonglong count);
+
+void pfs_inc_statement_created_tmp_disk_tables_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_created_tmp_tables_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_full_join_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_full_range_join_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_range_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_range_check_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_scan_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_sort_merge_passes_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_sort_range_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_sort_rows_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_sort_scan_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_set_statement_no_index_used_v1(PSI_statement_locker *locker);
+
+void pfs_set_statement_no_good_index_used_v1(PSI_statement_locker *locker);
+
+void pfs_end_statement_v1(PSI_statement_locker *locker, void *stmt_da);
+
+PSI_digest_locker *pfs_digest_start_v1(PSI_statement_locker *locker);
+
+void pfs_digest_end_v1(PSI_digest_locker *locker,
+ const sql_digest_storage *digest);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_STATEMENT_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_table_provider.h b/include/pfs_table_provider.h
new file mode 100644
index 00000000000..0d7ee76274b
--- /dev/null
+++ b/include/pfs_table_provider.h
@@ -0,0 +1,83 @@
+/* Copyright (c) 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_TABLE_PROVIDER_H
+#define PFS_TABLE_PROVIDER_H
+
+/**
+ @file include/pfs_table_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_TABLE_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_TABLE_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+PSI_table_share*
+pfs_get_table_share_v1(my_bool temporary, struct TABLE_SHARE *share);
+
+void pfs_release_table_share_v1(PSI_table_share* share);
+
+void
+pfs_drop_table_share_v1(my_bool temporary,
+ const char *schema_name, int schema_name_length,
+ const char *table_name, int table_name_length);
+
+PSI_table*
+pfs_open_table_v1(PSI_table_share *share, const void *identity);
+
+void pfs_unbind_table_v1(PSI_table *table);
+
+PSI_table *
+pfs_rebind_table_v1(PSI_table_share *share, const void *identity, PSI_table *table);
+
+void pfs_close_table_v1(struct TABLE_SHARE *server_share, PSI_table *table);
+
+PSI_table_locker*
+pfs_start_table_io_wait_v1(PSI_table_locker_state *state,
+ PSI_table *table,
+ PSI_table_io_operation op,
+ uint index,
+ const char *src_file, uint src_line);
+
+PSI_table_locker*
+pfs_start_table_lock_wait_v1(PSI_table_locker_state *state,
+ PSI_table *table,
+ PSI_table_lock_operation op,
+ ulong op_flags,
+ const char *src_file, uint src_line);
+
+void pfs_end_table_io_wait_v1(PSI_table_locker* locker, ulonglong numrows);
+
+void pfs_end_table_lock_wait_v1(PSI_table_locker* locker);
+
+void pfs_unlock_table_v1(PSI_table *table);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_TABLE_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_thread_provider.h b/include/pfs_thread_provider.h
new file mode 100644
index 00000000000..c4118a8efbf
--- /dev/null
+++ b/include/pfs_thread_provider.h
@@ -0,0 +1,170 @@
+/* Copyright (c) 2012, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_THREAD_PROVIDER_H
+#define PFS_THREAD_PROVIDER_H
+
+/**
+ @file include/pfs_thread_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_THREAD_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_MUTEX_CALL(M) pfs_ ## M ## _v1
+#define PSI_RWLOCK_CALL(M) pfs_ ## M ## _v1
+#define PSI_COND_CALL(M) pfs_ ## M ## _v1
+#define PSI_THREAD_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_mutex_v1(const char *category,
+ PSI_mutex_info_v1 *info,
+ int count);
+
+void pfs_register_rwlock_v1(const char *category,
+ PSI_rwlock_info_v1 *info,
+ int count);
+
+void pfs_register_cond_v1(const char *category,
+ PSI_cond_info_v1 *info,
+ int count);
+
+void pfs_register_thread_v1(const char *category,
+ PSI_thread_info_v1 *info,
+ int count);
+
+PSI_mutex*
+pfs_init_mutex_v1(PSI_mutex_key key, const void *identity);
+
+void pfs_destroy_mutex_v1(PSI_mutex* mutex);
+
+PSI_rwlock*
+pfs_init_rwlock_v1(PSI_rwlock_key key, const void *identity);
+
+void pfs_destroy_rwlock_v1(PSI_rwlock* rwlock);
+
+PSI_cond*
+pfs_init_cond_v1(PSI_cond_key key, const void *identity);
+
+void pfs_destroy_cond_v1(PSI_cond* cond);
+
+int pfs_spawn_thread_v1(PSI_thread_key key,
+ pthread_t *thread, const pthread_attr_t *attr,
+ void *(*start_routine)(void*), void *arg);
+
+PSI_thread*
+pfs_new_thread_v1(PSI_thread_key key, const void *identity, ulonglong processlist_id);
+
+void pfs_set_thread_id_v1(PSI_thread *thread, ulonglong processlist_id);
+void pfs_set_thread_THD_v1(PSI_thread *thread, THD *thd);
+void pfs_set_thread_os_id_v1(PSI_thread *thread);
+
+PSI_thread*
+pfs_get_thread_v1(void);
+
+void pfs_set_thread_user_v1(const char *user, int user_len);
+
+void pfs_set_thread_account_v1(const char *user, int user_len,
+ const char *host, int host_len);
+
+void pfs_set_thread_db_v1(const char* db, int db_len);
+
+void pfs_set_thread_command_v1(int command);
+
+void pfs_set_thread_start_time_v1(time_t start_time);
+
+void pfs_set_thread_state_v1(const char* state);
+
+void pfs_set_connection_type_v1(opaque_vio_type conn_type);
+
+void pfs_set_thread_info_v1(const char* info, uint info_len);
+
+void pfs_set_thread_v1(PSI_thread* thread);
+
+void pfs_delete_current_thread_v1(void);
+
+void pfs_delete_thread_v1(PSI_thread *thread);
+
+PSI_mutex_locker*
+pfs_start_mutex_wait_v1(PSI_mutex_locker_state *state,
+ PSI_mutex *mutex, PSI_mutex_operation op,
+ const char *src_file, uint src_line);
+
+PSI_rwlock_locker*
+pfs_start_rwlock_rdwait_v1(PSI_rwlock_locker_state *state,
+ PSI_rwlock *rwlock,
+ PSI_rwlock_operation op,
+ const char *src_file, uint src_line);
+
+PSI_rwlock_locker*
+pfs_start_rwlock_wrwait_v1(PSI_rwlock_locker_state *state,
+ PSI_rwlock *rwlock,
+ PSI_rwlock_operation op,
+ const char *src_file, uint src_line);
+
+PSI_cond_locker*
+pfs_start_cond_wait_v1(PSI_cond_locker_state *state,
+ PSI_cond *cond, PSI_mutex *mutex,
+ PSI_cond_operation op,
+ const char *src_file, uint src_line);
+
+PSI_table_locker*
+pfs_start_table_io_wait_v1(PSI_table_locker_state *state,
+ PSI_table *table,
+ PSI_table_io_operation op,
+ uint index,
+ const char *src_file, uint src_line);
+
+PSI_table_locker*
+pfs_start_table_lock_wait_v1(PSI_table_locker_state *state,
+ PSI_table *table,
+ PSI_table_lock_operation op,
+ ulong op_flags,
+ const char *src_file, uint src_line);
+
+void pfs_unlock_mutex_v1(PSI_mutex *mutex);
+
+void pfs_unlock_rwlock_v1(PSI_rwlock *rwlock);
+
+void pfs_signal_cond_v1(PSI_cond* cond);
+
+void pfs_broadcast_cond_v1(PSI_cond* cond);
+
+void pfs_end_mutex_wait_v1(PSI_mutex_locker* locker, int rc);
+
+void pfs_end_rwlock_rdwait_v1(PSI_rwlock_locker* locker, int rc);
+
+void pfs_end_rwlock_wrwait_v1(PSI_rwlock_locker* locker, int rc);
+
+void pfs_end_cond_wait_v1(PSI_cond_locker* locker, int rc);
+
+int pfs_set_thread_connect_attrs_v1(const char *buffer, uint length,
+ const void *from_cs);
+
+C_MODE_END
+
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_THREAD_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_transaction_provider.h b/include/pfs_transaction_provider.h
new file mode 100644
index 00000000000..fdaad8ae1c6
--- /dev/null
+++ b/include/pfs_transaction_provider.h
@@ -0,0 +1,79 @@
+/* Copyright (c) 2013, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_TRANSACTION_PROVIDER_H
+#define PFS_TRANSACTION_PROVIDER_H
+
+/**
+ @file include/pfs_transaction_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_TRANSACTION_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+PSI_transaction_locker*
+pfs_get_thread_transaction_locker_v1(PSI_transaction_locker_state *state,
+ const void *xid,
+ ulonglong trxid,
+ int isolation_level,
+ my_bool read_only,
+ my_bool autocommit);
+
+void pfs_start_transaction_v1(PSI_transaction_locker *locker,
+ const char *src_file, uint src_line);
+
+void pfs_set_transaction_xid_v1(PSI_transaction_locker *locker,
+ const void *xid,
+ int xa_state);
+
+void pfs_set_transaction_xa_state_v1(PSI_transaction_locker *locker,
+ int xa_state);
+
+void pfs_set_transaction_gtid_v1(PSI_transaction_locker *locker,
+ const void *sid,
+ const void *gtid_spec);
+
+void pfs_set_transaction_trxid_v1(PSI_transaction_locker *locker,
+ const ulonglong *trxid);
+
+void pfs_inc_transaction_savepoints_v1(PSI_transaction_locker *locker,
+ ulong count);
+
+void pfs_inc_transaction_rollback_to_savepoint_v1(PSI_transaction_locker *locker,
+ ulong count);
+
+void pfs_inc_transaction_release_savepoint_v1(PSI_transaction_locker *locker,
+ ulong count);
+
+void pfs_end_transaction_v1(PSI_transaction_locker *locker, my_bool commit);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_TRANSACTION_INTERFACE */
+
+#endif
+
diff --git a/include/thread_pool_priv.h b/include/thread_pool_priv.h
index 0112ef9c434..769c4a7d97d 100644
--- a/include/thread_pool_priv.h
+++ b/include/thread_pool_priv.h
@@ -38,12 +38,6 @@
#include <table.h>
#include <sql_list.h>
-/* Needed to get access to scheduler variables */
-void* thd_get_scheduler_data(THD *thd);
-void thd_set_scheduler_data(THD *thd, void *data);
-PSI_thread* thd_get_psi(THD *thd);
-void thd_set_psi(THD *thd, PSI_thread *psi);
-
/* Interface to THD variables and functions */
void thd_set_killed(THD *thd);
void thd_clear_errors(THD *thd);
diff --git a/include/violite.h b/include/violite.h
index 1d981c8bf83..95a4830df89 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -39,7 +39,10 @@ enum enum_vio_type
{
VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE,
VIO_TYPE_SSL
+ /* see also vio_type_names[] */
};
+#define FIRST_VIO_TYPE VIO_CLOSED
+#define LAST_VIO_TYPE VIO_TYPE_SSL
/**
VIO I/O events.
@@ -184,6 +187,8 @@ void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd);
void vio_end(void);
+const char *vio_type_name(enum enum_vio_type vio_type, size_t *len);
+
#ifdef __cplusplus
}
#endif