1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00
This commit is contained in:
Sergei Golubchik
2016-07-28 15:52:12 +02:00
parent 51ed64a520
commit 15f60c1a73
976 changed files with 148320 additions and 35656 deletions

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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) \
@@ -471,6 +480,19 @@ inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
inline_mysql_socket_setsockopt(FD, LV, ON, OP, OL)
#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.
@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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
@@ -49,72 +53,6 @@
#define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE)
#endif
/**
@def MYSQL_TABLE_IO_WAIT
Instrumentation helper for table io_waits.
This instrumentation marks the start of a wait event.
@param PSI the instrumented table
@param OP the table operation to be performed
@param INDEX the table index used if any, or MAY_KEY.
@param FLAGS per table operation flags.
@sa MYSQL_END_TABLE_WAIT.
*/
#ifdef HAVE_PSI_TABLE_INTERFACE
#define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
{ \
if (PSI != NULL) \
{ \
PSI_table_locker *locker; \
PSI_table_locker_state state; \
locker= PSI_TABLE_CALL(start_table_io_wait) \
(& state, PSI, OP, INDEX, __FILE__, __LINE__); \
PAYLOAD \
if (locker != NULL) \
PSI_TABLE_CALL(end_table_io_wait)(locker); \
} \
else \
{ \
PAYLOAD \
} \
}
#else
#define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
PAYLOAD
#endif
/**
@def MYSQL_TABLE_LOCK_WAIT
Instrumentation helper for table io_waits.
This instrumentation marks the start of a wait event.
@param PSI the instrumented table
@param OP the table operation to be performed
@param INDEX the table index used if any, or MAY_KEY.
@param FLAGS per table operation flags.
@sa MYSQL_END_TABLE_WAIT.
*/
#ifdef HAVE_PSI_TABLE_INTERFACE
#define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
{ \
if (PSI != NULL) \
{ \
PSI_table_locker *locker; \
PSI_table_locker_state state; \
locker= PSI_TABLE_CALL(start_table_lock_wait) \
(& state, PSI, OP, FLAGS, __FILE__, __LINE__); \
PAYLOAD \
if (locker != NULL) \
PSI_TABLE_CALL(end_table_lock_wait)(locker); \
} \
else \
{ \
PAYLOAD \
} \
}
#else
#define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
PAYLOAD
#endif
/**
@def MYSQL_START_TABLE_LOCK_WAIT
Instrumentation helper for table lock waits.
@@ -150,6 +88,14 @@
do {} while (0)
#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.
@@ -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) */

View File

@@ -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 */

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -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"

View File

@@ -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);

View File

@@ -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

View File

@@ -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"

View File

@@ -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,18 +243,22 @@ struct PSI_file_locker_state_v2
{
int placeholder;
};
struct PSI_table_locker_state_v2
{
int placeholder;
};
struct PSI_statement_locker_state_v2
{
int placeholder;
};
struct PSI_transaction_locker_state_v2
{
int placeholder;
};
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

View File

@@ -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 */

View File

@@ -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 */