summaryrefslogtreecommitdiff
path: root/include/mysql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-07-28 15:52:12 +0200
committerSergei Golubchik <serg@mariadb.org>2016-07-28 15:52:12 +0200
commit15f60c1a733eced957384ac56317337fc5f32420 (patch)
tree32e5595cdaa5acc78023745d81e3e4a80571f352 /include/mysql
parent51ed64a520dfbec24b73bffc40494d738713df22 (diff)
downloadmariadb-git-15f60c1a733eced957384ac56317337fc5f32420.tar.gz
5.7.13
Diffstat (limited to 'include/mysql')
-rw-r--r--include/mysql/psi/mysql_file.h32
-rw-r--r--include/mysql/psi/mysql_idle.h6
-rw-r--r--include/mysql/psi/mysql_mdl.h121
-rw-r--r--include/mysql/psi/mysql_memory.h62
-rw-r--r--include/mysql/psi/mysql_ps.h88
-rw-r--r--include/mysql/psi/mysql_socket.h116
-rw-r--r--include/mysql/psi/mysql_sp.h97
-rw-r--r--include/mysql/psi/mysql_stage.h134
-rw-r--r--include/mysql/psi/mysql_statement.h23
-rw-r--r--include/mysql/psi/mysql_table.h87
-rw-r--r--include/mysql/psi/mysql_thread.h255
-rw-r--r--include/mysql/psi/mysql_transaction.h213
-rw-r--r--include/mysql/psi/psi.h866
-rw-r--r--include/mysql/psi/psi_abi_v0.h4
-rw-r--r--include/mysql/psi/psi_abi_v0.h.pp53
-rw-r--r--include/mysql/psi/psi_abi_v1.h.pp282
-rw-r--r--include/mysql/psi/psi_abi_v2.h4
-rw-r--r--include/mysql/psi/psi_abi_v2.h.pp93
-rw-r--r--include/mysql/psi/psi_base.h155
-rw-r--r--include/mysql/psi/psi_memory.h155
20 files changed, 2459 insertions, 387 deletions
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h
index a83e2ef8a1d..fd28886d7bc 100644
--- a/include/mysql/psi/mysql_file.h
+++ b/include/mysql/psi/mysql_file.h
@@ -43,6 +43,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
@@ -290,7 +294,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)
@@ -803,7 +807,8 @@ 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
@@ -1011,20 +1016,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 (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;
}
diff --git a/include/mysql/psi/mysql_idle.h b/include/mysql/psi/mysql_idle.h
index 5c72b715b7a..102304aa338 100644
--- a/include/mysql/psi/mysql_idle.h
+++ b/include/mysql/psi/mysql_idle.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2012, 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 as published by
@@ -23,6 +23,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..bb2b76c151c
--- /dev/null
+++ b/include/mysql/psi/mysql_mdl.h
@@ -0,0 +1,121 @@
+/* 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 MYSQL_MDL_H
+#define MYSQL_MDL_H
+
+/**
+ @file mysql/psi/mysql_mdl.h
+ Instrumentation helpers for metadata locks.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifndef PSI_METADATA_CALL
+#define PSI_METADATA_CALL(M) PSI_DYNAMIC_CALL(M)
+#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..55dd8184b10
--- /dev/null
+++ b/include/mysql/psi/mysql_memory.h
@@ -0,0 +1,62 @@
+/* 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 as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef MYSQL_MEMORY_H
+#define MYSQL_MEMORY_H
+
+/**
+ @file mysql/psi/mysql_memory.h
+ Instrumentation helpers for memory allocation.
+*/
+
+#include "mysql/psi/psi.h"
+
+#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 MY_ATTRIBUTE((unused)),
+ void *info MY_ATTRIBUTE((unused)),
+ int count MY_ATTRIBUTE((unused)))
+#endif
+{
+#ifdef HAVE_PSI_MEMORY_INTERFACE
+ PSI_MEMORY_CALL(register_memory)(category, info, count);
+#endif
+}
+
+/** @} (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..485e1fbedfa
--- /dev/null
+++ b/include/mysql/psi/mysql_ps.h
@@ -0,0 +1,88 @@
+/* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-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, SQLTEXT, SQLTEXT_LENGTH) \
+ inline_mysql_create_prepared_stmt(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_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)
+#else
+ #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, SQLTEXT_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)
+#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,
+ const char *sqltext, size_t sqltext_length)
+{
+ if (locker == NULL)
+ return NULL;
+ return PSI_PS_CALL(create_prepared_stmt)(identity, stmt_id,
+ locker,
+ stmt_name, stmt_name_length,
+ sqltext, sqltext_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);
+}
+#endif
+
+#endif
diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h
index 209f113ffe2..ad76e318b30 100644
--- a/include/mysql/psi/mysql_socket.h
+++ b/include/mysql/psi/mysql_socket.h
@@ -26,7 +26,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>
@@ -42,6 +42,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
@@ -60,6 +64,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. */
@@ -102,9 +107,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 addres
+ @param addr_len length of socket addres
*/
static inline void
@@ -129,7 +133,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(
@@ -196,7 +199,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.
*/
@@ -225,6 +227,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)
@@ -320,8 +329,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) \
@@ -425,7 +434,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) \
@@ -472,6 +481,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.
@@ -965,6 +987,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
@@ -1104,7 +1198,7 @@ inline_mysql_socket_shutdown
{
int result;
-#ifdef __WIN__
+#ifdef _WIN32
static LPFN_DISCONNECTEX DisconnectEx = NULL;
if (DisconnectEx == NULL)
{
@@ -1127,7 +1221,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;
@@ -1144,7 +1238,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..68fc468db1f
--- /dev/null
+++ b/include/mysql/psi/mysql_sp.h
@@ -0,0 +1,97 @@
+/* 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 as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#ifndef MYSQL_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 91a5c12f82e..9c1623f4373 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 as published by
@@ -23,6 +23,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
@@ -41,12 +45,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
@@ -58,11 +98,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 3d5943fa55a..9c27933b069 100644
--- a/include/mysql/psi/mysql_statement.h
+++ b/include/mysql/psi/mysql_statement.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,6 +23,17 @@
#include "mysql/psi/psi.h"
+class Diagnostics_area;
+typedef 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
@@ -58,10 +69,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
@@ -146,10 +157,12 @@ inline_mysql_start_statement(PSI_statement_locker_state *state,
PSI_statement_key key,
const char *db, uint db_len,
const CHARSET_INFO *charset,
+ PSI_sp_share *sp_share,
const char *src_file, int 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 (likely(locker != NULL))
PSI_STATEMENT_CALL(start_statement)(locker, db, 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 815313e654b..00f75661b70 100644
--- a/include/mysql/psi/mysql_table.h
+++ b/include/mysql/psi/mysql_table.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 as published by
@@ -23,6 +23,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
@@ -50,72 +54,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 != NULL) \
- { \
- PSI_table_locker *locker; \
- PSI_table_locker_state state; \
- locker= PSI_TABLE_CALL(start_table_io_wait) \
- (& state, PSI, OP, INDEX, __FILE__, __LINE__); \
- PAYLOAD \
- if (locker != NULL) \
- PSI_TABLE_CALL(end_table_io_wait)(locker); \
- } \
- else \
- { \
- PAYLOAD \
- } \
- }
-#else
- #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
- PAYLOAD
-#endif
-
-/**
- @def MYSQL_TABLE_LOCK_WAIT
- Instrumentation helper for table io_waits.
- This instrumentation marks the start of a wait event.
- @param PSI the instrumented table
- @param OP the table operation to be performed
- @param INDEX the table index used if any, or MAY_KEY.
- @param FLAGS per table operation flags.
- @sa MYSQL_END_TABLE_WAIT.
-*/
-#ifdef HAVE_PSI_TABLE_INTERFACE
- #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
- { \
- if (PSI != NULL) \
- { \
- PSI_table_locker *locker; \
- PSI_table_locker_state state; \
- locker= PSI_TABLE_CALL(start_table_lock_wait) \
- (& state, PSI, OP, FLAGS, __FILE__, __LINE__); \
- PAYLOAD \
- if (locker != NULL) \
- PSI_TABLE_CALL(end_table_lock_wait)(locker); \
- } \
- else \
- { \
- PAYLOAD \
- } \
- }
-#else
- #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
- PAYLOAD
-#endif
-
-/**
@def MYSQL_START_TABLE_LOCK_WAIT
Instrumentation helper for table lock waits.
This instrumentation marks the start of a wait event.
@@ -151,6 +89,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.
@@ -181,6 +127,13 @@ inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
if (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 ee2693d2863..c5ace991e0b 100644
--- a/include/mysql/psi/mysql_thread.h
+++ b/include/mysql/psi/mysql_thread.h
@@ -29,9 +29,9 @@
Other compilers, like gcc, optimize these dependencies by default.
Since the instrumented APIs declared here are wrapper on top
- of my_pthread / safemutex / etc APIs,
+ of my_thread / safemutex / etc APIs,
including mysql/psi/mysql_thread.h assumes that
- the dependency on my_pthread and safemutex already exists.
+ the dependency on my_thread and safemutex already exists.
*/
/*
Note: there are several orthogonal dimensions here.
@@ -49,12 +49,37 @@
- the pthread library
- fast mutexes
- window apis
- This is implemented by various macro definitions in my_pthread.h
+ This is implemented by various macro definitions in my_thread.h
This causes complexity with '#ifdef'-ery that can't be avoided.
*/
+#include "my_thread.h"
+#include "my_thread_local.h"
+#include "thr_mutex.h"
+#include "thr_rwlock.h"
#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
@@ -69,13 +94,7 @@
struct st_mysql_mutex
{
/** The real mutex. */
-#ifdef SAFE_MUTEX
- safe_mutex_t m_mutex;
-#elif defined(MY_PTHREAD_FASTMUTEX)
- my_pthread_fastmutex_t m_mutex;
-#else
- pthread_mutex_t m_mutex;
-#endif
+ my_mutex_t m_mutex;
/**
The instrumentation hook.
Note that this hook is not conditionally defined,
@@ -86,7 +105,7 @@ struct st_mysql_mutex
/**
Type of an instrumented mutex.
- @c mysql_mutex_t is a drop-in replacement for @c pthread_mutex_t.
+ @c mysql_mutex_t is a drop-in replacement for @c my_mutex_t.
@sa mysql_mutex_assert_owner
@sa mysql_mutex_assert_not_owner
@sa mysql_mutex_init
@@ -103,7 +122,7 @@ typedef struct st_mysql_mutex mysql_mutex_t;
struct st_mysql_rwlock
{
/** The real rwlock */
- rw_lock_t m_rwlock;
+ native_rw_lock_t m_rwlock;
/**
The instrumentation hook.
Note that this hook is not conditionally defined,
@@ -160,7 +179,7 @@ typedef struct st_mysql_prlock mysql_prlock_t;
struct st_mysql_cond
{
/** The real condition */
- pthread_cond_t m_cond;
+ native_cond_t m_cond;
/**
The instrumentation hook.
Note that this hook is not conditionally defined,
@@ -171,7 +190,7 @@ struct st_mysql_cond
/**
Type of an instrumented condition.
- @c mysql_cond_t is a drop-in replacement for @c pthread_cond_t.
+ @c mysql_cond_t is a drop-in replacement for @c native_cond_t.
@sa mysql_cond_init
@sa mysql_cond_wait
@sa mysql_cond_timedwait
@@ -207,8 +226,12 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_mutex_assert_owner is a drop-in replacement
for @c safe_mutex_assert_owner.
*/
+#ifdef SAFE_MUTEX
#define mysql_mutex_assert_owner(M) \
- safe_mutex_assert_owner(&(M)->m_mutex)
+ safe_mutex_assert_owner(&(M)->m_mutex);
+#else
+#define mysql_mutex_assert_owner(M) { }
+#endif
/**
@def mysql_mutex_assert_not_owner(M)
@@ -216,14 +239,26 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_mutex_assert_not_owner is a drop-in replacement
for @c safe_mutex_assert_not_owner.
*/
+#ifdef SAFE_MUTEX
#define mysql_mutex_assert_not_owner(M) \
- safe_mutex_assert_not_owner(&(M)->m_mutex)
-
-/** Wrappers for instrumented prlock objects. */
+ safe_mutex_assert_not_owner(&(M)->m_mutex);
+#else
+#define mysql_mutex_assert_not_owner(M) { }
+#endif
+/**
+ @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)
@@ -294,7 +329,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@def mysql_mutex_trylock(M)
Instrumented mutex_lock.
@c mysql_mutex_trylock is a drop-in replacement
- for @c pthread_mutex_trylock.
+ for @c my_mutex_trylock.
*/
#if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE)
@@ -476,17 +511,18 @@ typedef struct st_mysql_cond mysql_cond_t;
inline_mysql_cond_register(P1, P2, P3)
/**
- @def mysql_cond_init(K, C, A)
+ @def mysql_cond_init(K, C)
Instrumented cond_init.
@c mysql_cond_init is a replacement for @c pthread_cond_init.
+ Note that pthread_condattr_t is not supported in MySQL.
@param C The cond to initialize
@param K The PSI_cond_key for this instrumented cond
- @param A Condition attributes
+
*/
#ifdef HAVE_PSI_COND_INTERFACE
- #define mysql_cond_init(K, C, A) inline_mysql_cond_init(K, C, A)
+ #define mysql_cond_init(K, C) inline_mysql_cond_init(K, C)
#else
- #define mysql_cond_init(K, C, A) inline_mysql_cond_init(C, A)
+ #define mysql_cond_init(K, C) inline_mysql_cond_init(C)
#endif
/**
@@ -499,9 +535,9 @@ typedef struct st_mysql_cond mysql_cond_t;
/**
@def mysql_cond_wait(C)
Instrumented cond_wait.
- @c mysql_cond_wait is a drop-in replacement for @c pthread_cond_wait.
+ @c mysql_cond_wait is a drop-in replacement for @c native_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
@@ -513,9 +549,9 @@ typedef struct st_mysql_cond mysql_cond_t;
@def mysql_cond_timedwait(C, M, W)
Instrumented cond_timedwait.
@c mysql_cond_timedwait is a drop-in replacement
- for @c pthread_cond_timedwait.
+ for @c native_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
@@ -547,9 +583,9 @@ typedef struct st_mysql_cond mysql_cond_t;
/**
@def mysql_thread_create(K, P1, P2, P3, P4)
- Instrumented pthread_create.
+ Instrumented my_thread_create.
This function creates both the thread instrumentation and a thread.
- @c mysql_thread_create is a replacement for @c pthread_create.
+ @c mysql_thread_create is a replacement for @c my_thread_create.
The parameter P4 (or, if it is NULL, P1) will be used as the
instrumented thread "indentity".
Providing a P1 / P4 parameter with a different value for each call
@@ -557,22 +593,22 @@ typedef struct st_mysql_cond mysql_cond_t;
is used internally to randomize access to data and prevent contention.
This is optional, and the improvement is not guaranteed, only statistical.
@param K The PSI_thread_key for this instrumented thread
- @param P1 pthread_create parameter 1
- @param P2 pthread_create parameter 2
- @param P3 pthread_create parameter 3
- @param P4 pthread_create parameter 4
+ @param P1 my_thread_create parameter 1
+ @param P2 my_thread_create parameter 2
+ @param P3 my_thread_create parameter 3
+ @param P4 my_thread_create parameter 4
*/
#ifdef HAVE_PSI_THREAD_INTERFACE
#define mysql_thread_create(K, P1, P2, P3, P4) \
inline_mysql_thread_create(K, P1, P2, P3, P4)
#else
#define mysql_thread_create(K, P1, P2, P3, P4) \
- pthread_create(P1, P2, P3, P4)
+ my_thread_create(P1, P2, P3, P4)
#endif
/**
@def mysql_thread_set_psi_id(I)
- Set the thread indentifier for the instrumentation.
+ Set the thread identifier for the instrumentation.
@param I The thread identifier
*/
#ifdef HAVE_PSI_THREAD_INTERFACE
@@ -581,6 +617,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,
@@ -603,7 +650,7 @@ static inline int inline_mysql_mutex_init(
PSI_mutex_key key,
#endif
mysql_mutex_t *that,
- const pthread_mutexattr_t *attr
+ const native_mutexattr_t *attr
#ifdef SAFE_MUTEX
, const char *src_file, uint src_line
#endif
@@ -614,13 +661,11 @@ static inline int inline_mysql_mutex_init(
#else
that->m_psi= NULL;
#endif
+ return my_mutex_init(&that->m_mutex, attr
#ifdef SAFE_MUTEX
- return safe_mutex_init(&that->m_mutex, attr, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- return my_pthread_fastmutex_init(&that->m_mutex, attr);
-#else
- return pthread_mutex_init(&that->m_mutex, attr);
+ , src_file, src_line
#endif
+ );
}
static inline int inline_mysql_mutex_destroy(
@@ -637,13 +682,11 @@ static inline int inline_mysql_mutex_destroy(
that->m_psi= NULL;
}
#endif
+ return my_mutex_destroy(&that->m_mutex
#ifdef SAFE_MUTEX
- return safe_mutex_destroy(&that->m_mutex, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- return pthread_mutex_destroy(&that->m_mutex.mutex);
-#else
- return pthread_mutex_destroy(&that->m_mutex);
+ , src_file, src_line
#endif
+ );
}
static inline int inline_mysql_mutex_lock(
@@ -665,13 +708,11 @@ static inline int inline_mysql_mutex_lock(
PSI_MUTEX_LOCK, src_file, src_line);
/* Instrumented code */
+ result= my_mutex_lock(&that->m_mutex
#ifdef SAFE_MUTEX
- result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= my_pthread_fastmutex_lock(&that->m_mutex);
-#else
- result= pthread_mutex_lock(&that->m_mutex);
+ , src_file, src_line
#endif
+ );
/* Instrumentation end */
if (locker != NULL)
@@ -682,13 +723,11 @@ static inline int inline_mysql_mutex_lock(
#endif
/* Non instrumented code */
+ result= my_mutex_lock(&that->m_mutex
#ifdef SAFE_MUTEX
- result= safe_mutex_lock(&that->m_mutex, FALSE, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= my_pthread_fastmutex_lock(&that->m_mutex);
-#else
- result= pthread_mutex_lock(&that->m_mutex);
+ , src_file, src_line
#endif
+ );
return result;
}
@@ -712,13 +751,11 @@ static inline int inline_mysql_mutex_trylock(
PSI_MUTEX_TRYLOCK, src_file, src_line);
/* Instrumented code */
+ result= my_mutex_trylock(&that->m_mutex
#ifdef SAFE_MUTEX
- result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= pthread_mutex_trylock(&that->m_mutex.mutex);
-#else
- result= pthread_mutex_trylock(&that->m_mutex);
+ , src_file, src_line
#endif
+ );
/* Instrumentation end */
if (locker != NULL)
@@ -729,13 +766,11 @@ static inline int inline_mysql_mutex_trylock(
#endif
/* Non instrumented code */
+ result= my_mutex_trylock(&that->m_mutex
#ifdef SAFE_MUTEX
- result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= pthread_mutex_trylock(&that->m_mutex.mutex);
-#else
- result= pthread_mutex_trylock(&that->m_mutex);
+ , src_file, src_line
#endif
+ );
return result;
}
@@ -754,13 +789,11 @@ static inline int inline_mysql_mutex_unlock(
PSI_MUTEX_CALL(unlock_mutex)(that->m_psi);
#endif
+ result= my_mutex_unlock(&that->m_mutex
#ifdef SAFE_MUTEX
- result= safe_mutex_unlock(&that->m_mutex, src_file, src_line);
-#elif defined(MY_PTHREAD_FASTMUTEX)
- result= pthread_mutex_unlock(&that->m_mutex.mutex);
-#else
- result= pthread_mutex_unlock(&that->m_mutex);
+ , src_file, src_line
#endif
+ );
return result;
}
@@ -793,10 +826,7 @@ static inline int inline_mysql_rwlock_init(
#else
that->m_psi= NULL;
#endif
- /*
- pthread_rwlockattr_t is not used in MySQL.
- */
- return my_rwlock_init(&that->m_rwlock, NULL);
+ return native_rw_init(&that->m_rwlock);
}
#ifndef DISABLE_MYSQL_PRLOCK_H
@@ -825,7 +855,7 @@ static inline int inline_mysql_rwlock_destroy(
that->m_psi= NULL;
}
#endif
- return rwlock_destroy(&that->m_rwlock);
+ return native_rw_destroy(&that->m_rwlock);
}
#ifndef DISABLE_MYSQL_PRLOCK_H
@@ -862,7 +892,7 @@ static inline int inline_mysql_rwlock_rdlock(
PSI_RWLOCK_READLOCK, src_file, src_line);
/* Instrumented code */
- result= rw_rdlock(&that->m_rwlock);
+ result= native_rw_rdlock(&that->m_rwlock);
/* Instrumentation end */
if (locker != NULL)
@@ -873,7 +903,7 @@ static inline int inline_mysql_rwlock_rdlock(
#endif
/* Non instrumented code */
- result= rw_rdlock(&that->m_rwlock);
+ result= native_rw_rdlock(&that->m_rwlock);
return result;
}
@@ -934,7 +964,7 @@ static inline int inline_mysql_rwlock_wrlock(
PSI_RWLOCK_WRITELOCK, src_file, src_line);
/* Instrumented code */
- result= rw_wrlock(&that->m_rwlock);
+ result= native_rw_wrlock(&that->m_rwlock);
/* Instrumentation end */
if (locker != NULL)
@@ -945,7 +975,7 @@ static inline int inline_mysql_rwlock_wrlock(
#endif
/* Non instrumented code */
- result= rw_wrlock(&that->m_rwlock);
+ result= native_rw_wrlock(&that->m_rwlock);
return result;
}
@@ -1006,7 +1036,7 @@ static inline int inline_mysql_rwlock_tryrdlock(
PSI_RWLOCK_TRYREADLOCK, src_file, src_line);
/* Instrumented code */
- result= rw_tryrdlock(&that->m_rwlock);
+ result= native_rw_tryrdlock(&that->m_rwlock);
/* Instrumentation end */
if (locker != NULL)
@@ -1017,7 +1047,7 @@ static inline int inline_mysql_rwlock_tryrdlock(
#endif
/* Non instrumented code */
- result= rw_tryrdlock(&that->m_rwlock);
+ result= native_rw_tryrdlock(&that->m_rwlock);
return result;
}
@@ -1041,7 +1071,7 @@ static inline int inline_mysql_rwlock_trywrlock(
PSI_RWLOCK_TRYWRITELOCK, src_file, src_line);
/* Instrumented code */
- result= rw_trywrlock(&that->m_rwlock);
+ result= native_rw_trywrlock(&that->m_rwlock);
/* Instrumentation end */
if (locker != NULL)
@@ -1052,7 +1082,7 @@ static inline int inline_mysql_rwlock_trywrlock(
#endif
/* Non instrumented code */
- result= rw_trywrlock(&that->m_rwlock);
+ result= native_rw_trywrlock(&that->m_rwlock);
return result;
}
@@ -1065,7 +1095,7 @@ static inline int inline_mysql_rwlock_unlock(
if (that->m_psi != NULL)
PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi);
#endif
- result= rw_unlock(&that->m_rwlock);
+ result= native_rw_unlock(&that->m_rwlock);
return result;
}
@@ -1104,15 +1134,14 @@ static inline int inline_mysql_cond_init(
#ifdef HAVE_PSI_COND_INTERFACE
PSI_cond_key key,
#endif
- mysql_cond_t *that,
- const pthread_condattr_t *attr)
+ mysql_cond_t *that)
{
#ifdef HAVE_PSI_COND_INTERFACE
that->m_psi= PSI_COND_CALL(init_cond)(key, &that->m_cond);
#else
that->m_psi= NULL;
#endif
- return pthread_cond_init(&that->m_cond, attr);
+ return native_cond_init(&that->m_cond);
}
static inline int inline_mysql_cond_destroy(
@@ -1125,13 +1154,13 @@ static inline int inline_mysql_cond_destroy(
that->m_psi= NULL;
}
#endif
- return pthread_cond_destroy(&that->m_cond);
+ return native_cond_destroy(&that->m_cond);
}
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
)
@@ -1148,7 +1177,11 @@ static inline int inline_mysql_cond_wait(
PSI_COND_WAIT, src_file, src_line);
/* Instrumented code */
- result= my_cond_wait(&that->m_cond, &mutex->m_mutex);
+ result= my_cond_wait(&that->m_cond, &mutex->m_mutex
+#ifdef SAFE_MUTEX
+ , src_file, src_line
+#endif
+ );
/* Instrumentation end */
if (locker != NULL)
@@ -1159,7 +1192,11 @@ static inline int inline_mysql_cond_wait(
#endif
/* Non instrumented code */
- result= my_cond_wait(&that->m_cond, &mutex->m_mutex);
+ result= my_cond_wait(&that->m_cond, &mutex->m_mutex
+#ifdef SAFE_MUTEX
+ , src_file, src_line
+#endif
+ );
return result;
}
@@ -1168,7 +1205,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
)
@@ -1185,7 +1222,11 @@ static inline int inline_mysql_cond_timedwait(
PSI_COND_TIMEDWAIT, src_file, src_line);
/* Instrumented code */
- result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
+ result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime
+#ifdef SAFE_MUTEX
+ , src_file, src_line
+#endif
+ );
/* Instrumentation end */
if (locker != NULL)
@@ -1196,7 +1237,11 @@ static inline int inline_mysql_cond_timedwait(
#endif
/* Non instrumented code */
- result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
+ result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime
+#ifdef SAFE_MUTEX
+ , src_file, src_line
+#endif
+ );
return result;
}
@@ -1209,7 +1254,7 @@ static inline int inline_mysql_cond_signal(
if (that->m_psi != NULL)
PSI_COND_CALL(signal_cond)(that->m_psi);
#endif
- result= pthread_cond_signal(&that->m_cond);
+ result= native_cond_signal(&that->m_cond);
return result;
}
@@ -1221,7 +1266,7 @@ static inline int inline_mysql_cond_broadcast(
if (that->m_psi != NULL)
PSI_COND_CALL(broadcast_cond)(that->m_psi);
#endif
- result= pthread_cond_broadcast(&that->m_cond);
+ result= native_cond_broadcast(&that->m_cond);
return result;
}
@@ -1245,19 +1290,29 @@ static inline void inline_mysql_thread_register(
#ifdef HAVE_PSI_THREAD_INTERFACE
static inline int inline_mysql_thread_create(
PSI_thread_key key,
- pthread_t *thread, const pthread_attr_t *attr,
- void *(*start_routine)(void*), void *arg)
+ my_thread_handle *thread, const my_thread_attr_t *attr,
+ my_start_routine start_routine, void *arg)
{
int result;
result= PSI_THREAD_CALL(spawn_thread)(key, thread, attr, start_routine, arg);
return result;
}
-static inline void inline_mysql_thread_set_psi_id(ulong id)
+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..c80abf46228
--- /dev/null
+++ b/include/mysql/psi/mysql_transaction.h
@@ -0,0 +1,213 @@
+/* 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 as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#ifndef MYSQL_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) \
+ do {} while (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) \
+ NULL
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_COMMIT_TRANSACTION(LOCKER) \
+ inline_mysql_commit_transaction(LOCKER)
+#else
+ #define MYSQL_COMMIT_TRANSACTION(LOCKER) \
+ NULL
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+static inline struct PSI_transaction_locker *
+inline_mysql_start_transaction(PSI_transaction_locker_state *state,
+ const void *xid,
+ const 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 7fcff89c8b6..9fb62868e31 100644
--- a/include/mysql/psi/psi.h
+++ b/include/mysql/psi/psi.h
@@ -17,16 +17,7 @@
#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
+#define DISABLE_ALL_PSI
#endif /* EMBEDDED_LIBRARY */
#ifndef MY_GLOBAL_INCLUDED
@@ -40,12 +31,52 @@
#error "You must include my_global.h in the code for the build to be correct."
#endif
+#include "psi_base.h"
+#include "psi_memory.h"
+
+/*
+ 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.
@@ -112,6 +143,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.
*/
@@ -126,6 +164,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.
*/
@@ -139,6 +184,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
{
@@ -161,14 +290,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
@@ -176,8 +375,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
@@ -254,6 +458,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.
*/
@@ -265,6 +489,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
@@ -275,6 +509,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
@@ -285,6 +529,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.
@@ -346,6 +600,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
{
@@ -356,7 +617,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. */
@@ -366,7 +632,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;
@@ -426,20 +706,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
{
@@ -532,7 +798,10 @@ typedef unsigned int PSI_thread_key;
To instrument a file, a file key must be obtained using @c register_file.
Using a zero key always disable the instrumentation.
*/
+#ifndef PSI_FILE_KEY_DEFINED
typedef unsigned int PSI_file_key;
+#define PSI_FILE_KEY_DEFINED
+#endif
/**
Instrumented stage key.
@@ -555,44 +824,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
/**
@@ -622,6 +853,7 @@ struct PSI_mutex_info_v1
*/
int m_flags;
};
+typedef struct PSI_mutex_info_v1 PSI_mutex_info_v1;
/**
Rwlock information.
@@ -644,6 +876,7 @@ struct PSI_rwlock_info_v1
*/
int m_flags;
};
+typedef struct PSI_rwlock_info_v1 PSI_rwlock_info_v1;
/**
Condition information.
@@ -666,6 +899,7 @@ struct PSI_cond_info_v1
*/
int m_flags;
};
+typedef struct PSI_cond_info_v1 PSI_cond_info_v1;
/**
Thread instrument information.
@@ -688,6 +922,7 @@ struct PSI_thread_info_v1
*/
int m_flags;
};
+typedef struct PSI_thread_info_v1 PSI_thread_info_v1;
/**
File instrument information.
@@ -710,6 +945,7 @@ struct PSI_file_info_v1
*/
int m_flags;
};
+typedef struct PSI_file_info_v1 PSI_file_info_v1;
/**
Stage instrument information.
@@ -725,6 +961,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.
@@ -740,6 +977,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.
@@ -762,6 +1000,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.
@@ -785,6 +1024,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.
@@ -812,6 +1052,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.
@@ -840,6 +1081,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.
@@ -869,6 +1111,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.
@@ -904,28 +1147,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. */
@@ -934,13 +1172,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)
@@ -959,6 +1192,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. */
@@ -1011,7 +1246,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.
@@ -1045,6 +1323,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. */
@@ -1241,7 +1535,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.
@@ -1264,8 +1559,8 @@ typedef void (*create_file_v1_t)(PSI_file_key key, const char *name,
@param arg the thread start routine argument
*/
typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
- pthread_t *thread,
- const pthread_attr_t *attr,
+ my_thread_handle *thread,
+ const my_thread_attr_t *attr,
void *(*start_routine)(void*), void *arg);
/**
@@ -1278,6 +1573,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
@@ -1286,6 +1589,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
@@ -1308,8 +1618,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.
@@ -1325,6 +1635,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
*/
@@ -1424,9 +1741,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);
@@ -1518,7 +1846,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,
@@ -1527,8 +1855,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.
@@ -1537,7 +1868,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,
@@ -1549,6 +1880,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
@@ -1577,6 +1910,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
@@ -1627,10 +1969,13 @@ typedef void (*end_file_close_wait_v1_t)
@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);
@@ -1643,7 +1988,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.
@@ -1817,6 +2162,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,
+ const 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
@@ -1872,23 +2313,111 @@ 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,
+ const char *name, size_t 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);
+
+/**
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,
@@ -1932,6 +2461,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. */
@@ -1954,16 +2484,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. */
@@ -2025,6 +2561,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. */
@@ -2035,6 +2574,8 @@ struct PSI_v1
end_file_close_wait_v1_t end_file_close_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. */
@@ -2079,6 +2620,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. */
@@ -2089,12 +2650,49 @@ 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 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) */
@@ -2175,6 +2773,13 @@ struct PSI_statement_info_v2
};
/** Placeholder */
+struct PSI_transaction_info_v2
+{
+ /** Placeholder */
+ int placeholder;
+};
+
+/** Placeholder */
struct PSI_idle_locker_state_v2
{
/** Placeholder */
@@ -2210,14 +2815,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;
@@ -2230,6 +2835,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 */
@@ -2275,15 +2885,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
@@ -2295,15 +2908,18 @@ 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 */
@@ -2355,50 +2971,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 7444cb0b276..cb6e225246d 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 as published by
@@ -19,6 +19,6 @@
This file is only used to automate detection of changes between versions.
Do not include this file, include mysql/psi/psi.h instead.
*/
-#define _global_h
+#define MY_GLOBAL_INCLUDED
#include "mysql/psi/psi.h"
diff --git a/include/mysql/psi/psi_abi_v0.h.pp b/include/mysql/psi/psi_abi_v0.h.pp
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 2e2d7a79fe1..f96c944df8e 100644
--- a/include/mysql/psi/psi_abi_v1.h.pp
+++ b/include/mysql/psi/psi_abi_v1.h.pp
@@ -1,7 +1,41 @@
#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;
+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;
+ struct opaque_THD
+ {
+ int dummy;
+ };
+ typedef struct opaque_THD THD;
struct PSI_mutex;
typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
@@ -18,14 +52,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);
@@ -41,6 +112,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,
@@ -52,7 +125,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
@@ -82,14 +161,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,
@@ -135,48 +206,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;
@@ -185,6 +264,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;
@@ -195,6 +275,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;
@@ -205,6 +286,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;
@@ -216,6 +298,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;
@@ -229,21 +312,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;
@@ -270,7 +353,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;
@@ -284,6 +386,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)
@@ -325,23 +437,28 @@ 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,
- pthread_t *thread,
- const pthread_attr_t *attr,
+ my_thread_handle *thread,
+ const my_thread_attr_t *attr,
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);
@@ -400,25 +517,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);
@@ -428,12 +550,13 @@ 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 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);
@@ -478,6 +601,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,
+ const 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,
@@ -493,10 +644,50 @@ 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,
+ const char *name, size_t 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 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
@@ -528,11 +719,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;
@@ -564,11 +758,14 @@ 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;
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;
@@ -591,14 +788,44 @@ 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;
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;
@@ -608,14 +835,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;
+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 08bca609b41..bd7dd487902 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 as published by
@@ -21,6 +21,6 @@
*/
#define USE_PSI_2
#define HAVE_PSI_INTERFACE
-#define _global_h
+#define MY_GLOBAL_INCLUDED
#include "mysql/psi/psi.h"
diff --git a/include/mysql/psi/psi_abi_v2.h.pp b/include/mysql/psi/psi_abi_v2.h.pp
index c3dba0a9b76..d67f39bbb0e 100644
--- a/include/mysql/psi/psi_abi_v2.h.pp
+++ b/include/mysql/psi/psi_abi_v2.h.pp
@@ -1,7 +1,28 @@
#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;
+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;
+ struct opaque_THD
+ {
+ int dummy;
+ };
+ typedef struct opaque_THD THD;
struct PSI_mutex;
typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
@@ -18,14 +39,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);
@@ -41,6 +99,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,
@@ -52,7 +112,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
@@ -82,14 +148,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,
@@ -161,6 +219,10 @@ struct PSI_statement_info_v2
{
int placeholder;
};
+struct PSI_transaction_info_v2
+{
+ int placeholder;
+};
struct PSI_idle_locker_state_v2
{
int placeholder;
@@ -181,11 +243,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;
};
@@ -193,6 +255,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;
@@ -201,14 +267,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;
+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
new file mode 100644
index 00000000000..94cb5c9f51c
--- /dev/null
+++ b/include/mysql/psi/psi_base.h
@@ -0,0 +1,155 @@
+/* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef MYSQL_PSI_BASE_H
+#define MYSQL_PSI_BASE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ @file mysql/psi/psi_base.h
+ Performance schema instrumentation interface.
+
+ @defgroup Instrumentation_interface Instrumentation Interface
+ @ingroup Performance_schema
+ @{
+*/
+
+#define PSI_INSTRUMENT_ME 0
+
+#define PSI_NOT_INSTRUMENTED 0
+
+/**
+ Global flag.
+ This flag indicate that an instrumentation point is a global variable,
+ or a singleton.
+*/
+#define PSI_FLAG_GLOBAL (1 << 0)
+
+/**
+ Mutable 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)
+
+#define PSI_FLAG_THREAD (1 << 2)
+
+/**
+ Stage progress flag.
+ This flag apply to the stage instruments only.
+ It indicates the instrumentation provides progress data.
+*/
+#define PSI_FLAG_STAGE_PROGRESS (1 << 3)
+
+/**
+ Shared Exclusive flag.
+ Indicates that rwlock support the shared exclusive state.
+*/
+#define PSI_RWLOCK_FLAG_SX (1 << 4)
+
+/**
+ Transferable flag.
+ This flag indicate that an instrumented object can
+ be created by a thread and destroyed by another thread.
+*/
+#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
+
+/**
+ @def PSI_VERSION_1
+ Performance Schema Interface number for version 1.
+ This version is supported.
+*/
+#define PSI_VERSION_1 1
+
+/**
+ @def PSI_VERSION_2
+ Performance Schema Interface number for version 2.
+ This version is not implemented, it's a placeholder.
+*/
+#define PSI_VERSION_2 2
+
+/**
+ @def PSI_CURRENT_VERSION
+ Performance Schema Interface number for the most recent version.
+ The most current version is @c PSI_VERSION_1
+*/
+#define PSI_CURRENT_VERSION 1
+
+/**
+ @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.
+*/
+
+#ifndef USE_PSI_2
+#ifndef USE_PSI_1
+#define USE_PSI_1
+#endif
+#endif
+
+#ifdef USE_PSI_1
+#define HAVE_PSI_1
+#endif
+
+#ifdef USE_PSI_2
+#define HAVE_PSI_2
+#endif
+
+/*
+ Allow to override PSI_XXX_CALL at compile time
+ with more efficient implementations, if available.
+ If nothing better is available,
+ make a dynamic call using the PSI_server function pointer.
+*/
+
+#define PSI_DYNAMIC_CALL(M) PSI_server->M
+
+#endif /* HAVE_PSI_INTERFACE */
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MYSQL_PSI_BASE_H */
+
diff --git a/include/mysql/psi/psi_memory.h b/include/mysql/psi/psi_memory.h
new file mode 100644
index 00000000000..725b3ed77d0
--- /dev/null
+++ b/include/mysql/psi/psi_memory.h
@@ -0,0 +1,155 @@
+/* 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 MYSQL_PSI_MEMORY_H
+#define MYSQL_PSI_MEMORY_H
+
+#include "psi_base.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ @file mysql/psi/psi_memory.h
+ Performance schema instrumentation interface.
+
+ @defgroup Instrumentation_interface Instrumentation Interface
+ @ingroup Performance_schema
+ @{
+*/
+
+#ifdef HAVE_PSI_INTERFACE
+#ifndef DISABLE_ALL_PSI
+#ifndef DISABLE_PSI_MEMORY
+#define HAVE_PSI_MEMORY_INTERFACE
+#endif /* DISABLE_PSI_MEMORY */
+#endif /* DISABLE_ALL_PSI */
+#endif /* HAVE_PSI_INTERFACE */
+
+struct PSI_thread;
+
+/**
+ Instrumented memory key.
+ To instrument memory, a memory key must be obtained using @c register_memory.
+ Using a zero key always disable the instrumentation.
+*/
+typedef unsigned int PSI_memory_key;
+
+#ifdef HAVE_PSI_1
+
+/**
+ @defgroup Group_PSI_v1 Application Binary Interface, version 1
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ Memory instrument information.
+ @since PSI_VERSION_1
+ This structure is used to register instrumented memory.
+*/
+struct PSI_memory_info_v1
+{
+ /** Pointer to the key assigned to the registered memory. */
+ PSI_memory_key *m_key;
+ /** The name of the memory instrument to register. */
+ const char *m_name;
+ /**
+ The flags of the socket instrument to register.
+ @sa PSI_FLAG_GLOBAL
+ */
+ int m_flags;
+};
+typedef struct PSI_memory_info_v1 PSI_memory_info_v1;
+
+/**
+ Memory registration API.
+ @param category a category name (typically a plugin name)
+ @param info an array of memory info to register
+ @param count the size of the info array
+*/
+typedef void (*register_memory_v1_t)
+ (const char *category, struct PSI_memory_info_v1 *info, int count);
+
+/**
+ Instrument memory allocation.
+ @param key the memory instrument key
+ @param size the size of memory allocated
+ @param[out] owner the memory owner
+ @return the effective memory instrument key
+*/
+typedef PSI_memory_key (*memory_alloc_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread ** owner);
+
+/**
+ Instrument memory re allocation.
+ @param key the memory instrument key
+ @param old_size the size of memory previously allocated
+ @param new_size the size of memory re allocated
+ @param[in, out] owner the memory owner
+ @return the effective memory instrument key
+*/
+typedef PSI_memory_key (*memory_realloc_v1_t)
+ (PSI_memory_key key, size_t old_size, size_t new_size, struct PSI_thread ** owner);
+
+/**
+ Instrument memory claim.
+ @param key the memory instrument key
+ @param size the size of memory allocated
+ @param[in, out] owner the memory owner
+ @return the effective memory instrument key
+*/
+typedef PSI_memory_key (*memory_claim_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread ** owner);
+
+/**
+ Instrument memory free.
+ @param key the memory instrument key
+ @param size the size of memory allocated
+ @param owner the memory owner
+*/
+typedef void (*memory_free_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread * owner);
+
+/** @} (end of group Group_PSI_v1) */
+
+#endif /* HAVE_PSI_1 */
+
+#ifdef HAVE_PSI_2
+struct PSI_memory_info_v2
+{
+ int placeholder;
+};
+
+#endif /* HAVE_PSI_2 */
+
+#ifdef USE_PSI_1
+typedef struct PSI_memory_info_v1 PSI_memory_info;
+#endif
+
+#ifdef USE_PSI_2
+typedef struct PSI_memory_info_v2 PSI_memory_info;
+#endif
+
+/** @} (end of group Instrumentation_interface) */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* MYSQL_PSI_MEMORY_H */
+