1 /* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software Foundation,
14 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
16 #ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
17 #define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
19 #ifdef EMBEDDED_LIBRARY
20 #define DISABLE_ALL_PSI
21 #endif /* EMBEDDED_LIBRARY */
23 #ifndef MY_GLOBAL_INCLUDED
25 Make sure a .c or .cc file contains an include to my_global.h first.
26 When this include is missing, all the #ifdef HAVE_XXX have no effect,
27 and the resulting binary won't build, or won't link,
28 or will crash at runtime
29 since various structures will have different binary definitions.
31 #error "You must include my_global.h in the code for the build to be correct."
35 #include "psi_memory.h"
39 The following pattern:
40 typedef struct XYZ XYZ;
41 is not needed in C++, but required for C.
48 typedef struct MDL_key MDL_key;
50 /** @sa enum_mdl_type. */
51 typedef int opaque_mdl_type;
53 /** @sa enum_mdl_duration. */
54 typedef int opaque_mdl_duration;
56 /** @sa MDL_wait::enum_wait_status. */
57 typedef int opaque_mdl_status;
59 /** @sa enum_vio_type. */
60 typedef int opaque_vio_type;
64 struct sql_digest_storage;
70 Phony declaration when compiling C code.
71 This is ok, because the C code will never have a THD anyway.
77 typedef struct opaque_THD THD;
82 Performance schema instrumentation interface.
84 @defgroup Instrumentation_interface Instrumentation Interface
85 @ingroup Performance_schema
90 Interface for an instrumented mutex.
91 This is an opaque structure.
94 typedef struct PSI_mutex PSI_mutex;
97 Interface for an instrumented rwlock.
98 This is an opaque structure.
101 typedef struct PSI_rwlock PSI_rwlock;
104 Interface for an instrumented condition.
105 This is an opaque structure.
108 typedef struct PSI_cond PSI_cond;
111 Interface for an instrumented table share.
112 This is an opaque structure.
114 struct PSI_table_share;
115 typedef struct PSI_table_share PSI_table_share;
118 Interface for an instrumented table handle.
119 This is an opaque structure.
122 typedef struct PSI_table PSI_table;
125 Interface for an instrumented thread.
126 This is an opaque structure.
129 typedef struct PSI_thread PSI_thread;
132 Interface for an instrumented file handle.
133 This is an opaque structure.
136 typedef struct PSI_file PSI_file;
139 Interface for an instrumented socket descriptor.
140 This is an opaque structure.
143 typedef struct PSI_socket PSI_socket;
146 Interface for an instrumented prepared statement.
147 This is an opaque structure.
149 struct PSI_prepared_stmt;
150 typedef struct PSI_prepared_stmt PSI_prepared_stmt;
153 Interface for an instrumented table operation.
154 This is an opaque structure.
156 struct PSI_table_locker;
157 typedef struct PSI_table_locker PSI_table_locker;
160 Interface for an instrumented statement.
161 This is an opaque structure.
163 struct PSI_statement_locker;
164 typedef struct PSI_statement_locker PSI_statement_locker;
167 Interface for an instrumented transaction.
168 This is an opaque structure.
170 struct PSI_transaction_locker;
171 typedef struct PSI_transaction_locker PSI_transaction_locker;
174 Interface for an instrumented idle operation.
175 This is an opaque structure.
177 struct PSI_idle_locker;
178 typedef struct PSI_idle_locker PSI_idle_locker;
181 Interface for an instrumented statement digest operation.
182 This is an opaque structure.
184 struct PSI_digest_locker;
185 typedef struct PSI_digest_locker PSI_digest_locker;
188 Interface for an instrumented stored procedure share.
189 This is an opaque structure.
192 typedef struct PSI_sp_share PSI_sp_share;
195 Interface for an instrumented stored program.
196 This is an opaque structure.
198 struct PSI_sp_locker;
199 typedef struct PSI_sp_locker PSI_sp_locker;
202 Interface for an instrumented metadata lock.
203 This is an opaque structure.
205 struct PSI_metadata_lock;
206 typedef struct PSI_metadata_lock PSI_metadata_lock;
209 Interface for an instrumented stage progress.
210 This is a public structure, for efficiency.
212 struct PSI_stage_progress
214 ulonglong m_work_completed;
215 ulonglong m_work_estimated;
217 typedef struct PSI_stage_progress PSI_stage_progress;
219 /** IO operation performed on an instrumented table. */
220 enum PSI_table_io_operation
223 PSI_TABLE_FETCH_ROW= 0,
225 PSI_TABLE_WRITE_ROW= 1,
227 PSI_TABLE_UPDATE_ROW= 2,
229 PSI_TABLE_DELETE_ROW= 3
231 typedef enum PSI_table_io_operation PSI_table_io_operation;
234 State data storage for @c start_table_io_wait_v1_t,
235 @c start_table_lock_wait_v1_t.
236 This structure provide temporary storage to a table locker.
237 The content of this structure is considered opaque,
238 the fields are only hints of what an implementation
239 of the psi interface can use.
240 This memory is provided by the instrumented code for performance reasons.
241 @sa start_table_io_wait_v1_t
242 @sa start_table_lock_wait_v1_t
244 struct PSI_table_locker_state
246 /** Internal state. */
248 /** Current io operation. */
249 enum PSI_table_io_operation m_io_operation;
250 /** Current table handle. */
251 struct PSI_table *m_table;
252 /** Current table share. */
253 struct PSI_table_share *m_table_share;
254 /** Current thread. */
255 struct PSI_thread *m_thread;
257 ulonglong m_timer_start;
258 /** Timer function. */
259 ulonglong (*m_timer)(void);
260 /** Internal data. */
263 Implementation specific.
264 For table io, the table io index.
265 For table lock, the lock type.
269 typedef struct PSI_table_locker_state PSI_table_locker_state;
271 /** Entry point for the performance schema interface. */
275 ABI interface finder.
276 Calling this method with an interface version number returns either
277 an instance of the ABI for this version, or NULL.
278 @param version the interface version number to find
279 @return a versioned interface (PSI_v1, PSI_v2 or PSI)
284 @sa PSI_CURRENT_VERSION
287 void* (*get_interface)(int version);
289 typedef struct PSI_bootstrap PSI_bootstrap;
291 #ifdef HAVE_PSI_INTERFACE
293 #ifdef DISABLE_ALL_PSI
295 #ifndef DISABLE_PSI_THREAD
296 #define DISABLE_PSI_THREAD
299 #ifndef DISABLE_PSI_MUTEX
300 #define DISABLE_PSI_MUTEX
303 #ifndef DISABLE_PSI_RWLOCK
304 #define DISABLE_PSI_RWLOCK
307 #ifndef DISABLE_PSI_COND
308 #define DISABLE_PSI_COND
311 #ifndef DISABLE_PSI_FILE
312 #define DISABLE_PSI_FILE
315 #ifndef DISABLE_PSI_TABLE
316 #define DISABLE_PSI_TABLE
319 #ifndef DISABLE_PSI_SOCKET
320 #define DISABLE_PSI_SOCKET
323 #ifndef DISABLE_PSI_STAGE
324 #define DISABLE_PSI_STAGE
327 #ifndef DISABLE_PSI_STATEMENT
328 #define DISABLE_PSI_STATEMENT
331 #ifndef DISABLE_PSI_SP
332 #define DISABLE_PSI_SP
335 #ifndef DISABLE_PSI_IDLE
336 #define DISABLE_PSI_IDLE
339 #ifndef DISABLE_PSI_STATEMENT_DIGEST
340 #define DISABLE_PSI_STATEMENT_DIGEST
343 #ifndef DISABLE_PSI_METADATA
344 #define DISABLE_PSI_METADATA
347 #ifndef DISABLE_PSI_MEMORY
348 #define DISABLE_PSI_MEMORY
351 #ifndef DISABLE_PSI_TRANSACTION
352 #define DISABLE_PSI_TRANSACTION
355 #ifndef DISABLE_PSI_SP
356 #define DISABLE_PSI_SP
359 #ifndef DISABLE_PSI_PS
360 #define DISABLE_PSI_PS
366 @def DISABLE_PSI_MUTEX
367 Compiling option to disable the mutex instrumentation.
368 This option is mostly intended to be used during development,
369 when doing special builds with only a subset of the performance schema instrumentation,
370 for code analysis / profiling / performance tuning of a specific instrumentation alone.
371 @sa DISABLE_PSI_RWLOCK
374 @sa DISABLE_PSI_THREAD
375 @sa DISABLE_PSI_TABLE
376 @sa DISABLE_PSI_STAGE
377 @sa DISABLE_PSI_STATEMENT
379 @sa DISABLE_PSI_STATEMENT_DIGEST
380 @sa DISABLE_PSI_SOCKET
381 @sa DISABLE_PSI_MEMORY
383 @sa DISABLE_PSI_METADATA
384 @sa DISABLE PSI_TRANSACTION
387 #ifndef DISABLE_PSI_MUTEX
388 #define HAVE_PSI_MUTEX_INTERFACE
392 @def DISABLE_PSI_RWLOCK
393 Compiling option to disable the rwlock instrumentation.
394 @sa DISABLE_PSI_MUTEX
397 #ifndef DISABLE_PSI_RWLOCK
398 #define HAVE_PSI_RWLOCK_INTERFACE
402 @def DISABLE_PSI_COND
403 Compiling option to disable the cond instrumentation.
404 @sa DISABLE_PSI_MUTEX
407 #ifndef DISABLE_PSI_COND
408 #define HAVE_PSI_COND_INTERFACE
412 @def DISABLE_PSI_FILE
413 Compiling option to disable the file instrumentation.
414 @sa DISABLE_PSI_MUTEX
417 #ifndef DISABLE_PSI_FILE
418 #define HAVE_PSI_FILE_INTERFACE
422 @def DISABLE_PSI_THREAD
423 Compiling option to disable the thread instrumentation.
424 @sa DISABLE_PSI_MUTEX
426 #ifndef DISABLE_PSI_THREAD
427 #define HAVE_PSI_THREAD_INTERFACE
431 @def DISABLE_PSI_TABLE
432 Compiling option to disable the table instrumentation.
433 @sa DISABLE_PSI_MUTEX
436 #ifndef DISABLE_PSI_TABLE
437 #define HAVE_PSI_TABLE_INTERFACE
441 @def DISABLE_PSI_STAGE
442 Compiling option to disable the stage instrumentation.
443 @sa DISABLE_PSI_MUTEX
446 #ifndef DISABLE_PSI_STAGE
447 #define HAVE_PSI_STAGE_INTERFACE
451 @def DISABLE_PSI_STATEMENT
452 Compiling option to disable the statement instrumentation.
453 @sa DISABLE_PSI_MUTEX
456 #ifndef DISABLE_PSI_STATEMENT
457 #define HAVE_PSI_STATEMENT_INTERFACE
462 Compiling option to disable the stored program instrumentation.
463 @sa DISABLE_PSI_MUTEX
465 #ifndef DISABLE_PSI_SP
466 #define HAVE_PSI_SP_INTERFACE
471 Compiling option to disable the prepared statement instrumentation.
472 @sa DISABLE_PSI_MUTEX
474 #ifndef DISABLE_PSI_STATEMENT
475 #ifndef DISABLE_PSI_PS
476 #define HAVE_PSI_PS_INTERFACE
481 @def DISABLE_PSI_STATEMENT_DIGEST
482 Compiling option to disable the statement digest instrumentation.
485 #ifndef DISABLE_PSI_STATEMENT
486 #ifndef DISABLE_PSI_STATEMENT_DIGEST
487 #define HAVE_PSI_STATEMENT_DIGEST_INTERFACE
492 @def DISABLE_PSI_TRANSACTION
493 Compiling option to disable the transaction instrumentation.
494 @sa DISABLE_PSI_MUTEX
497 #ifndef DISABLE_PSI_TRANSACTION
498 #define HAVE_PSI_TRANSACTION_INTERFACE
502 @def DISABLE_PSI_SOCKET
503 Compiling option to disable the statement instrumentation.
504 @sa DISABLE_PSI_MUTEX
507 #ifndef DISABLE_PSI_SOCKET
508 #define HAVE_PSI_SOCKET_INTERFACE
512 @def DISABLE_PSI_MEMORY
513 Compiling option to disable the memory instrumentation.
514 @sa DISABLE_PSI_MUTEX
517 #ifndef DISABLE_PSI_MEMORY
518 #define HAVE_PSI_MEMORY_INTERFACE
522 @def DISABLE_PSI_IDLE
523 Compiling option to disable the idle instrumentation.
524 @sa DISABLE_PSI_MUTEX
527 #ifndef DISABLE_PSI_IDLE
528 #define HAVE_PSI_IDLE_INTERFACE
532 @def DISABLE_PSI_METADATA
533 Compiling option to disable the metadata instrumentation.
534 @sa DISABLE_PSI_MUTEX
537 #ifndef DISABLE_PSI_METADATA
538 #define HAVE_PSI_METADATA_INTERFACE
543 Performance Schema Interface number for version 1.
544 This version is supported.
546 #define PSI_VERSION_1 1
550 Performance Schema Interface number for version 2.
551 This version is not implemented, it's a placeholder.
553 #define PSI_VERSION_2 2
556 @def PSI_CURRENT_VERSION
557 Performance Schema Interface number for the most recent version.
558 The most current version is @c PSI_VERSION_1
560 #define PSI_CURRENT_VERSION 1
569 Interface for an instrumented mutex operation.
570 This is an opaque structure.
572 struct PSI_mutex_locker;
573 typedef struct PSI_mutex_locker PSI_mutex_locker;
576 Interface for an instrumented rwlock operation.
577 This is an opaque structure.
579 struct PSI_rwlock_locker;
580 typedef struct PSI_rwlock_locker PSI_rwlock_locker;
583 Interface for an instrumented condition operation.
584 This is an opaque structure.
586 struct PSI_cond_locker;
587 typedef struct PSI_cond_locker PSI_cond_locker;
590 Interface for an instrumented file operation.
591 This is an opaque structure.
593 struct PSI_file_locker;
594 typedef struct PSI_file_locker PSI_file_locker;
597 Interface for an instrumented socket operation.
598 This is an opaque structure.
600 struct PSI_socket_locker;
601 typedef struct PSI_socket_locker PSI_socket_locker;
604 Interface for an instrumented MDL operation.
605 This is an opaque structure.
607 struct PSI_metadata_locker;
608 typedef struct PSI_metadata_locker PSI_metadata_locker;
610 /** Operation performed on an instrumented mutex. */
611 enum PSI_mutex_operation
618 typedef enum PSI_mutex_operation PSI_mutex_operation;
621 Operation performed on an instrumented rwlock.
622 For basic READ / WRITE lock,
623 operations are "READ" or "WRITE".
624 For SX-locks, operations are "SHARED", "SHARED-EXCLUSIVE" or "EXCLUSIVE".
626 enum PSI_rwlock_operation
629 PSI_RWLOCK_READLOCK= 0,
631 PSI_RWLOCK_WRITELOCK= 1,
632 /** Read lock attempt. */
633 PSI_RWLOCK_TRYREADLOCK= 2,
634 /** Write lock attempt. */
635 PSI_RWLOCK_TRYWRITELOCK= 3,
638 PSI_RWLOCK_SHAREDLOCK= 4,
639 /** Shared Exclusive lock. */
640 PSI_RWLOCK_SHAREDEXCLUSIVELOCK= 5,
641 /** Exclusive lock. */
642 PSI_RWLOCK_EXCLUSIVELOCK= 6,
643 /** Shared lock attempt. */
644 PSI_RWLOCK_TRYSHAREDLOCK= 7,
645 /** Shared Exclusive lock attempt. */
646 PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK= 8,
647 /** Exclusive lock attempt. */
648 PSI_RWLOCK_TRYEXCLUSIVELOCK= 9
651 typedef enum PSI_rwlock_operation PSI_rwlock_operation;
653 /** Operation performed on an instrumented condition. */
654 enum PSI_cond_operation
658 /** Wait, with timeout. */
659 PSI_COND_TIMEDWAIT= 1
661 typedef enum PSI_cond_operation PSI_cond_operation;
663 /** Operation performed on an instrumented file. */
664 enum PSI_file_operation
666 /** File creation, as in @c create(). */
668 /** Temporary file creation, as in @c create_temp_file(). */
669 PSI_FILE_CREATE_TMP= 1,
670 /** File open, as in @c open(). */
672 /** File open, as in @c fopen(). */
673 PSI_FILE_STREAM_OPEN= 3,
674 /** File close, as in @c close(). */
676 /** File close, as in @c fclose(). */
677 PSI_FILE_STREAM_CLOSE= 5,
679 Generic file read, such as @c fgets(), @c fgetc(), @c fread(), @c read(),
684 Generic file write, such as @c fputs(), @c fputc(), @c fprintf(),
685 @c vfprintf(), @c fwrite(), @c write(), @c pwrite().
688 /** Generic file seek, such as @c fseek() or @c seek(). */
690 /** Generic file tell, such as @c ftell() or @c tell(). */
692 /** File flush, as in @c fflush(). */
694 /** File stat, as in @c stat(). */
696 /** File stat, as in @c fstat(). */
698 /** File chsize, as in @c my_chsize(). */
700 /** File delete, such as @c my_delete() or @c my_delete_with_symlink(). */
702 /** File rename, such as @c my_rename() or @c my_rename_with_symlink(). */
704 /** File sync, as in @c fsync() or @c my_sync(). */
707 typedef enum PSI_file_operation PSI_file_operation;
709 /** Lock operation performed on an instrumented table. */
710 enum PSI_table_lock_operation
712 /** Table lock, in the server layer. */
714 /** Table lock, in the storage engine layer. */
715 PSI_TABLE_EXTERNAL_LOCK= 1
717 typedef enum PSI_table_lock_operation PSI_table_lock_operation;
719 /** State of an instrumented socket. */
720 enum PSI_socket_state
722 /** Idle, waiting for the next command. */
723 PSI_SOCKET_STATE_IDLE= 1,
724 /** Active, executing a command. */
725 PSI_SOCKET_STATE_ACTIVE= 2
727 typedef enum PSI_socket_state PSI_socket_state;
729 /** Operation performed on an instrumented socket. */
730 enum PSI_socket_operation
732 /** Socket creation, as in @c socket() or @c socketpair(). */
733 PSI_SOCKET_CREATE= 0,
734 /** Socket connection, as in @c connect(), @c listen() and @c accept(). */
735 PSI_SOCKET_CONNECT= 1,
736 /** Socket bind, as in @c bind(), @c getsockname() and @c getpeername(). */
738 /** Socket close, as in @c shutdown(). */
740 /** Socket send, @c send(). */
742 /** Socket receive, @c recv(). */
744 /** Socket send, @c sendto(). */
745 PSI_SOCKET_SENDTO= 6,
746 /** Socket receive, @c recvfrom). */
747 PSI_SOCKET_RECVFROM= 7,
748 /** Socket send, @c sendmsg(). */
749 PSI_SOCKET_SENDMSG= 8,
750 /** Socket receive, @c recvmsg(). */
751 PSI_SOCKET_RECVMSG= 9,
752 /** Socket seek, such as @c fseek() or @c seek(). */
754 /** Socket options, as in @c getsockopt() and @c setsockopt(). */
756 /** Socket status, as in @c sockatmark() and @c isfdtype(). */
758 /** Socket shutdown, as in @c shutdown(). */
759 PSI_SOCKET_SHUTDOWN= 13,
760 /** Socket select, as in @c select() and @c poll(). */
761 PSI_SOCKET_SELECT= 14
763 typedef enum PSI_socket_operation PSI_socket_operation;
766 Instrumented mutex key.
767 To instrument a mutex, a mutex key must be obtained using @c register_mutex.
768 Using a zero key always disable the instrumentation.
770 typedef unsigned int PSI_mutex_key;
773 Instrumented rwlock key.
774 To instrument a rwlock, a rwlock key must be obtained
775 using @c register_rwlock.
776 Using a zero key always disable the instrumentation.
778 typedef unsigned int PSI_rwlock_key;
781 Instrumented cond key.
782 To instrument a condition, a condition key must be obtained
783 using @c register_cond.
784 Using a zero key always disable the instrumentation.
786 typedef unsigned int PSI_cond_key;
789 Instrumented thread key.
790 To instrument a thread, a thread key must be obtained
791 using @c register_thread.
792 Using a zero key always disable the instrumentation.
794 typedef unsigned int PSI_thread_key;
797 Instrumented file key.
798 To instrument a file, a file key must be obtained using @c register_file.
799 Using a zero key always disable the instrumentation.
801 #ifndef PSI_FILE_KEY_DEFINED
802 typedef unsigned int PSI_file_key;
803 #define PSI_FILE_KEY_DEFINED
807 Instrumented stage key.
808 To instrument a stage, a stage key must be obtained using @c register_stage.
809 Using a zero key always disable the instrumentation.
811 typedef unsigned int PSI_stage_key;
814 Instrumented statement key.
815 To instrument a statement, a statement key must be obtained using @c register_statement.
816 Using a zero key always disable the instrumentation.
818 typedef unsigned int PSI_statement_key;
821 Instrumented socket key.
822 To instrument a socket, a socket key must be obtained using @c register_socket.
823 Using a zero key always disable the instrumentation.
825 typedef unsigned int PSI_socket_key;
830 @defgroup Group_PSI_v1 Application Binary Interface, version 1
831 @ingroup Instrumentation_interface
838 This structure is used to register an instrumented mutex.
840 struct PSI_mutex_info_v1
843 Pointer to the key assigned to the registered mutex.
845 PSI_mutex_key *m_key;
847 The name of the mutex to register.
851 The flags of the mutex to register.
856 typedef struct PSI_mutex_info_v1 PSI_mutex_info_v1;
861 This structure is used to register an instrumented rwlock.
863 struct PSI_rwlock_info_v1
866 Pointer to the key assigned to the registered rwlock.
868 PSI_rwlock_key *m_key;
870 The name of the rwlock to register.
874 The flags of the rwlock to register.
879 typedef struct PSI_rwlock_info_v1 PSI_rwlock_info_v1;
882 Condition information.
884 This structure is used to register an instrumented cond.
886 struct PSI_cond_info_v1
889 Pointer to the key assigned to the registered cond.
893 The name of the cond to register.
897 The flags of the cond to register.
902 typedef struct PSI_cond_info_v1 PSI_cond_info_v1;
905 Thread instrument information.
907 This structure is used to register an instrumented thread.
909 struct PSI_thread_info_v1
912 Pointer to the key assigned to the registered thread.
914 PSI_thread_key *m_key;
916 The name of the thread instrument to register.
920 The flags of the thread to register.
925 typedef struct PSI_thread_info_v1 PSI_thread_info_v1;
928 File instrument information.
930 This structure is used to register an instrumented file.
932 struct PSI_file_info_v1
935 Pointer to the key assigned to the registered file.
939 The name of the file instrument to register.
943 The flags of the file instrument to register.
948 typedef struct PSI_file_info_v1 PSI_file_info_v1;
951 Stage instrument information.
953 This structure is used to register an instrumented stage.
955 struct PSI_stage_info_v1
957 /** The registered stage key. */
959 /** The name of the stage instrument to register. */
961 /** The flags of the stage instrument to register. */
964 typedef struct PSI_stage_info_v1 PSI_stage_info_v1;
967 Statement instrument information.
969 This structure is used to register an instrumented statement.
971 struct PSI_statement_info_v1
973 /** The registered statement key. */
974 PSI_statement_key m_key;
975 /** The name of the statement instrument to register. */
977 /** The flags of the statement instrument to register. */
980 typedef struct PSI_statement_info_v1 PSI_statement_info_v1;
983 Socket instrument information.
985 This structure is used to register an instrumented socket.
987 struct PSI_socket_info_v1
990 Pointer to the key assigned to the registered socket.
992 PSI_socket_key *m_key;
994 The name of the socket instrument to register.
998 The flags of the socket instrument to register.
1003 typedef struct PSI_socket_info_v1 PSI_socket_info_v1;
1006 State data storage for @c start_idle_wait_v1_t.
1007 This structure provide temporary storage to an idle locker.
1008 The content of this structure is considered opaque,
1009 the fields are only hints of what an implementation
1010 of the psi interface can use.
1011 This memory is provided by the instrumented code for performance reasons.
1012 @sa start_idle_wait_v1_t.
1014 struct PSI_idle_locker_state_v1
1016 /** Internal state. */
1018 /** Current thread. */
1019 struct PSI_thread *m_thread;
1021 ulonglong m_timer_start;
1022 /** Timer function. */
1023 ulonglong (*m_timer)(void);
1024 /** Internal data. */
1027 typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state_v1;
1030 State data storage for @c start_mutex_wait_v1_t.
1031 This structure provide temporary storage to a mutex locker.
1032 The content of this structure is considered opaque,
1033 the fields are only hints of what an implementation
1034 of the psi interface can use.
1035 This memory is provided by the instrumented code for performance reasons.
1036 @sa start_mutex_wait_v1_t
1038 struct PSI_mutex_locker_state_v1
1040 /** Internal state. */
1042 /** Current operation. */
1043 enum PSI_mutex_operation m_operation;
1044 /** Current mutex. */
1045 struct PSI_mutex *m_mutex;
1046 /** Current thread. */
1047 struct PSI_thread *m_thread;
1049 ulonglong m_timer_start;
1050 /** Timer function. */
1051 ulonglong (*m_timer)(void);
1052 /** Internal data. */
1055 typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state_v1;
1058 State data storage for @c start_rwlock_rdwait_v1_t, @c start_rwlock_wrwait_v1_t.
1059 This structure provide temporary storage to a rwlock locker.
1060 The content of this structure is considered opaque,
1061 the fields are only hints of what an implementation
1062 of the psi interface can use.
1063 This memory is provided by the instrumented code for performance reasons.
1064 @sa start_rwlock_rdwait_v1_t
1065 @sa start_rwlock_wrwait_v1_t
1067 struct PSI_rwlock_locker_state_v1
1069 /** Internal state. */
1071 /** Current operation. */
1072 enum PSI_rwlock_operation m_operation;
1073 /** Current rwlock. */
1074 struct PSI_rwlock *m_rwlock;
1075 /** Current thread. */
1076 struct PSI_thread *m_thread;
1078 ulonglong m_timer_start;
1079 /** Timer function. */
1080 ulonglong (*m_timer)(void);
1081 /** Internal data. */
1084 typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state_v1;
1087 State data storage for @c start_cond_wait_v1_t.
1088 This structure provide temporary storage to a condition locker.
1089 The content of this structure is considered opaque,
1090 the fields are only hints of what an implementation
1091 of the psi interface can use.
1092 This memory is provided by the instrumented code for performance reasons.
1093 @sa start_cond_wait_v1_t
1095 struct PSI_cond_locker_state_v1
1097 /** Internal state. */
1099 /** Current operation. */
1100 enum PSI_cond_operation m_operation;
1101 /** Current condition. */
1102 struct PSI_cond *m_cond;
1103 /** Current mutex. */
1104 struct PSI_mutex *m_mutex;
1105 /** Current thread. */
1106 struct PSI_thread *m_thread;
1108 ulonglong m_timer_start;
1109 /** Timer function. */
1110 ulonglong (*m_timer)(void);
1111 /** Internal data. */
1114 typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state_v1;
1117 State data storage for @c get_thread_file_name_locker_v1_t.
1118 This structure provide temporary storage to a file locker.
1119 The content of this structure is considered opaque,
1120 the fields are only hints of what an implementation
1121 of the psi interface can use.
1122 This memory is provided by the instrumented code for performance reasons.
1123 @sa get_thread_file_name_locker_v1_t
1124 @sa get_thread_file_stream_locker_v1_t
1125 @sa get_thread_file_descriptor_locker_v1_t
1127 struct PSI_file_locker_state_v1
1129 /** Internal state. */
1131 /** Current operation. */
1132 enum PSI_file_operation m_operation;
1133 /** Current file. */
1134 struct PSI_file *m_file;
1135 /** Current file name. */
1137 /** Current file class. */
1139 /** Current thread. */
1140 struct PSI_thread *m_thread;
1141 /** Operation number of bytes. */
1142 size_t m_number_of_bytes;
1144 ulonglong m_timer_start;
1145 /** Timer function. */
1146 ulonglong (*m_timer)(void);
1147 /** Internal data. */
1150 typedef struct PSI_file_locker_state_v1 PSI_file_locker_state_v1;
1153 State data storage for @c start_metadata_wait_v1_t.
1154 This structure provide temporary storage to a metadata locker.
1155 The content of this structure is considered opaque,
1156 the fields are only hints of what an implementation
1157 of the psi interface can use.
1158 This memory is provided by the instrumented code for performance reasons.
1159 @sa start_metadata_wait_v1_t
1161 struct PSI_metadata_locker_state_v1
1163 /** Internal state. */
1165 /** Current metadata lock. */
1166 struct PSI_metadata_lock *m_metadata_lock;
1167 /** Current thread. */
1168 struct PSI_thread *m_thread;
1170 ulonglong m_timer_start;
1171 /** Timer function. */
1172 ulonglong (*m_timer)(void);
1173 /** Internal data. */
1176 typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state_v1;
1178 /* Duplicate of NAME_LEN, to avoid dependency on mysql_com.h */
1179 #define PSI_SCHEMA_NAME_LEN (64 * 3)
1182 State data storage for @c get_thread_statement_locker_v1_t,
1183 @c get_thread_statement_locker_v1_t.
1184 This structure provide temporary storage to a statement locker.
1185 The content of this structure is considered opaque,
1186 the fields are only hints of what an implementation
1187 of the psi interface can use.
1188 This memory is provided by the instrumented code for performance reasons.
1189 @sa get_thread_statement_locker_v1_t
1191 struct PSI_statement_locker_state_v1
1193 /** Discarded flag. */
1194 my_bool m_discarded;
1195 /** In prepare flag. */
1196 my_bool m_in_prepare;
1197 /** Metric, no index used flag. */
1198 uchar m_no_index_used;
1199 /** Metric, no good index used flag. */
1200 uchar m_no_good_index_used;
1201 /** Internal state. */
1203 /** Instrumentation class. */
1205 /** Current thread. */
1206 struct PSI_thread *m_thread;
1208 ulonglong m_timer_start;
1209 /** Timer function. */
1210 ulonglong (*m_timer)(void);
1211 /** Internal data. */
1214 ulonglong m_lock_time;
1216 ulonglong m_rows_sent;
1217 /** Rows examined. */
1218 ulonglong m_rows_examined;
1219 /** Metric, temporary tables created on disk. */
1220 ulong m_created_tmp_disk_tables;
1221 /** Metric, temporary tables created. */
1222 ulong m_created_tmp_tables;
1223 /** Metric, number of select full join. */
1224 ulong m_select_full_join;
1225 /** Metric, number of select full range join. */
1226 ulong m_select_full_range_join;
1227 /** Metric, number of select range. */
1228 ulong m_select_range;
1229 /** Metric, number of select range check. */
1230 ulong m_select_range_check;
1231 /** Metric, number of select scan. */
1232 ulong m_select_scan;
1233 /** Metric, number of sort merge passes. */
1234 ulong m_sort_merge_passes;
1235 /** Metric, number of sort merge. */
1237 /** Metric, number of sort rows. */
1239 /** Metric, number of sort scans. */
1241 /** Statement digest. */
1242 const struct sql_digest_storage *m_digest;
1243 /** Current schema name. */
1244 char m_schema_name[PSI_SCHEMA_NAME_LEN];
1245 /** Length in bytes of @c m_schema_name. */
1246 uint m_schema_name_length;
1247 /** Statement character set number. */
1249 PSI_sp_share *m_parent_sp_share;
1250 PSI_prepared_stmt *m_parent_prepared_stmt;
1252 typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state_v1;
1255 State data storage for @c get_thread_transaction_locker_v1_t,
1256 @c get_thread_transaction_locker_v1_t.
1257 This structure provide temporary storage to a transaction locker.
1258 The content of this structure is considered opaque,
1259 the fields are only hints of what an implementation
1260 of the psi interface can use.
1261 This memory is provided by the instrumented code for performance reasons.
1262 @sa get_thread_transaction_locker_v1_t
1264 struct PSI_transaction_locker_state_v1
1266 /** Internal state. */
1268 /** Instrumentation class. */
1270 /** Current thread. */
1271 struct PSI_thread *m_thread;
1273 ulonglong m_timer_start;
1274 /** Timer function. */
1275 ulonglong (*m_timer)(void);
1276 /** Internal data. */
1277 void *m_transaction;
1278 /** True if read-only transaction, false if read-write. */
1279 my_bool m_read_only;
1280 /** True if transaction is autocommit. */
1281 my_bool m_autocommit;
1282 /** Number of statements. */
1283 ulong m_statement_count;
1284 /** Total number of savepoints. */
1285 ulong m_savepoint_count;
1286 /** Number of rollback_to_savepoint. */
1287 ulong m_rollback_to_savepoint_count;
1288 /** Number of release_savepoint. */
1289 ulong m_release_savepoint_count;
1292 typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state_v1;
1295 State data storage for @c start_socket_wait_v1_t.
1296 This structure provide temporary storage to a socket locker.
1297 The content of this structure is considered opaque,
1298 the fields are only hints of what an implementation
1299 of the psi interface can use.
1300 This memory is provided by the instrumented code for performance reasons.
1301 @sa start_socket_wait_v1_t
1303 struct PSI_socket_locker_state_v1
1305 /** Internal state. */
1307 /** Current socket. */
1308 struct PSI_socket *m_socket;
1309 /** Current thread. */
1310 struct PSI_thread *m_thread;
1311 /** Operation number of bytes. */
1312 size_t m_number_of_bytes;
1314 ulonglong m_timer_start;
1315 /** Timer function. */
1316 ulonglong (*m_timer)(void);
1317 /** Current operation. */
1318 enum PSI_socket_operation m_operation;
1320 const char* m_src_file;
1321 /** Source line number. */
1323 /** Internal data. */
1326 typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state_v1;
1328 struct PSI_sp_locker_state_v1
1330 /** Internal state. */
1332 /** Current thread. */
1333 struct PSI_thread *m_thread;
1335 ulonglong m_timer_start;
1336 /** Timer function. */
1337 ulonglong (*m_timer)(void);
1338 /** Stored Procedure share. */
1339 PSI_sp_share* m_sp_share;
1341 typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state_v1;
1343 /* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */
1346 Mutex registration API.
1347 @param category a category name (typically a plugin name)
1348 @param info an array of mutex info to register
1349 @param count the size of the info array
1351 typedef void (*register_mutex_v1_t)
1352 (const char *category, struct PSI_mutex_info_v1 *info, int count);
1355 Rwlock registration API.
1356 @param category a category name (typically a plugin name)
1357 @param info an array of rwlock info to register
1358 @param count the size of the info array
1360 typedef void (*register_rwlock_v1_t)
1361 (const char *category, struct PSI_rwlock_info_v1 *info, int count);
1364 Cond registration API.
1365 @param category a category name (typically a plugin name)
1366 @param info an array of cond info to register
1367 @param count the size of the info array
1369 typedef void (*register_cond_v1_t)
1370 (const char *category, struct PSI_cond_info_v1 *info, int count);
1373 Thread registration API.
1374 @param category a category name (typically a plugin name)
1375 @param info an array of thread info to register
1376 @param count the size of the info array
1378 typedef void (*register_thread_v1_t)
1379 (const char *category, struct PSI_thread_info_v1 *info, int count);
1382 File registration API.
1383 @param category a category name (typically a plugin name)
1384 @param info an array of file info to register
1385 @param count the size of the info array
1387 typedef void (*register_file_v1_t)
1388 (const char *category, struct PSI_file_info_v1 *info, int count);
1391 Stage registration API.
1392 @param category a category name
1393 @param info an array of stage info to register
1394 @param count the size of the info array
1396 typedef void (*register_stage_v1_t)
1397 (const char *category, struct PSI_stage_info_v1 **info, int count);
1400 Statement registration API.
1401 @param category a category name
1402 @param info an array of stage info to register
1403 @param count the size of the info array
1405 typedef void (*register_statement_v1_t)
1406 (const char *category, struct PSI_statement_info_v1 *info, int count);
1409 Socket registration API.
1410 @param category a category name (typically a plugin name)
1411 @param info an array of socket info to register
1412 @param count the size of the info array
1414 typedef void (*register_socket_v1_t)
1415 (const char *category, struct PSI_socket_info_v1 *info, int count);
1418 Mutex instrumentation initialisation API.
1419 @param key the registered mutex key
1420 @param identity the address of the mutex itself
1421 @return an instrumented mutex
1423 typedef struct PSI_mutex* (*init_mutex_v1_t)
1424 (PSI_mutex_key key, const void *identity);
1427 Mutex instrumentation destruction API.
1428 @param mutex the mutex to destroy
1430 typedef void (*destroy_mutex_v1_t)(struct PSI_mutex *mutex);
1433 Rwlock instrumentation initialisation API.
1434 @param key the registered rwlock key
1435 @param identity the address of the rwlock itself
1436 @return an instrumented rwlock
1438 typedef struct PSI_rwlock* (*init_rwlock_v1_t)
1439 (PSI_rwlock_key key, const void *identity);
1442 Rwlock instrumentation destruction API.
1443 @param rwlock the rwlock to destroy
1445 typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock);
1448 Cond instrumentation initialisation API.
1449 @param key the registered key
1450 @param identity the address of the rwlock itself
1451 @return an instrumented cond
1453 typedef struct PSI_cond* (*init_cond_v1_t)
1454 (PSI_cond_key key, const void *identity);
1457 Cond instrumentation destruction API.
1458 @param cond the rcond to destroy
1460 typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond);
1463 Socket instrumentation initialisation API.
1464 @param key the registered mutex key
1465 @param socket descriptor
1466 @param addr the socket ip address
1467 @param addr_len length of socket ip address
1468 @return an instrumented socket
1470 typedef struct PSI_socket* (*init_socket_v1_t)
1471 (PSI_socket_key key, const my_socket *fd,
1472 const struct sockaddr *addr, socklen_t addr_len);
1475 socket instrumentation destruction API.
1476 @param socket the socket to destroy
1478 typedef void (*destroy_socket_v1_t)(struct PSI_socket *socket);
1481 Acquire a table share instrumentation.
1482 @param temporary True for temporary tables
1483 @param share The SQL layer table share
1484 @return a table share instrumentation, or NULL
1486 typedef struct PSI_table_share* (*get_table_share_v1_t)
1487 (my_bool temporary, struct TABLE_SHARE *share);
1490 Release a table share.
1491 @param info the table share to release
1493 typedef void (*release_table_share_v1_t)(struct PSI_table_share *share);
1497 @param temporary True for temporary tables
1498 @param schema_name the table schema name
1499 @param schema_name_length the table schema name length
1500 @param table_name the table name
1501 @param table_name_length the table name length
1503 typedef void (*drop_table_share_v1_t)
1504 (my_bool temporary, const char *schema_name, int schema_name_length,
1505 const char *table_name, int table_name_length);
1508 Open an instrumentation table handle.
1509 @param share the table to open
1510 @param identity table handle identity
1511 @return a table handle, or NULL
1513 typedef struct PSI_table* (*open_table_v1_t)
1514 (struct PSI_table_share *share, const void *identity);
1517 Unbind a table handle from the current thread.
1518 This operation happens when an opened table is added to the open table cache.
1519 @param table the table to unbind
1521 typedef void (*unbind_table_v1_t)
1522 (struct PSI_table *table);
1525 Rebind a table handle to the current thread.
1526 This operation happens when a table from the open table cache
1527 is reused for a thread.
1528 @param table the table to unbind
1530 typedef PSI_table* (*rebind_table_v1_t)
1531 (PSI_table_share *share, const void *identity, PSI_table *table);
1534 Close an instrumentation table handle.
1535 Note that the table handle is invalid after this call.
1536 @param table the table handle to close
1538 typedef void (*close_table_v1_t)(struct TABLE_SHARE *server_share,
1539 struct PSI_table *table);
1542 Create a file instrumentation for a created file.
1543 This method does not create the file itself, but is used to notify the
1544 instrumentation interface that a file was just created.
1545 @param key the file instrumentation key for this file
1546 @param name the file name
1547 @param file the file handle
1549 typedef void (*create_file_v1_t)(PSI_file_key key, const char *name,
1554 This method creates a new thread, with instrumentation.
1555 @param key the instrumentation key for this thread
1556 @param thread the resulting thread
1557 @param attr the thread attributes
1558 @param start_routine the thread start routine
1559 @param arg the thread start routine argument
1561 typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
1562 my_thread_handle *thread,
1563 const my_thread_attr_t *attr,
1564 void *(*start_routine)(void*), void *arg);
1567 Create instrumentation for a thread.
1568 @param key the registered key
1569 @param identity an address typical of the thread
1570 @return an instrumented thread
1572 typedef struct PSI_thread* (*new_thread_v1_t)
1573 (PSI_thread_key key, const void *identity, ulonglong thread_id);
1576 Assign a THD to an instrumented thread.
1577 @param thread the instrumented thread
1578 @param THD the sql layer THD to assign
1580 typedef void (*set_thread_THD_v1_t)(struct PSI_thread *thread,
1584 Assign an id to an instrumented thread.
1585 @param thread the instrumented thread
1586 @param id the id to assign
1588 typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
1592 Assign the current operating system thread id to an instrumented thread.
1593 The operating system task id is obtained from @c gettid()
1594 @param thread the instrumented thread
1596 typedef void (*set_thread_os_id_v1_t)(struct PSI_thread *thread);
1599 Get the instrumentation for the running thread.
1600 For this function to return a result,
1601 the thread instrumentation must have been attached to the
1602 running thread using @c set_thread()
1603 @return the instrumentation for the running thread
1605 typedef struct PSI_thread* (*get_thread_v1_t)(void);
1608 Assign a user name to the instrumented thread.
1609 @param user the user name
1610 @param user_len the user name length
1612 typedef void (*set_thread_user_v1_t)(const char *user, int user_len);
1615 Assign a user name and host name to the instrumented thread.
1616 @param user the user name
1617 @param user_len the user name length
1618 @param host the host name
1619 @param host_len the host name length
1621 typedef void (*set_thread_account_v1_t)(const char *user, int user_len,
1622 const char *host, int host_len);
1625 Assign a current database to the instrumented thread.
1626 @param db the database name
1627 @param db_len the database name length
1629 typedef void (*set_thread_db_v1_t)(const char* db, int db_len);
1632 Assign a current command to the instrumented thread.
1633 @param command the current command
1635 typedef void (*set_thread_command_v1_t)(int command);
1638 Assign a connection type to the instrumented thread.
1639 @param conn_type the connection type
1641 typedef void (*set_connection_type_v1_t)(opaque_vio_type conn_type);
1645 Assign a start time to the instrumented thread.
1646 @param start_time the thread start time
1648 typedef void (*set_thread_start_time_v1_t)(time_t start_time);
1651 Assign a state to the instrumented thread.
1652 @param state the thread state
1654 typedef void (*set_thread_state_v1_t)(const char* state);
1657 Assign a process info to the instrumented thread.
1658 @param info the process into string
1659 @param info_len the process into string length
1661 typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
1664 Attach a thread instrumentation to the running thread.
1665 In case of thread pools, this method should be called when
1666 a worker thread picks a work item and runs it.
1667 Also, this method should be called if the instrumented code does not
1668 keep the pointer returned by @c new_thread() and relies on @c get_thread()
1670 @param thread the thread instrumentation
1672 typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
1674 /** Delete the current thread instrumentation. */
1675 typedef void (*delete_current_thread_v1_t)(void);
1677 /** Delete a thread instrumentation. */
1678 typedef void (*delete_thread_v1_t)(struct PSI_thread *thread);
1681 Get a file instrumentation locker, for opening or creating a file.
1682 @param state data storage for the locker
1683 @param key the file instrumentation key
1684 @param op the operation to perform
1685 @param name the file name
1686 @param identity a pointer representative of this file.
1687 @return a file locker, or NULL
1689 typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t)
1690 (struct PSI_file_locker_state_v1 *state,
1691 PSI_file_key key, enum PSI_file_operation op, const char *name,
1692 const void *identity);
1695 Get a file stream instrumentation locker.
1696 @param state data storage for the locker
1697 @param file the file stream to access
1698 @param op the operation to perform
1699 @return a file locker, or NULL
1701 typedef struct PSI_file_locker* (*get_thread_file_stream_locker_v1_t)
1702 (struct PSI_file_locker_state_v1 *state,
1703 struct PSI_file *file, enum PSI_file_operation op);
1706 Get a file instrumentation locker.
1707 @param state data storage for the locker
1708 @param file the file descriptor to access
1709 @param op the operation to perform
1710 @return a file locker, or NULL
1712 typedef struct PSI_file_locker* (*get_thread_file_descriptor_locker_v1_t)
1713 (struct PSI_file_locker_state_v1 *state,
1714 File file, enum PSI_file_operation op);
1717 Record a mutex instrumentation unlock event.
1718 @param mutex the mutex instrumentation
1720 typedef void (*unlock_mutex_v1_t)
1721 (struct PSI_mutex *mutex);
1724 Record a rwlock instrumentation unlock event.
1725 @param rwlock the rwlock instrumentation
1727 typedef void (*unlock_rwlock_v1_t)
1728 (struct PSI_rwlock *rwlock);
1731 Record a condition instrumentation signal event.
1732 @param cond the cond instrumentation
1734 typedef void (*signal_cond_v1_t)
1735 (struct PSI_cond *cond);
1738 Record a condition instrumentation broadcast event.
1739 @param cond the cond instrumentation
1741 typedef void (*broadcast_cond_v1_t)
1742 (struct PSI_cond *cond);
1745 Record an idle instrumentation wait start event.
1746 @param state data storage for the locker
1747 @param file the source file name
1748 @param line the source line number
1749 @return an idle locker, or NULL
1751 typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
1752 (struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
1755 Record an idle instrumentation wait end event.
1756 @param locker a thread locker for the running thread
1758 typedef void (*end_idle_wait_v1_t)
1759 (struct PSI_idle_locker *locker);
1762 Record a mutex instrumentation wait start event.
1763 @param state data storage for the locker
1764 @param mutex the instrumented mutex to lock
1765 @param op the operation to perform
1766 @param file the source file name
1767 @param line the source line number
1768 @return a mutex locker, or NULL
1770 typedef struct PSI_mutex_locker* (*start_mutex_wait_v1_t)
1771 (struct PSI_mutex_locker_state_v1 *state,
1772 struct PSI_mutex *mutex,
1773 enum PSI_mutex_operation op,
1774 const char *src_file, uint src_line);
1777 Record a mutex instrumentation wait end event.
1778 @param locker a thread locker for the running thread
1779 @param rc the wait operation return code
1781 typedef void (*end_mutex_wait_v1_t)
1782 (struct PSI_mutex_locker *locker, int rc);
1785 Record a rwlock instrumentation read wait start event.
1786 @param locker a thread locker for the running thread
1787 @param must must block: 1 for lock, 0 for trylock
1789 typedef struct PSI_rwlock_locker* (*start_rwlock_rdwait_v1_t)
1790 (struct PSI_rwlock_locker_state_v1 *state,
1791 struct PSI_rwlock *rwlock,
1792 enum PSI_rwlock_operation op,
1793 const char *src_file, uint src_line);
1796 Record a rwlock instrumentation read wait end event.
1797 @param locker a thread locker for the running thread
1798 @param rc the wait operation return code
1800 typedef void (*end_rwlock_rdwait_v1_t)
1801 (struct PSI_rwlock_locker *locker, int rc);
1804 Record a rwlock instrumentation write wait start event.
1805 @param locker a thread locker for the running thread
1806 @param must must block: 1 for lock, 0 for trylock
1808 typedef struct PSI_rwlock_locker* (*start_rwlock_wrwait_v1_t)
1809 (struct PSI_rwlock_locker_state_v1 *state,
1810 struct PSI_rwlock *rwlock,
1811 enum PSI_rwlock_operation op,
1812 const char *src_file, uint src_line);
1815 Record a rwlock instrumentation write wait end event.
1816 @param locker a thread locker for the running thread
1817 @param rc the wait operation return code
1819 typedef void (*end_rwlock_wrwait_v1_t)
1820 (struct PSI_rwlock_locker *locker, int rc);
1823 Record a condition instrumentation wait start event.
1824 @param locker a thread locker for the running thread
1825 @param must must block: 1 for wait, 0 for timedwait
1827 typedef struct PSI_cond_locker* (*start_cond_wait_v1_t)
1828 (struct PSI_cond_locker_state_v1 *state,
1829 struct PSI_cond *cond,
1830 struct PSI_mutex *mutex,
1831 enum PSI_cond_operation op,
1832 const char *src_file, uint src_line);
1835 Record a condition instrumentation wait end event.
1836 @param locker a thread locker for the running thread
1837 @param rc the wait operation return code
1839 typedef void (*end_cond_wait_v1_t)
1840 (struct PSI_cond_locker *locker, int rc);
1843 Record a table instrumentation io wait start event.
1844 @param locker a table locker for the running thread
1845 @param file the source file name
1846 @param line the source line number
1848 typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
1849 (struct PSI_table_locker_state *state,
1850 struct PSI_table *table,
1851 enum PSI_table_io_operation op,
1853 const char *src_file, uint src_line);
1856 Record a table instrumentation io wait end event.
1857 @param locker a table locker for the running thread
1858 @param numrows the number of rows involved in io
1860 typedef void (*end_table_io_wait_v1_t)
1861 (struct PSI_table_locker *locker,
1865 Record a table instrumentation lock wait start event.
1866 @param locker a table locker for the running thread
1867 @param file the source file name
1868 @param line the source line number
1870 typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
1871 (struct PSI_table_locker_state *state,
1872 struct PSI_table *table,
1873 enum PSI_table_lock_operation op,
1875 const char *src_file, uint src_line);
1878 Record a table instrumentation lock wait end event.
1879 @param locker a table locker for the running thread
1881 typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
1883 typedef void (*unlock_table_v1_t)(struct PSI_table *table);
1886 Start a file instrumentation open operation.
1887 @param locker the file locker
1888 @param op the operation to perform
1889 @param src_file the source file name
1890 @param src_line the source line number
1892 typedef void (*start_file_open_wait_v1_t)
1893 (struct PSI_file_locker *locker, const char *src_file, uint src_line);
1896 End a file instrumentation open operation, for file streams.
1897 @param locker the file locker.
1898 @param result the opened file (NULL indicates failure, non NULL success).
1899 @return an instrumented file handle
1901 typedef struct PSI_file* (*end_file_open_wait_v1_t)
1902 (struct PSI_file_locker *locker, void *result);
1905 End a file instrumentation open operation, for non stream files.
1906 @param locker the file locker.
1907 @param file the file number assigned by open() or create() for this file.
1909 typedef void (*end_file_open_wait_and_bind_to_descriptor_v1_t)
1910 (struct PSI_file_locker *locker, File file);
1913 End a file instrumentation open operation, for non stream temporary files.
1914 @param locker the file locker.
1915 @param file the file number assigned by open() or create() for this file.
1916 @param filename the file name generated during temporary file creation.
1918 typedef void (*end_temp_file_open_wait_and_bind_to_descriptor_v1_t)
1919 (struct PSI_file_locker *locker, File file, const char *filename);
1922 Record a file instrumentation start event.
1923 @param locker a file locker for the running thread
1924 @param op file operation to be performed
1925 @param count the number of bytes requested, or 0 if not applicable
1926 @param src_file the source file name
1927 @param src_line the source line number
1929 typedef void (*start_file_wait_v1_t)
1930 (struct PSI_file_locker *locker, size_t count,
1931 const char *src_file, uint src_line);
1934 Record a file instrumentation end event.
1935 Note that for file close operations, the instrumented file handle
1936 associated with the file (which was provided to obtain a locker)
1937 is invalid after this call.
1938 @param locker a file locker for the running thread
1939 @param count the number of bytes actually used in the operation,
1940 or 0 if not applicable, or -1 if the operation failed
1941 @sa get_thread_file_name_locker
1942 @sa get_thread_file_stream_locker
1943 @sa get_thread_file_descriptor_locker
1945 typedef void (*end_file_wait_v1_t)
1946 (struct PSI_file_locker *locker, size_t count);
1949 Start a file instrumentation close operation.
1950 @param locker the file locker
1951 @param op the operation to perform
1952 @param src_file the source file name
1953 @param src_line the source line number
1955 typedef void (*start_file_close_wait_v1_t)
1956 (struct PSI_file_locker *locker, const char *src_file, uint src_line);
1959 End a file instrumentation close operation.
1960 @param locker the file locker.
1961 @param rc the close operation return code (0 for success).
1962 @return an instrumented file handle
1964 typedef void (*end_file_close_wait_v1_t)
1965 (struct PSI_file_locker *locker, int rc);
1968 Start a new stage, and implicitly end the previous stage.
1969 @param key the key of the new stage
1970 @param src_file the source file name
1971 @param src_line the source line number
1972 @return the new stage progress
1974 typedef PSI_stage_progress* (*start_stage_v1_t)
1975 (PSI_stage_key key, const char *src_file, int src_line);
1977 typedef PSI_stage_progress* (*get_current_stage_progress_v1_t)(void);
1979 /** End the current stage. */
1980 typedef void (*end_stage_v1_t) (void);
1983 Get a statement instrumentation locker.
1984 @param state data storage for the locker
1985 @param key the statement instrumentation key
1986 @param charset client character set
1987 @return a statement locker, or NULL
1989 typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t)
1990 (struct PSI_statement_locker_state_v1 *state,
1991 PSI_statement_key key, const void *charset, PSI_sp_share *sp_share);
1994 Refine a statement locker to a more specific key.
1995 Note that only events declared mutable can be refined.
1996 @param the statement locker for the current event
1997 @param key the new key for the event
1998 @sa PSI_FLAG_MUTABLE
2000 typedef struct PSI_statement_locker* (*refine_statement_v1_t)
2001 (struct PSI_statement_locker *locker,
2002 PSI_statement_key key);
2005 Start a new statement event.
2006 @param locker the statement locker for this event
2007 @param db the active database name for this statement
2008 @param db_length the active database name length for this statement
2009 @param src_file source file name
2010 @param src_line source line number
2012 typedef void (*start_statement_v1_t)
2013 (struct PSI_statement_locker *locker,
2014 const char *db, uint db_length,
2015 const char *src_file, uint src_line);
2018 Set the statement text for a statement event.
2019 @param locker the current statement locker
2020 @param text the statement text
2021 @param text_len the statement text length
2023 typedef void (*set_statement_text_v1_t)
2024 (struct PSI_statement_locker *locker,
2025 const char *text, uint text_len);
2028 Set a statement event lock time.
2029 @param locker the statement locker
2030 @param lock_time the locked time, in microseconds
2032 typedef void (*set_statement_lock_time_t)
2033 (struct PSI_statement_locker *locker, ulonglong lock_time);
2036 Set a statement event rows sent metric.
2037 @param locker the statement locker
2038 @param count the number of rows sent
2040 typedef void (*set_statement_rows_sent_t)
2041 (struct PSI_statement_locker *locker, ulonglong count);
2044 Set a statement event rows examined metric.
2045 @param locker the statement locker
2046 @param count the number of rows examined
2048 typedef void (*set_statement_rows_examined_t)
2049 (struct PSI_statement_locker *locker, ulonglong count);
2052 Increment a statement event "created tmp disk tables" metric.
2053 @param locker the statement locker
2054 @param count the metric increment value
2056 typedef void (*inc_statement_created_tmp_disk_tables_t)
2057 (struct PSI_statement_locker *locker, ulong count);
2060 Increment a statement event "created tmp tables" metric.
2061 @param locker the statement locker
2062 @param count the metric increment value
2064 typedef void (*inc_statement_created_tmp_tables_t)
2065 (struct PSI_statement_locker *locker, ulong count);
2068 Increment a statement event "select full join" metric.
2069 @param locker the statement locker
2070 @param count the metric increment value
2072 typedef void (*inc_statement_select_full_join_t)
2073 (struct PSI_statement_locker *locker, ulong count);
2076 Increment a statement event "select full range join" metric.
2077 @param locker the statement locker
2078 @param count the metric increment value
2080 typedef void (*inc_statement_select_full_range_join_t)
2081 (struct PSI_statement_locker *locker, ulong count);
2084 Increment a statement event "select range join" metric.
2085 @param locker the statement locker
2086 @param count the metric increment value
2088 typedef void (*inc_statement_select_range_t)
2089 (struct PSI_statement_locker *locker, ulong count);
2092 Increment a statement event "select range check" metric.
2093 @param locker the statement locker
2094 @param count the metric increment value
2096 typedef void (*inc_statement_select_range_check_t)
2097 (struct PSI_statement_locker *locker, ulong count);
2100 Increment a statement event "select scan" metric.
2101 @param locker the statement locker
2102 @param count the metric increment value
2104 typedef void (*inc_statement_select_scan_t)
2105 (struct PSI_statement_locker *locker, ulong count);
2108 Increment a statement event "sort merge passes" metric.
2109 @param locker the statement locker
2110 @param count the metric increment value
2112 typedef void (*inc_statement_sort_merge_passes_t)
2113 (struct PSI_statement_locker *locker, ulong count);
2116 Increment a statement event "sort range" metric.
2117 @param locker the statement locker
2118 @param count the metric increment value
2120 typedef void (*inc_statement_sort_range_t)
2121 (struct PSI_statement_locker *locker, ulong count);
2124 Increment a statement event "sort rows" metric.
2125 @param locker the statement locker
2126 @param count the metric increment value
2128 typedef void (*inc_statement_sort_rows_t)
2129 (struct PSI_statement_locker *locker, ulong count);
2132 Increment a statement event "sort scan" metric.
2133 @param locker the statement locker
2134 @param count the metric increment value
2136 typedef void (*inc_statement_sort_scan_t)
2137 (struct PSI_statement_locker *locker, ulong count);
2140 Set a statement event "no index used" metric.
2141 @param locker the statement locker
2142 @param count the metric value
2144 typedef void (*set_statement_no_index_used_t)
2145 (struct PSI_statement_locker *locker);
2148 Set a statement event "no good index used" metric.
2149 @param locker the statement locker
2150 @param count the metric value
2152 typedef void (*set_statement_no_good_index_used_t)
2153 (struct PSI_statement_locker *locker);
2156 End a statement event.
2157 @param locker the statement locker
2158 @param stmt_da the statement diagnostics area.
2159 @sa Diagnostics_area
2161 typedef void (*end_statement_v1_t)
2162 (struct PSI_statement_locker *locker, void *stmt_da);
2165 Get a transaction instrumentation locker.
2166 @param state data storage for the locker
2167 @param xid the xid for this transaction
2168 @param trxid the InnoDB transaction id
2169 @param iso_level isolation level for this transaction
2170 @param read_only true if transaction access mode is read-only
2171 @param autocommit true if transaction is autocommit
2172 @return a transaction locker, or NULL
2174 typedef struct PSI_transaction_locker* (*get_thread_transaction_locker_v1_t)
2175 (struct PSI_transaction_locker_state_v1 *state, const void *xid,
2176 const ulonglong *trxid, int isolation_level, my_bool read_only,
2177 my_bool autocommit);
2180 Start a new transaction event.
2181 @param locker the transaction locker for this event
2182 @param src_file source file name
2183 @param src_line source line number
2185 typedef void (*start_transaction_v1_t)
2186 (struct PSI_transaction_locker *locker,
2187 const char *src_file, uint src_line);
2190 Set the transaction xid.
2191 @param locker the transaction locker for this event
2192 @param xid the id of the XA transaction
2193 #param xa_state is the state of the XA transaction
2195 typedef void (*set_transaction_xid_v1_t)
2196 (struct PSI_transaction_locker *locker,
2197 const void *xid, int xa_state);
2200 Set the state of the XA transaction.
2201 @param locker the transaction locker for this event
2202 @param xa_state the new state of the xa transaction
2204 typedef void (*set_transaction_xa_state_v1_t)
2205 (struct PSI_transaction_locker *locker,
2209 Set the transaction gtid.
2210 @param locker the transaction locker for this event
2211 @param sid the source id for the transaction, mapped from sidno
2212 @param gtid_spec the gtid specifier for the transaction
2214 typedef void (*set_transaction_gtid_v1_t)
2215 (struct PSI_transaction_locker *locker,
2216 const void *sid, const void *gtid_spec);
2219 Set the transaction trx_id.
2220 @param locker the transaction locker for this event
2221 @param trxid the storage engine transaction ID
2223 typedef void (*set_transaction_trxid_v1_t)
2224 (struct PSI_transaction_locker *locker,
2225 const ulonglong *trxid);
2228 Increment a transaction event savepoint count.
2229 @param locker the transaction locker
2230 @param count the increment value
2232 typedef void (*inc_transaction_savepoints_v1_t)
2233 (struct PSI_transaction_locker *locker, ulong count);
2236 Increment a transaction event rollback to savepoint count.
2237 @param locker the transaction locker
2238 @param count the increment value
2240 typedef void (*inc_transaction_rollback_to_savepoint_v1_t)
2241 (struct PSI_transaction_locker *locker, ulong count);
2244 Increment a transaction event release savepoint count.
2245 @param locker the transaction locker
2246 @param count the increment value
2248 typedef void (*inc_transaction_release_savepoint_v1_t)
2249 (struct PSI_transaction_locker *locker, ulong count);
2252 Commit or rollback the transaction.
2253 @param locker the transaction locker for this event
2254 @param commit true if transaction was committed, false if rolled back
2256 typedef void (*end_transaction_v1_t)
2257 (struct PSI_transaction_locker *locker,
2261 Record a socket instrumentation start event.
2262 @param locker a socket locker for the running thread
2263 @param op socket operation to be performed
2264 @param count the number of bytes requested, or 0 if not applicable
2265 @param src_file the source file name
2266 @param src_line the source line number
2268 typedef struct PSI_socket_locker* (*start_socket_wait_v1_t)
2269 (struct PSI_socket_locker_state_v1 *state,
2270 struct PSI_socket *socket,
2271 enum PSI_socket_operation op,
2273 const char *src_file, uint src_line);
2276 Record a socket instrumentation end event.
2277 Note that for socket close operations, the instrumented socket handle
2278 associated with the socket (which was provided to obtain a locker)
2279 is invalid after this call.
2280 @param locker a socket locker for the running thread
2281 @param count the number of bytes actually used in the operation,
2282 or 0 if not applicable, or -1 if the operation failed
2283 @sa get_thread_socket_locker
2285 typedef void (*end_socket_wait_v1_t)
2286 (struct PSI_socket_locker *locker, size_t count);
2289 Set the socket state for an instrumented socket.
2290 @param socket the instrumented socket
2291 @param state socket state
2293 typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket,
2294 enum PSI_socket_state state);
2297 Set the socket info for an instrumented socket.
2298 @param socket the instrumented socket
2299 @param fd the socket descriptor
2300 @param addr the socket ip address
2301 @param addr_len length of socket ip address
2302 @param thread_id associated thread id
2304 typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
2305 const my_socket *fd,
2306 const struct sockaddr *addr,
2307 socklen_t addr_len);
2310 Bind a socket to the thread that owns it.
2311 @param socket instrumented socket
2313 typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
2316 Get a prepare statement.
2317 @param locker a statement locker for the running thread.
2319 typedef PSI_prepared_stmt* (*create_prepared_stmt_v1_t)
2320 (void *identity, uint stmt_id, PSI_statement_locker *locker,
2321 const char *stmt_name, size_t stmt_name_length,
2322 const char *name, size_t length);
2325 destroy a prepare statement.
2326 @param prepared_stmt prepared statement.
2328 typedef void (*destroy_prepared_stmt_v1_t)
2329 (PSI_prepared_stmt *prepared_stmt);
2332 repreare a prepare statement.
2333 @param prepared_stmt prepared statement.
2335 typedef void (*reprepare_prepared_stmt_v1_t)
2336 (PSI_prepared_stmt *prepared_stmt);
2339 Record a prepare statement instrumentation execute event.
2340 @param locker a statement locker for the running thread.
2341 @param prepared_stmt prepared statement.
2343 typedef void (*execute_prepared_stmt_v1_t)
2344 (PSI_statement_locker *locker, PSI_prepared_stmt* prepared_stmt);
2347 Get a digest locker for the current statement.
2348 @param locker a statement locker for the running thread
2350 typedef struct PSI_digest_locker * (*digest_start_v1_t)
2351 (struct PSI_statement_locker *locker);
2354 Add a token to the current digest instrumentation.
2355 @param locker a digest locker for the current statement
2356 @param token the lexical token to add
2357 @param yylval the lexical token attributes
2359 typedef void (*digest_end_v1_t)
2360 (struct PSI_digest_locker *locker, const struct sql_digest_storage *digest);
2362 typedef PSI_sp_locker* (*start_sp_v1_t)
2363 (struct PSI_sp_locker_state_v1 *state, struct PSI_sp_share* sp_share);
2365 typedef void (*end_sp_v1_t)
2366 (struct PSI_sp_locker *locker);
2368 typedef void (*drop_sp_v1_t)
2370 const char *schema_name, uint schema_name_length,
2371 const char *object_name, uint object_name_length);
2374 Acquire a sp share instrumentation.
2375 @param type of stored program
2376 @param schema name of stored program
2377 @param name of stored program
2378 @return a stored program share instrumentation, or NULL
2380 typedef struct PSI_sp_share* (*get_sp_share_v1_t)
2382 const char *schema_name, uint schema_name_length,
2383 const char *object_name, uint object_name_length);
2386 Release a stored program share.
2387 @param info the stored program share to release
2389 typedef void (*release_sp_share_v1_t)(struct PSI_sp_share *share);
2391 typedef PSI_metadata_lock* (*create_metadata_lock_v1_t)
2394 opaque_mdl_type mdl_type,
2395 opaque_mdl_duration mdl_duration,
2396 opaque_mdl_status mdl_status,
2397 const char *src_file,
2400 typedef void (*set_metadata_lock_status_v1_t)(PSI_metadata_lock *lock,
2401 opaque_mdl_status mdl_status);
2403 typedef void (*destroy_metadata_lock_v1_t)(PSI_metadata_lock *lock);
2405 typedef struct PSI_metadata_locker* (*start_metadata_wait_v1_t)
2406 (struct PSI_metadata_locker_state_v1 *state,
2407 struct PSI_metadata_lock *mdl,
2408 const char *src_file, uint src_line);
2410 typedef void (*end_metadata_wait_v1_t)
2411 (struct PSI_metadata_locker *locker, int rc);
2414 Stores an array of connection attributes
2415 @param buffer char array of length encoded connection attributes
2417 @param length length of the data in buffer
2418 @param from_cs charset in which @c buffer is encoded
2420 @retval non_0 attributes truncated
2421 @retval 0 stored the attribute
2423 typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
2424 const void *from_cs);
2427 Performance Schema Interface, version 1.
2428 @since PSI_VERSION_1
2432 /** @sa register_mutex_v1_t. */
2433 register_mutex_v1_t register_mutex;
2434 /** @sa register_rwlock_v1_t. */
2435 register_rwlock_v1_t register_rwlock;
2436 /** @sa register_cond_v1_t. */
2437 register_cond_v1_t register_cond;
2438 /** @sa register_thread_v1_t. */
2439 register_thread_v1_t register_thread;
2440 /** @sa register_file_v1_t. */
2441 register_file_v1_t register_file;
2442 /** @sa register_stage_v1_t. */
2443 register_stage_v1_t register_stage;
2444 /** @sa register_statement_v1_t. */
2445 register_statement_v1_t register_statement;
2446 /** @sa register_socket_v1_t. */
2447 register_socket_v1_t register_socket;
2448 /** @sa init_mutex_v1_t. */
2449 init_mutex_v1_t init_mutex;
2450 /** @sa destroy_mutex_v1_t. */
2451 destroy_mutex_v1_t destroy_mutex;
2452 /** @sa init_rwlock_v1_t. */
2453 init_rwlock_v1_t init_rwlock;
2454 /** @sa destroy_rwlock_v1_t. */
2455 destroy_rwlock_v1_t destroy_rwlock;
2456 /** @sa init_cond_v1_t. */
2457 init_cond_v1_t init_cond;
2458 /** @sa destroy_cond_v1_t. */
2459 destroy_cond_v1_t destroy_cond;
2460 /** @sa init_socket_v1_t. */
2461 init_socket_v1_t init_socket;
2462 /** @sa destroy_socket_v1_t. */
2463 destroy_socket_v1_t destroy_socket;
2465 /** @sa get_table_share_v1_t. */
2466 get_table_share_v1_t get_table_share;
2467 /** @sa release_table_share_v1_t. */
2468 release_table_share_v1_t release_table_share;
2469 /** @sa drop_table_share_v1_t. */
2470 drop_table_share_v1_t drop_table_share;
2471 /** @sa open_table_v1_t. */
2472 open_table_v1_t open_table;
2473 /** @sa unbind_table_v1_t. */
2474 unbind_table_v1_t unbind_table;
2475 /** @sa rebind_table_v1_t. */
2476 rebind_table_v1_t rebind_table;
2477 /** @sa close_table_v1_t. */
2478 close_table_v1_t close_table;
2479 /** @sa create_file_v1_t. */
2480 create_file_v1_t create_file;
2481 /** @sa spawn_thread_v1_t. */
2482 spawn_thread_v1_t spawn_thread;
2483 /** @sa new_thread_v1_t. */
2484 new_thread_v1_t new_thread;
2485 /** @sa set_thread_id_v1_t. */
2486 set_thread_id_v1_t set_thread_id;
2487 /** @sa set_thread_THD_v1_t. */
2488 set_thread_THD_v1_t set_thread_THD;
2489 /** @sa set_thread_os_id_v1_t. */
2490 set_thread_os_id_v1_t set_thread_os_id;
2491 /** @sa get_thread_v1_t. */
2492 get_thread_v1_t get_thread;
2493 /** @sa set_thread_user_v1_t. */
2494 set_thread_user_v1_t set_thread_user;
2495 /** @sa set_thread_account_v1_t. */
2496 set_thread_account_v1_t set_thread_account;
2497 /** @sa set_thread_db_v1_t. */
2498 set_thread_db_v1_t set_thread_db;
2499 /** @sa set_thread_command_v1_t. */
2500 set_thread_command_v1_t set_thread_command;
2501 /** @sa set_connection_type_v1_t. */
2502 set_connection_type_v1_t set_connection_type;
2503 /** @sa set_thread_start_time_v1_t. */
2504 set_thread_start_time_v1_t set_thread_start_time;
2505 /** @sa set_thread_state_v1_t. */
2506 set_thread_state_v1_t set_thread_state;
2507 /** @sa set_thread_info_v1_t. */
2508 set_thread_info_v1_t set_thread_info;
2509 /** @sa set_thread_v1_t. */
2510 set_thread_v1_t set_thread;
2511 /** @sa delete_current_thread_v1_t. */
2512 delete_current_thread_v1_t delete_current_thread;
2513 /** @sa delete_thread_v1_t. */
2514 delete_thread_v1_t delete_thread;
2515 /** @sa get_thread_file_name_locker_v1_t. */
2516 get_thread_file_name_locker_v1_t get_thread_file_name_locker;
2517 /** @sa get_thread_file_stream_locker_v1_t. */
2518 get_thread_file_stream_locker_v1_t get_thread_file_stream_locker;
2519 /** @sa get_thread_file_descriptor_locker_v1_t. */
2520 get_thread_file_descriptor_locker_v1_t get_thread_file_descriptor_locker;
2521 /** @sa unlock_mutex_v1_t. */
2522 unlock_mutex_v1_t unlock_mutex;
2523 /** @sa unlock_rwlock_v1_t. */
2524 unlock_rwlock_v1_t unlock_rwlock;
2525 /** @sa signal_cond_v1_t. */
2526 signal_cond_v1_t signal_cond;
2527 /** @sa broadcast_cond_v1_t. */
2528 broadcast_cond_v1_t broadcast_cond;
2529 /** @sa start_idle_wait_v1_t. */
2530 start_idle_wait_v1_t start_idle_wait;
2531 /** @sa end_idle_wait_v1_t. */
2532 end_idle_wait_v1_t end_idle_wait;
2533 /** @sa start_mutex_wait_v1_t. */
2534 start_mutex_wait_v1_t start_mutex_wait;
2535 /** @sa end_mutex_wait_v1_t. */
2536 end_mutex_wait_v1_t end_mutex_wait;
2537 /** @sa start_rwlock_rdwait_v1_t. */
2538 start_rwlock_rdwait_v1_t start_rwlock_rdwait;
2539 /** @sa end_rwlock_rdwait_v1_t. */
2540 end_rwlock_rdwait_v1_t end_rwlock_rdwait;
2541 /** @sa start_rwlock_wrwait_v1_t. */
2542 start_rwlock_wrwait_v1_t start_rwlock_wrwait;
2543 /** @sa end_rwlock_wrwait_v1_t. */
2544 end_rwlock_wrwait_v1_t end_rwlock_wrwait;
2545 /** @sa start_cond_wait_v1_t. */
2546 start_cond_wait_v1_t start_cond_wait;
2547 /** @sa end_cond_wait_v1_t. */
2548 end_cond_wait_v1_t end_cond_wait;
2549 /** @sa start_table_io_wait_v1_t. */
2550 start_table_io_wait_v1_t start_table_io_wait;
2551 /** @sa end_table_io_wait_v1_t. */
2552 end_table_io_wait_v1_t end_table_io_wait;
2553 /** @sa start_table_lock_wait_v1_t. */
2554 start_table_lock_wait_v1_t start_table_lock_wait;
2555 /** @sa end_table_lock_wait_v1_t. */
2556 end_table_lock_wait_v1_t end_table_lock_wait;
2557 /** @sa start_file_open_wait_v1_t. */
2558 start_file_open_wait_v1_t start_file_open_wait;
2559 /** @sa end_file_open_wait_v1_t. */
2560 end_file_open_wait_v1_t end_file_open_wait;
2561 /** @sa end_file_open_wait_and_bind_to_descriptor_v1_t. */
2562 end_file_open_wait_and_bind_to_descriptor_v1_t
2563 end_file_open_wait_and_bind_to_descriptor;
2564 /** @sa end_temp_file_open_wait_and_bind_to_descriptor_v1_t. */
2565 end_temp_file_open_wait_and_bind_to_descriptor_v1_t
2566 end_temp_file_open_wait_and_bind_to_descriptor;
2567 /** @sa start_file_wait_v1_t. */
2568 start_file_wait_v1_t start_file_wait;
2569 /** @sa end_file_wait_v1_t. */
2570 end_file_wait_v1_t end_file_wait;
2571 /** @sa start_file_close_wait_v1_t. */
2572 start_file_close_wait_v1_t start_file_close_wait;
2573 /** @sa end_file_close_wait_v1_t. */
2574 end_file_close_wait_v1_t end_file_close_wait;
2575 /** @sa start_stage_v1_t. */
2576 start_stage_v1_t start_stage;
2577 /** @sa get_current_stage_progress_v1_t. */
2578 get_current_stage_progress_v1_t get_current_stage_progress;
2579 /** @sa end_stage_v1_t. */
2580 end_stage_v1_t end_stage;
2581 /** @sa get_thread_statement_locker_v1_t. */
2582 get_thread_statement_locker_v1_t get_thread_statement_locker;
2583 /** @sa refine_statement_v1_t. */
2584 refine_statement_v1_t refine_statement;
2585 /** @sa start_statement_v1_t. */
2586 start_statement_v1_t start_statement;
2587 /** @sa set_statement_text_v1_t. */
2588 set_statement_text_v1_t set_statement_text;
2589 /** @sa set_statement_lock_time_t. */
2590 set_statement_lock_time_t set_statement_lock_time;
2591 /** @sa set_statement_rows_sent_t. */
2592 set_statement_rows_sent_t set_statement_rows_sent;
2593 /** @sa set_statement_rows_examined_t. */
2594 set_statement_rows_examined_t set_statement_rows_examined;
2595 /** @sa inc_statement_created_tmp_disk_tables. */
2596 inc_statement_created_tmp_disk_tables_t inc_statement_created_tmp_disk_tables;
2597 /** @sa inc_statement_created_tmp_tables. */
2598 inc_statement_created_tmp_tables_t inc_statement_created_tmp_tables;
2599 /** @sa inc_statement_select_full_join. */
2600 inc_statement_select_full_join_t inc_statement_select_full_join;
2601 /** @sa inc_statement_select_full_range_join. */
2602 inc_statement_select_full_range_join_t inc_statement_select_full_range_join;
2603 /** @sa inc_statement_select_range. */
2604 inc_statement_select_range_t inc_statement_select_range;
2605 /** @sa inc_statement_select_range_check. */
2606 inc_statement_select_range_check_t inc_statement_select_range_check;
2607 /** @sa inc_statement_select_scan. */
2608 inc_statement_select_scan_t inc_statement_select_scan;
2609 /** @sa inc_statement_sort_merge_passes. */
2610 inc_statement_sort_merge_passes_t inc_statement_sort_merge_passes;
2611 /** @sa inc_statement_sort_range. */
2612 inc_statement_sort_range_t inc_statement_sort_range;
2613 /** @sa inc_statement_sort_rows. */
2614 inc_statement_sort_rows_t inc_statement_sort_rows;
2615 /** @sa inc_statement_sort_scan. */
2616 inc_statement_sort_scan_t inc_statement_sort_scan;
2617 /** @sa set_statement_no_index_used. */
2618 set_statement_no_index_used_t set_statement_no_index_used;
2619 /** @sa set_statement_no_good_index_used. */
2620 set_statement_no_good_index_used_t set_statement_no_good_index_used;
2621 /** @sa end_statement_v1_t. */
2622 end_statement_v1_t end_statement;
2623 /** @sa get_thread_transaction_locker_v1_t. */
2624 get_thread_transaction_locker_v1_t get_thread_transaction_locker;
2625 /** @sa start_transaction_v1_t. */
2626 start_transaction_v1_t start_transaction;
2627 /** @sa set_transaction_xid_v1_t. */
2628 set_transaction_xid_v1_t set_transaction_xid;
2629 /** @sa set_transaction_xa_state_v1_t. */
2630 set_transaction_xa_state_v1_t set_transaction_xa_state;
2631 /** @sa set_transaction_gtid_v1_t. */
2632 set_transaction_gtid_v1_t set_transaction_gtid;
2633 /** @sa set_transaction_trxid_v1_t. */
2634 set_transaction_trxid_v1_t set_transaction_trxid;
2635 /** @sa inc_transaction_savepoints_v1_t. */
2636 inc_transaction_savepoints_v1_t inc_transaction_savepoints;
2637 /** @sa inc_transaction_rollback_to_savepoint_v1_t. */
2638 inc_transaction_rollback_to_savepoint_v1_t inc_transaction_rollback_to_savepoint;
2639 /** @sa inc_transaction_release_savepoint_v1_t. */
2640 inc_transaction_release_savepoint_v1_t inc_transaction_release_savepoint;
2641 /** @sa end_transaction_v1_t. */
2642 end_transaction_v1_t end_transaction;
2643 /** @sa start_socket_wait_v1_t. */
2644 start_socket_wait_v1_t start_socket_wait;
2645 /** @sa end_socket_wait_v1_t. */
2646 end_socket_wait_v1_t end_socket_wait;
2647 /** @sa set_socket_state_v1_t. */
2648 set_socket_state_v1_t set_socket_state;
2649 /** @sa set_socket_info_v1_t. */
2650 set_socket_info_v1_t set_socket_info;
2651 /** @sa set_socket_thread_owner_v1_t. */
2652 set_socket_thread_owner_v1_t set_socket_thread_owner;
2653 /** @sa create_prepared_stmt_v1_t. */
2654 create_prepared_stmt_v1_t create_prepared_stmt;
2655 /** @sa destroy_prepared_stmt_v1_t. */
2656 destroy_prepared_stmt_v1_t destroy_prepared_stmt;
2657 /** @sa reprepare_prepared_stmt_v1_t. */
2658 reprepare_prepared_stmt_v1_t reprepare_prepared_stmt;
2659 /** @sa execute_prepared_stmt_v1_t. */
2660 execute_prepared_stmt_v1_t execute_prepared_stmt;
2661 /** @sa digest_start_v1_t. */
2662 digest_start_v1_t digest_start;
2663 /** @sa digest_end_v1_t. */
2664 digest_end_v1_t digest_end;
2665 /** @sa set_thread_connect_attrs_v1_t. */
2666 set_thread_connect_attrs_v1_t set_thread_connect_attrs;
2667 /** @sa start_sp_v1_t. */
2668 start_sp_v1_t start_sp;
2669 /** @sa start_sp_v1_t. */
2671 /** @sa drop_sp_v1_t. */
2672 drop_sp_v1_t drop_sp;
2673 /** @sa get_sp_share_v1_t. */
2674 get_sp_share_v1_t get_sp_share;
2675 /** @sa release_sp_share_v1_t. */
2676 release_sp_share_v1_t release_sp_share;
2677 /** @sa register_memory_v1_t. */
2678 register_memory_v1_t register_memory;
2679 /** @sa memory_alloc_v1_t. */
2680 memory_alloc_v1_t memory_alloc;
2681 /** @sa memory_realloc_v1_t. */
2682 memory_realloc_v1_t memory_realloc;
2683 /** @sa memory_claim_v1_t. */
2684 memory_claim_v1_t memory_claim;
2685 /** @sa memory_free_v1_t. */
2686 memory_free_v1_t memory_free;
2688 unlock_table_v1_t unlock_table;
2690 create_metadata_lock_v1_t create_metadata_lock;
2691 set_metadata_lock_status_v1_t set_metadata_lock_status;
2692 destroy_metadata_lock_v1_t destroy_metadata_lock;
2694 start_metadata_wait_v1_t start_metadata_wait;
2695 end_metadata_wait_v1_t end_metadata_wait;
2698 /** @} (end of group Group_PSI_v1) */
2700 #endif /* HAVE_PSI_1 */
2709 @defgroup Group_PSI_v2 Application Binary Interface, version 2
2710 @ingroup Instrumentation_interface
2715 Performance Schema Interface, version 2.
2716 This is a placeholder, this interface is not defined yet.
2717 @since PSI_VERSION_2
2723 /* ... extended interface ... */
2727 struct PSI_mutex_info_v2
2734 struct PSI_rwlock_info_v2
2741 struct PSI_cond_info_v2
2748 struct PSI_thread_info_v2
2755 struct PSI_file_info_v2
2762 struct PSI_stage_info_v2
2769 struct PSI_statement_info_v2
2776 struct PSI_transaction_info_v2
2783 struct PSI_idle_locker_state_v2
2790 struct PSI_mutex_locker_state_v2
2797 struct PSI_rwlock_locker_state_v2
2804 struct PSI_cond_locker_state_v2
2811 struct PSI_file_locker_state_v2
2818 struct PSI_statement_locker_state_v2
2825 struct PSI_transaction_locker_state_v2
2832 struct PSI_socket_locker_state_v2
2838 struct PSI_metadata_locker_state_v2
2843 /** @} (end of group Group_PSI_v2) */
2845 #endif /* HAVE_PSI_2 */
2849 The instrumentation interface for the current version.
2850 @sa PSI_CURRENT_VERSION
2854 @typedef PSI_mutex_info
2855 The mutex information structure for the current version.
2859 @typedef PSI_rwlock_info
2860 The rwlock information structure for the current version.
2864 @typedef PSI_cond_info
2865 The cond information structure for the current version.
2869 @typedef PSI_thread_info
2870 The thread information structure for the current version.
2874 @typedef PSI_file_info
2875 The file information structure for the current version.
2878 /* Export the required version */
2880 typedef struct PSI_v1 PSI;
2881 typedef struct PSI_mutex_info_v1 PSI_mutex_info;
2882 typedef struct PSI_rwlock_info_v1 PSI_rwlock_info;
2883 typedef struct PSI_cond_info_v1 PSI_cond_info;
2884 typedef struct PSI_thread_info_v1 PSI_thread_info;
2885 typedef struct PSI_file_info_v1 PSI_file_info;
2886 typedef struct PSI_stage_info_v1 PSI_stage_info;
2887 typedef struct PSI_statement_info_v1 PSI_statement_info;
2888 typedef struct PSI_transaction_info_v1 PSI_transaction_info;
2889 typedef struct PSI_socket_info_v1 PSI_socket_info;
2890 typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
2891 typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
2892 typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
2893 typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
2894 typedef struct PSI_file_locker_state_v1 PSI_file_locker_state;
2895 typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
2896 typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state;
2897 typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
2898 typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state;
2899 typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state;
2903 typedef struct PSI_v2 PSI;
2904 typedef struct PSI_mutex_info_v2 PSI_mutex_info;
2905 typedef struct PSI_rwlock_info_v2 PSI_rwlock_info;
2906 typedef struct PSI_cond_info_v2 PSI_cond_info;
2907 typedef struct PSI_thread_info_v2 PSI_thread_info;
2908 typedef struct PSI_file_info_v2 PSI_file_info;
2909 typedef struct PSI_stage_info_v2 PSI_stage_info;
2910 typedef struct PSI_statement_info_v2 PSI_statement_info;
2911 typedef struct PSI_transaction_info_v2 PSI_transaction_info;
2912 typedef struct PSI_socket_info_v2 PSI_socket_info;
2913 typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
2914 typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
2915 typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
2916 typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
2917 typedef struct PSI_file_locker_state_v2 PSI_file_locker_state;
2918 typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
2919 typedef struct PSI_transaction_locker_state_v2 PSI_transaction_locker_state;
2920 typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
2921 typedef struct PSI_sp_locker_state_v2 PSI_sp_locker_state;
2922 typedef struct PSI_metadata_locker_state_v2 PSI_metadata_locker_state;
2925 #else /* HAVE_PSI_INTERFACE */
2928 Dummy structure, used to declare PSI_server when no instrumentation
2930 The content does not matter, since PSI_server will be NULL.
2936 typedef struct PSI_none PSI;
2939 Stage instrument information.
2940 @since PSI_VERSION_1
2941 This structure is used to register an instrumented stage.
2943 struct PSI_stage_info_none
2945 /** Unused stage key. */
2947 /** The name of the stage instrument. */
2949 /** Unused stage flags. */
2954 The stage instrumentation has to co exist with the legacy
2955 THD::set_proc_info instrumentation.
2956 To avoid duplication of the instrumentation in the server,
2957 the common PSI_stage_info structure is used,
2958 so we export it here, even when not building
2959 with HAVE_PSI_INTERFACE.
2961 typedef struct PSI_stage_info_none PSI_stage_info;
2963 #endif /* HAVE_PSI_INTERFACE */
2965 extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
2968 Allow to override PSI_XXX_CALL at compile time
2969 with more efficient implementations, if available.
2970 If nothing better is available,
2971 make a dynamic call using the PSI_server function pointer.
2974 #define PSI_DYNAMIC_CALL(M) PSI_server->M
2979 #endif /* MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H */