MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
psi.h
Go to the documentation of this file.
1 /* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
2 
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.
6 
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.
11 
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 */
15 
16 #ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
17 #define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
18 
19 #ifdef EMBEDDED_LIBRARY
20 #define DISABLE_PSI_MUTEX
21 #define DISABLE_PSI_RWLOCK
22 #define DISABLE_PSI_COND
23 #define DISABLE_PSI_FILE
24 #define DISABLE_PSI_TABLE
25 #define DISABLE_PSI_SOCKET
26 #define DISABLE_PSI_STAGE
27 #define DISABLE_PSI_STATEMENT
28 #define DISABLE_PSI_IDLE
29 #define DISABLE_PSI_STATEMENT_DIGEST
30 #endif /* EMBEDDED_LIBRARY */
31 
32 #ifndef MY_GLOBAL_INCLUDED
33 /*
34  Make sure a .c or .cc file contains an include to my_global.h first.
35  When this include is missing, all the #ifdef HAVE_XXX have no effect,
36  and the resulting binary won't build, or won't link,
37  or will crash at runtime
38  since various structures will have different binary definitions.
39 */
40 #error "You must include my_global.h in the code for the build to be correct."
41 #endif
42 
43 C_MODE_START
44 
45 struct TABLE_SHARE;
46 /*
47  There are 3 known bison parsers in the server:
48  - (1) the SQL parser itself, sql/sql_yacc.yy
49  - (2) storage/innobase/fts/fts0pars.y
50  - (3) storage/innobase/pars/pars0grm.y
51  What is instrumented here are the tokens from the SQL query text (1),
52  to make digests.
53  Now, to avoid name pollution and conflicts with different YYSTYPE definitions,
54  an opaque structure is used here.
55  The real type to use when invoking the digest api is LEX_YYSTYPE.
56 */
57 struct OPAQUE_LEX_YYSTYPE;
58 
72 struct PSI_mutex;
73 typedef struct PSI_mutex PSI_mutex;
74 
79 struct PSI_rwlock;
80 typedef struct PSI_rwlock PSI_rwlock;
81 
86 struct PSI_cond;
87 typedef struct PSI_cond PSI_cond;
88 
93 struct PSI_table_share;
94 typedef struct PSI_table_share PSI_table_share;
95 
100 struct PSI_table;
101 typedef struct PSI_table PSI_table;
102 
107 struct PSI_thread;
108 typedef struct PSI_thread PSI_thread;
109 
114 struct PSI_file;
115 typedef struct PSI_file PSI_file;
116 
121 struct PSI_socket;
122 typedef struct PSI_socket PSI_socket;
123 
128 struct PSI_table_locker;
129 typedef struct PSI_table_locker PSI_table_locker;
130 
135 struct PSI_statement_locker;
136 typedef struct PSI_statement_locker PSI_statement_locker;
137 
142 struct PSI_idle_locker;
143 typedef struct PSI_idle_locker PSI_idle_locker;
144 
149 struct PSI_digest_locker;
150 typedef struct PSI_digest_locker PSI_digest_locker;
151 
154 {
168  void* (*get_interface)(int version);
169 };
170 typedef struct PSI_bootstrap PSI_bootstrap;
171 
172 #ifdef HAVE_PSI_INTERFACE
173 
193 #ifndef DISABLE_PSI_MUTEX
194 #define HAVE_PSI_MUTEX_INTERFACE
195 #endif
196 
203 #ifndef DISABLE_PSI_RWLOCK
204 #define HAVE_PSI_RWLOCK_INTERFACE
205 #endif
206 
213 #ifndef DISABLE_PSI_COND
214 #define HAVE_PSI_COND_INTERFACE
215 #endif
216 
223 #ifndef DISABLE_PSI_FILE
224 #define HAVE_PSI_FILE_INTERFACE
225 #endif
226 
232 #ifndef DISABLE_PSI_THREAD
233 #define HAVE_PSI_THREAD_INTERFACE
234 #endif
235 
242 #ifndef DISABLE_PSI_TABLE
243 #define HAVE_PSI_TABLE_INTERFACE
244 #endif
245 
252 #ifndef DISABLE_PSI_STAGE
253 #define HAVE_PSI_STAGE_INTERFACE
254 #endif
255 
262 #ifndef DISABLE_PSI_STATEMENT
263 #define HAVE_PSI_STATEMENT_INTERFACE
264 #endif
265 
271 #ifndef DISABLE_PSI_STATEMENT
272 #ifndef DISABLE_PSI_STATEMENT_DIGEST
273 #define HAVE_PSI_STATEMENT_DIGEST_INTERFACE
274 #endif
275 #endif
276 
283 #ifndef DISABLE_PSI_SOCKET
284 #define HAVE_PSI_SOCKET_INTERFACE
285 #endif
286 
293 #ifndef DISABLE_PSI_IDLE
294 #define HAVE_PSI_IDLE_INTERFACE
295 #endif
296 
302 #define PSI_VERSION_1 1
303 
309 #define PSI_VERSION_2 2
310 
316 #define PSI_CURRENT_VERSION 1
317 
318 #ifndef USE_PSI_2
319 #ifndef USE_PSI_1
320 #define USE_PSI_1
321 #endif
322 #endif
323 
328 struct PSI_mutex_locker;
329 typedef struct PSI_mutex_locker PSI_mutex_locker;
330 
335 struct PSI_rwlock_locker;
336 typedef struct PSI_rwlock_locker PSI_rwlock_locker;
337 
342 struct PSI_cond_locker;
343 typedef struct PSI_cond_locker PSI_cond_locker;
344 
349 struct PSI_file_locker;
350 typedef struct PSI_file_locker PSI_file_locker;
351 
356 struct PSI_socket_locker;
357 typedef struct PSI_socket_locker PSI_socket_locker;
358 
360 enum PSI_mutex_operation
361 {
363  PSI_MUTEX_LOCK= 0,
365  PSI_MUTEX_TRYLOCK= 1
366 };
367 typedef enum PSI_mutex_operation PSI_mutex_operation;
368 
370 enum PSI_rwlock_operation
371 {
373  PSI_RWLOCK_READLOCK= 0,
375  PSI_RWLOCK_WRITELOCK= 1,
377  PSI_RWLOCK_TRYREADLOCK= 2,
379  PSI_RWLOCK_TRYWRITELOCK= 3
380 };
381 typedef enum PSI_rwlock_operation PSI_rwlock_operation;
382 
384 enum PSI_cond_operation
385 {
387  PSI_COND_WAIT= 0,
389  PSI_COND_TIMEDWAIT= 1
390 };
391 typedef enum PSI_cond_operation PSI_cond_operation;
392 
394 enum PSI_file_operation
395 {
397  PSI_FILE_CREATE= 0,
399  PSI_FILE_CREATE_TMP= 1,
401  PSI_FILE_OPEN= 2,
403  PSI_FILE_STREAM_OPEN= 3,
405  PSI_FILE_CLOSE= 4,
407  PSI_FILE_STREAM_CLOSE= 5,
412  PSI_FILE_READ= 6,
417  PSI_FILE_WRITE= 7,
419  PSI_FILE_SEEK= 8,
421  PSI_FILE_TELL= 9,
423  PSI_FILE_FLUSH= 10,
425  PSI_FILE_STAT= 11,
427  PSI_FILE_FSTAT= 12,
429  PSI_FILE_CHSIZE= 13,
431  PSI_FILE_DELETE= 14,
433  PSI_FILE_RENAME= 15,
435  PSI_FILE_SYNC= 16
436 };
437 typedef enum PSI_file_operation PSI_file_operation;
438 
440 enum PSI_table_io_operation
441 {
443  PSI_TABLE_FETCH_ROW= 0,
445  PSI_TABLE_WRITE_ROW= 1,
447  PSI_TABLE_UPDATE_ROW= 2,
449  PSI_TABLE_DELETE_ROW= 3
450 };
451 typedef enum PSI_table_io_operation PSI_table_io_operation;
452 
454 enum PSI_table_lock_operation
455 {
457  PSI_TABLE_LOCK= 0,
459  PSI_TABLE_EXTERNAL_LOCK= 1
460 };
461 typedef enum PSI_table_lock_operation PSI_table_lock_operation;
462 
464 enum PSI_socket_state
465 {
467  PSI_SOCKET_STATE_IDLE= 1,
469  PSI_SOCKET_STATE_ACTIVE= 2
470 };
471 typedef enum PSI_socket_state PSI_socket_state;
472 
474 enum PSI_socket_operation
475 {
477  PSI_SOCKET_CREATE= 0,
479  PSI_SOCKET_CONNECT= 1,
481  PSI_SOCKET_BIND= 2,
483  PSI_SOCKET_CLOSE= 3,
485  PSI_SOCKET_SEND= 4,
487  PSI_SOCKET_RECV= 5,
489  PSI_SOCKET_SENDTO= 6,
491  PSI_SOCKET_RECVFROM= 7,
493  PSI_SOCKET_SENDMSG= 8,
495  PSI_SOCKET_RECVMSG= 9,
497  PSI_SOCKET_SEEK= 10,
499  PSI_SOCKET_OPT= 11,
501  PSI_SOCKET_STAT= 12,
503  PSI_SOCKET_SHUTDOWN= 13,
505  PSI_SOCKET_SELECT= 14
506 };
507 typedef enum PSI_socket_operation PSI_socket_operation;
508 
514 typedef unsigned int PSI_mutex_key;
515 
522 typedef unsigned int PSI_rwlock_key;
523 
530 typedef unsigned int PSI_cond_key;
531 
538 typedef unsigned int PSI_thread_key;
539 
545 typedef unsigned int PSI_file_key;
546 
552 typedef unsigned int PSI_stage_key;
553 
559 typedef unsigned int PSI_statement_key;
560 
566 typedef unsigned int PSI_socket_key;
567 
593 #define PSI_FLAG_GLOBAL (1 << 0)
594 
600 #define PSI_FLAG_MUTABLE (1 << 1)
601 
602 #ifdef USE_PSI_1
603 #define HAVE_PSI_1
604 #endif
605 
606 #ifdef HAVE_PSI_1
607 
619 struct PSI_mutex_info_v1
620 {
624  PSI_mutex_key *m_key;
628  const char *m_name;
633  int m_flags;
634 };
635 
641 struct PSI_rwlock_info_v1
642 {
646  PSI_rwlock_key *m_key;
650  const char *m_name;
655  int m_flags;
656 };
657 
663 struct PSI_cond_info_v1
664 {
668  PSI_cond_key *m_key;
672  const char *m_name;
677  int m_flags;
678 };
679 
685 struct PSI_thread_info_v1
686 {
690  PSI_thread_key *m_key;
694  const char *m_name;
699  int m_flags;
700 };
701 
707 struct PSI_file_info_v1
708 {
712  PSI_file_key *m_key;
716  const char *m_name;
721  int m_flags;
722 };
723 
729 struct PSI_stage_info_v1
730 {
732  PSI_stage_key m_key;
734  const char *m_name;
736  int m_flags;
737 };
738 
744 struct PSI_statement_info_v1
745 {
747  PSI_statement_key m_key;
749  const char *m_name;
751  int m_flags;
752 };
753 
759 struct PSI_socket_info_v1
760 {
764  PSI_socket_key *m_key;
768  const char *m_name;
773  int m_flags;
774 };
775 
785 struct PSI_idle_locker_state_v1
786 {
788  uint m_flags;
790  struct PSI_thread *m_thread;
792  ulonglong m_timer_start;
794  ulonglong (*m_timer)(void);
796  void *m_wait;
797 };
798 
808 struct PSI_mutex_locker_state_v1
809 {
811  uint m_flags;
813  enum PSI_mutex_operation m_operation;
815  struct PSI_mutex *m_mutex;
817  struct PSI_thread *m_thread;
819  ulonglong m_timer_start;
821  ulonglong (*m_timer)(void);
823  void *m_wait;
824 };
825 
836 struct PSI_rwlock_locker_state_v1
837 {
839  uint m_flags;
841  enum PSI_rwlock_operation m_operation;
843  struct PSI_rwlock *m_rwlock;
845  struct PSI_thread *m_thread;
847  ulonglong m_timer_start;
849  ulonglong (*m_timer)(void);
851  void *m_wait;
852 };
853 
863 struct PSI_cond_locker_state_v1
864 {
866  uint m_flags;
868  enum PSI_cond_operation m_operation;
870  struct PSI_cond *m_cond;
872  struct PSI_mutex *m_mutex;
874  struct PSI_thread *m_thread;
876  ulonglong m_timer_start;
878  ulonglong (*m_timer)(void);
880  void *m_wait;
881 };
882 
894 struct PSI_file_locker_state_v1
895 {
897  uint m_flags;
899  enum PSI_file_operation m_operation;
901  struct PSI_file *m_file;
903  const char *m_name;
905  void *m_class;
907  struct PSI_thread *m_thread;
909  size_t m_number_of_bytes;
911  ulonglong m_timer_start;
913  ulonglong (*m_timer)(void);
915  void *m_wait;
916 };
917 
929 struct PSI_table_locker_state_v1
930 {
932  uint m_flags;
934  enum PSI_table_io_operation m_io_operation;
936  struct PSI_table *m_table;
938  struct PSI_table_share *m_table_share;
940  struct PSI_thread *m_thread;
942  ulonglong m_timer_start;
944  ulonglong (*m_timer)(void);
946  void *m_wait;
952  uint m_index;
953 };
954 
955 #define PSI_MAX_DIGEST_STORAGE_SIZE 1024
956 
961 struct PSI_digest_storage
962 {
963  my_bool m_full;
964  int m_byte_count;
966  uint m_charset_number;
967  unsigned char m_token_array[PSI_MAX_DIGEST_STORAGE_SIZE];
968 };
969 typedef struct PSI_digest_storage PSI_digest_storage;
970 
971 struct PSI_digest_locker_state
972 {
973  int m_last_id_index;
974  PSI_digest_storage m_digest_storage;
975 };
976 typedef struct PSI_digest_locker_state PSI_digest_locker_state;
977 
978 /* Duplicate of NAME_LEN, to avoid dependency on mysql_com.h */
979 #define PSI_SCHEMA_NAME_LEN (64 * 3)
980 
991 struct PSI_statement_locker_state_v1
992 {
994  my_bool m_discarded;
996  uchar m_no_index_used;
998  uchar m_no_good_index_used;
1000  uint m_flags;
1002  void *m_class;
1004  struct PSI_thread *m_thread;
1006  ulonglong m_timer_start;
1008  ulonglong (*m_timer)(void);
1010  void *m_statement;
1012  ulonglong m_lock_time;
1014  ulonglong m_rows_sent;
1016  ulonglong m_rows_examined;
1018  ulong m_created_tmp_disk_tables;
1020  ulong m_created_tmp_tables;
1022  ulong m_select_full_join;
1024  ulong m_select_full_range_join;
1026  ulong m_select_range;
1028  ulong m_select_range_check;
1030  ulong m_select_scan;
1032  ulong m_sort_merge_passes;
1034  ulong m_sort_range;
1036  ulong m_sort_rows;
1038  ulong m_sort_scan;
1040  PSI_digest_locker_state m_digest_state;
1042  char m_schema_name[PSI_SCHEMA_NAME_LEN];
1044  uint m_schema_name_length;
1045 };
1046 
1056 struct PSI_socket_locker_state_v1
1057 {
1059  uint m_flags;
1061  struct PSI_socket *m_socket;
1063  struct PSI_thread *m_thread;
1065  size_t m_number_of_bytes;
1067  ulonglong m_timer_start;
1069  ulonglong (*m_timer)(void);
1071  enum PSI_socket_operation m_operation;
1073  const char* m_src_file;
1075  int m_src_line;
1077  void *m_wait;
1078 };
1079 
1080 /* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */
1081 
1088 typedef void (*register_mutex_v1_t)
1089  (const char *category, struct PSI_mutex_info_v1 *info, int count);
1090 
1097 typedef void (*register_rwlock_v1_t)
1098  (const char *category, struct PSI_rwlock_info_v1 *info, int count);
1099 
1106 typedef void (*register_cond_v1_t)
1107  (const char *category, struct PSI_cond_info_v1 *info, int count);
1108 
1115 typedef void (*register_thread_v1_t)
1116  (const char *category, struct PSI_thread_info_v1 *info, int count);
1117 
1124 typedef void (*register_file_v1_t)
1125  (const char *category, struct PSI_file_info_v1 *info, int count);
1126 
1133 typedef void (*register_stage_v1_t)
1134  (const char *category, struct PSI_stage_info_v1 **info, int count);
1135 
1142 typedef void (*register_statement_v1_t)
1143  (const char *category, struct PSI_statement_info_v1 *info, int count);
1144 
1151 typedef void (*register_socket_v1_t)
1152  (const char *category, struct PSI_socket_info_v1 *info, int count);
1153 
1160 typedef struct PSI_mutex* (*init_mutex_v1_t)
1161  (PSI_mutex_key key, const void *identity);
1162 
1167 typedef void (*destroy_mutex_v1_t)(struct PSI_mutex *mutex);
1168 
1175 typedef struct PSI_rwlock* (*init_rwlock_v1_t)
1176  (PSI_rwlock_key key, const void *identity);
1177 
1182 typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock);
1183 
1190 typedef struct PSI_cond* (*init_cond_v1_t)
1191  (PSI_cond_key key, const void *identity);
1192 
1197 typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond);
1198 
1207 typedef struct PSI_socket* (*init_socket_v1_t)
1208  (PSI_socket_key key, const my_socket *fd,
1209  const struct sockaddr *addr, socklen_t addr_len);
1210 
1215 typedef void (*destroy_socket_v1_t)(struct PSI_socket *socket);
1216 
1223 typedef struct PSI_table_share* (*get_table_share_v1_t)
1224  (my_bool temporary, struct TABLE_SHARE *share);
1225 
1230 typedef void (*release_table_share_v1_t)(struct PSI_table_share *share);
1231 
1240 typedef void (*drop_table_share_v1_t)
1241  (my_bool temporary, const char *schema_name, int schema_name_length,
1242  const char *table_name, int table_name_length);
1243 
1250 typedef struct PSI_table* (*open_table_v1_t)
1251  (struct PSI_table_share *share, const void *identity);
1252 
1258 typedef void (*unbind_table_v1_t)
1259  (struct PSI_table *table);
1260 
1267 typedef PSI_table* (*rebind_table_v1_t)
1268  (PSI_table_share *share, const void *identity, PSI_table *table);
1269 
1275 typedef void (*close_table_v1_t)(struct PSI_table *table);
1276 
1285 typedef void (*create_file_v1_t)(PSI_file_key key, const char *name,
1286  File file);
1287 
1297 typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
1298  pthread_t *thread,
1299  const pthread_attr_t *attr,
1300  void *(*start_routine)(void*), void *arg);
1301 
1308 typedef struct PSI_thread* (*new_thread_v1_t)
1309  (PSI_thread_key key, const void *identity, ulonglong thread_id);
1310 
1316 typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
1317  ulonglong id);
1318 
1326 typedef struct PSI_thread* (*get_thread_v1_t)(void);
1327 
1333 typedef void (*set_thread_user_v1_t)(const char *user, int user_len);
1334 
1342 typedef void (*set_thread_user_host_v1_t)(const char *user, int user_len,
1343  const char *host, int host_len);
1344 
1350 typedef void (*set_thread_db_v1_t)(const char* db, int db_len);
1351 
1356 typedef void (*set_thread_command_v1_t)(int command);
1357 
1362 typedef void (*set_thread_start_time_v1_t)(time_t start_time);
1363 
1368 typedef void (*set_thread_state_v1_t)(const char* state);
1369 
1375 typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
1376 
1386 typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
1387 
1389 typedef void (*delete_current_thread_v1_t)(void);
1390 
1392 typedef void (*delete_thread_v1_t)(struct PSI_thread *thread);
1393 
1403 typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t)
1404  (struct PSI_file_locker_state_v1 *state,
1405  PSI_file_key key, enum PSI_file_operation op, const char *name,
1406  const void *identity);
1407 
1415 typedef struct PSI_file_locker* (*get_thread_file_stream_locker_v1_t)
1416  (struct PSI_file_locker_state_v1 *state,
1417  struct PSI_file *file, enum PSI_file_operation op);
1418 
1426 typedef struct PSI_file_locker* (*get_thread_file_descriptor_locker_v1_t)
1427  (struct PSI_file_locker_state_v1 *state,
1428  File file, enum PSI_file_operation op);
1429 
1434 typedef void (*unlock_mutex_v1_t)
1435  (struct PSI_mutex *mutex);
1436 
1441 typedef void (*unlock_rwlock_v1_t)
1442  (struct PSI_rwlock *rwlock);
1443 
1448 typedef void (*signal_cond_v1_t)
1449  (struct PSI_cond *cond);
1450 
1455 typedef void (*broadcast_cond_v1_t)
1456  (struct PSI_cond *cond);
1457 
1458 typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
1459  (struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
1460 
1461 typedef void (*end_idle_wait_v1_t)
1462  (struct PSI_idle_locker *locker);
1463 
1473 typedef struct PSI_mutex_locker* (*start_mutex_wait_v1_t)
1474  (struct PSI_mutex_locker_state_v1 *state,
1475  struct PSI_mutex *mutex,
1476  enum PSI_mutex_operation op,
1477  const char *src_file, uint src_line);
1478 
1484 typedef void (*end_mutex_wait_v1_t)
1485  (struct PSI_mutex_locker *locker, int rc);
1486 
1492 typedef struct PSI_rwlock_locker* (*start_rwlock_rdwait_v1_t)
1493  (struct PSI_rwlock_locker_state_v1 *state,
1494  struct PSI_rwlock *rwlock,
1495  enum PSI_rwlock_operation op,
1496  const char *src_file, uint src_line);
1497 
1503 typedef void (*end_rwlock_rdwait_v1_t)
1504  (struct PSI_rwlock_locker *locker, int rc);
1505 
1511 typedef struct PSI_rwlock_locker* (*start_rwlock_wrwait_v1_t)
1512  (struct PSI_rwlock_locker_state_v1 *state,
1513  struct PSI_rwlock *rwlock,
1514  enum PSI_rwlock_operation op,
1515  const char *src_file, uint src_line);
1516 
1522 typedef void (*end_rwlock_wrwait_v1_t)
1523  (struct PSI_rwlock_locker *locker, int rc);
1524 
1530 typedef struct PSI_cond_locker* (*start_cond_wait_v1_t)
1531  (struct PSI_cond_locker_state_v1 *state,
1532  struct PSI_cond *cond,
1533  struct PSI_mutex *mutex,
1534  enum PSI_cond_operation op,
1535  const char *src_file, uint src_line);
1536 
1542 typedef void (*end_cond_wait_v1_t)
1543  (struct PSI_cond_locker *locker, int rc);
1544 
1551 typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
1552  (struct PSI_table_locker_state_v1 *state,
1553  struct PSI_table *table,
1554  enum PSI_table_io_operation op,
1555  uint index,
1556  const char *src_file, uint src_line);
1557 
1562 typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
1563 
1570 typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
1571  (struct PSI_table_locker_state_v1 *state,
1572  struct PSI_table *table,
1573  enum PSI_table_lock_operation op,
1574  ulong flags,
1575  const char *src_file, uint src_line);
1576 
1581 typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
1582 
1590 typedef void (*start_file_open_wait_v1_t)
1591  (struct PSI_file_locker *locker, const char *src_file, uint src_line);
1592 
1599 typedef struct PSI_file* (*end_file_open_wait_v1_t)
1600  (struct PSI_file_locker *locker, void *result);
1601 
1607 typedef void (*end_file_open_wait_and_bind_to_descriptor_v1_t)
1608  (struct PSI_file_locker *locker, File file);
1609 
1618 typedef void (*start_file_wait_v1_t)
1619  (struct PSI_file_locker *locker, size_t count,
1620  const char *src_file, uint src_line);
1621 
1634 typedef void (*end_file_wait_v1_t)
1635  (struct PSI_file_locker *locker, size_t count);
1636 
1644 typedef void (*start_file_close_wait_v1_t)
1645  (struct PSI_file_locker *locker, const char *src_file, uint src_line);
1646 
1653 typedef void (*end_file_close_wait_v1_t)
1654  (struct PSI_file_locker *locker, int rc);
1655 
1662 typedef void (*start_stage_v1_t)
1663  (PSI_stage_key key, const char *src_file, int src_line);
1664 
1666 typedef void (*end_stage_v1_t) (void);
1667 
1675 typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t)
1676  (struct PSI_statement_locker_state_v1 *state,
1677  PSI_statement_key key, const void *charset);
1678 
1686 typedef struct PSI_statement_locker* (*refine_statement_v1_t)
1687  (struct PSI_statement_locker *locker,
1688  PSI_statement_key key);
1689 
1698 typedef void (*start_statement_v1_t)
1699  (struct PSI_statement_locker *locker,
1700  const char *db, uint db_length,
1701  const char *src_file, uint src_line);
1702 
1709 typedef void (*set_statement_text_v1_t)
1710  (struct PSI_statement_locker *locker,
1711  const char *text, uint text_len);
1712 
1718 typedef void (*set_statement_lock_time_t)
1719  (struct PSI_statement_locker *locker, ulonglong lock_time);
1720 
1726 typedef void (*set_statement_rows_sent_t)
1727  (struct PSI_statement_locker *locker, ulonglong count);
1728 
1734 typedef void (*set_statement_rows_examined_t)
1735  (struct PSI_statement_locker *locker, ulonglong count);
1736 
1742 typedef void (*inc_statement_created_tmp_disk_tables_t)
1743  (struct PSI_statement_locker *locker, ulong count);
1744 
1750 typedef void (*inc_statement_created_tmp_tables_t)
1751  (struct PSI_statement_locker *locker, ulong count);
1752 
1758 typedef void (*inc_statement_select_full_join_t)
1759  (struct PSI_statement_locker *locker, ulong count);
1760 
1766 typedef void (*inc_statement_select_full_range_join_t)
1767  (struct PSI_statement_locker *locker, ulong count);
1768 
1774 typedef void (*inc_statement_select_range_t)
1775  (struct PSI_statement_locker *locker, ulong count);
1776 
1782 typedef void (*inc_statement_select_range_check_t)
1783  (struct PSI_statement_locker *locker, ulong count);
1784 
1790 typedef void (*inc_statement_select_scan_t)
1791  (struct PSI_statement_locker *locker, ulong count);
1792 
1798 typedef void (*inc_statement_sort_merge_passes_t)
1799  (struct PSI_statement_locker *locker, ulong count);
1800 
1806 typedef void (*inc_statement_sort_range_t)
1807  (struct PSI_statement_locker *locker, ulong count);
1808 
1814 typedef void (*inc_statement_sort_rows_t)
1815  (struct PSI_statement_locker *locker, ulong count);
1816 
1822 typedef void (*inc_statement_sort_scan_t)
1823  (struct PSI_statement_locker *locker, ulong count);
1824 
1830 typedef void (*set_statement_no_index_used_t)
1831  (struct PSI_statement_locker *locker);
1832 
1838 typedef void (*set_statement_no_good_index_used_t)
1839  (struct PSI_statement_locker *locker);
1840 
1847 typedef void (*end_statement_v1_t)
1848  (struct PSI_statement_locker *locker, void *stmt_da);
1849 
1858 typedef struct PSI_socket_locker* (*start_socket_wait_v1_t)
1859  (struct PSI_socket_locker_state_v1 *state,
1860  struct PSI_socket *socket,
1861  enum PSI_socket_operation op,
1862  size_t count,
1863  const char *src_file, uint src_line);
1864 
1875 typedef void (*end_socket_wait_v1_t)
1876  (struct PSI_socket_locker *locker, size_t count);
1877 
1883 typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket,
1884  enum PSI_socket_state state);
1885 
1894 typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
1895  const my_socket *fd,
1896  const struct sockaddr *addr,
1897  socklen_t addr_len);
1898 
1903 typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
1904 
1905 typedef struct PSI_digest_locker * (*digest_start_v1_t)
1906  (struct PSI_statement_locker *locker);
1907 
1908 typedef struct PSI_digest_locker* (*digest_add_token_v1_t)
1909  (struct PSI_digest_locker *locker, uint token, struct OPAQUE_LEX_YYSTYPE *yylval);
1910 
1921 typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
1922  const void *from_cs);
1923 
1928 struct PSI_v1
1929 {
1931  register_mutex_v1_t register_mutex;
1933  register_rwlock_v1_t register_rwlock;
1935  register_cond_v1_t register_cond;
1937  register_thread_v1_t register_thread;
1939  register_file_v1_t register_file;
1941  register_stage_v1_t register_stage;
1943  register_statement_v1_t register_statement;
1945  register_socket_v1_t register_socket;
1947  init_mutex_v1_t init_mutex;
1949  destroy_mutex_v1_t destroy_mutex;
1951  init_rwlock_v1_t init_rwlock;
1953  destroy_rwlock_v1_t destroy_rwlock;
1955  init_cond_v1_t init_cond;
1957  destroy_cond_v1_t destroy_cond;
1959  init_socket_v1_t init_socket;
1961  destroy_socket_v1_t destroy_socket;
1963  get_table_share_v1_t get_table_share;
1965  release_table_share_v1_t release_table_share;
1967  drop_table_share_v1_t drop_table_share;
1969  open_table_v1_t open_table;
1971  unbind_table_v1_t unbind_table;
1973  rebind_table_v1_t rebind_table;
1975  close_table_v1_t close_table;
1977  create_file_v1_t create_file;
1979  spawn_thread_v1_t spawn_thread;
1981  new_thread_v1_t new_thread;
1983  set_thread_id_v1_t set_thread_id;
1985  get_thread_v1_t get_thread;
1987  set_thread_user_v1_t set_thread_user;
1989  set_thread_user_host_v1_t set_thread_user_host;
1991  set_thread_db_v1_t set_thread_db;
1993  set_thread_command_v1_t set_thread_command;
1995  set_thread_start_time_v1_t set_thread_start_time;
1997  set_thread_state_v1_t set_thread_state;
1999  set_thread_info_v1_t set_thread_info;
2001  set_thread_v1_t set_thread;
2003  delete_current_thread_v1_t delete_current_thread;
2005  delete_thread_v1_t delete_thread;
2007  get_thread_file_name_locker_v1_t get_thread_file_name_locker;
2009  get_thread_file_stream_locker_v1_t get_thread_file_stream_locker;
2011  get_thread_file_descriptor_locker_v1_t get_thread_file_descriptor_locker;
2013  unlock_mutex_v1_t unlock_mutex;
2015  unlock_rwlock_v1_t unlock_rwlock;
2017  signal_cond_v1_t signal_cond;
2019  broadcast_cond_v1_t broadcast_cond;
2021  start_idle_wait_v1_t start_idle_wait;
2023  end_idle_wait_v1_t end_idle_wait;
2025  start_mutex_wait_v1_t start_mutex_wait;
2027  end_mutex_wait_v1_t end_mutex_wait;
2029  start_rwlock_rdwait_v1_t start_rwlock_rdwait;
2031  end_rwlock_rdwait_v1_t end_rwlock_rdwait;
2033  start_rwlock_wrwait_v1_t start_rwlock_wrwait;
2035  end_rwlock_wrwait_v1_t end_rwlock_wrwait;
2037  start_cond_wait_v1_t start_cond_wait;
2039  end_cond_wait_v1_t end_cond_wait;
2041  start_table_io_wait_v1_t start_table_io_wait;
2043  end_table_io_wait_v1_t end_table_io_wait;
2045  start_table_lock_wait_v1_t start_table_lock_wait;
2047  end_table_lock_wait_v1_t end_table_lock_wait;
2049  start_file_open_wait_v1_t start_file_open_wait;
2051  end_file_open_wait_v1_t end_file_open_wait;
2053  end_file_open_wait_and_bind_to_descriptor_v1_t
2054  end_file_open_wait_and_bind_to_descriptor;
2056  start_file_wait_v1_t start_file_wait;
2058  end_file_wait_v1_t end_file_wait;
2060  start_file_close_wait_v1_t start_file_close_wait;
2062  end_file_close_wait_v1_t end_file_close_wait;
2064  start_stage_v1_t start_stage;
2066  end_stage_v1_t end_stage;
2068  get_thread_statement_locker_v1_t get_thread_statement_locker;
2070  refine_statement_v1_t refine_statement;
2072  start_statement_v1_t start_statement;
2074  set_statement_text_v1_t set_statement_text;
2076  set_statement_lock_time_t set_statement_lock_time;
2078  set_statement_rows_sent_t set_statement_rows_sent;
2080  set_statement_rows_examined_t set_statement_rows_examined;
2082  inc_statement_created_tmp_disk_tables_t inc_statement_created_tmp_disk_tables;
2084  inc_statement_created_tmp_tables_t inc_statement_created_tmp_tables;
2086  inc_statement_select_full_join_t inc_statement_select_full_join;
2088  inc_statement_select_full_range_join_t inc_statement_select_full_range_join;
2090  inc_statement_select_range_t inc_statement_select_range;
2092  inc_statement_select_range_check_t inc_statement_select_range_check;
2094  inc_statement_select_scan_t inc_statement_select_scan;
2096  inc_statement_sort_merge_passes_t inc_statement_sort_merge_passes;
2098  inc_statement_sort_range_t inc_statement_sort_range;
2100  inc_statement_sort_rows_t inc_statement_sort_rows;
2102  inc_statement_sort_scan_t inc_statement_sort_scan;
2104  set_statement_no_index_used_t set_statement_no_index_used;
2106  set_statement_no_good_index_used_t set_statement_no_good_index_used;
2108  end_statement_v1_t end_statement;
2110  start_socket_wait_v1_t start_socket_wait;
2112  end_socket_wait_v1_t end_socket_wait;
2114  set_socket_state_v1_t set_socket_state;
2116  set_socket_info_v1_t set_socket_info;
2118  set_socket_thread_owner_v1_t set_socket_thread_owner;
2120  digest_start_v1_t digest_start;
2122  digest_add_token_v1_t digest_add_token;
2124  set_thread_connect_attrs_v1_t set_thread_connect_attrs;
2125 };
2126 
2129 #endif /* HAVE_PSI_1 */
2130 
2131 #ifdef USE_PSI_2
2132 #define HAVE_PSI_2
2133 #endif
2134 
2135 #ifdef HAVE_PSI_2
2136 
2148 struct PSI_v2
2149 {
2151  int placeholder;
2152  /* ... extended interface ... */
2153 };
2154 
2156 struct PSI_mutex_info_v2
2157 {
2159  int placeholder;
2160 };
2161 
2163 struct PSI_rwlock_info_v2
2164 {
2166  int placeholder;
2167 };
2168 
2170 struct PSI_cond_info_v2
2171 {
2173  int placeholder;
2174 };
2175 
2177 struct PSI_thread_info_v2
2178 {
2180  int placeholder;
2181 };
2182 
2184 struct PSI_file_info_v2
2185 {
2187  int placeholder;
2188 };
2189 
2191 struct PSI_stage_info_v2
2192 {
2194  int placeholder;
2195 };
2196 
2198 struct PSI_statement_info_v2
2199 {
2201  int placeholder;
2202 };
2203 
2205 struct PSI_idle_locker_state_v2
2206 {
2208  int placeholder;
2209 };
2210 
2212 struct PSI_mutex_locker_state_v2
2213 {
2215  int placeholder;
2216 };
2217 
2219 struct PSI_rwlock_locker_state_v2
2220 {
2222  int placeholder;
2223 };
2224 
2226 struct PSI_cond_locker_state_v2
2227 {
2229  int placeholder;
2230 };
2231 
2233 struct PSI_file_locker_state_v2
2234 {
2236  int placeholder;
2237 };
2238 
2240 struct PSI_table_locker_state_v2
2241 {
2243  int placeholder;
2244 };
2245 
2247 struct PSI_statement_locker_state_v2
2248 {
2250  int placeholder;
2251 };
2252 
2254 struct PSI_socket_locker_state_v2
2255 {
2257  int placeholder;
2258 };
2259 
2262 #endif /* HAVE_PSI_2 */
2263 
2295 /* Export the required version */
2296 #ifdef USE_PSI_1
2297 typedef struct PSI_v1 PSI;
2298 typedef struct PSI_mutex_info_v1 PSI_mutex_info;
2299 typedef struct PSI_rwlock_info_v1 PSI_rwlock_info;
2300 typedef struct PSI_cond_info_v1 PSI_cond_info;
2301 typedef struct PSI_thread_info_v1 PSI_thread_info;
2302 typedef struct PSI_file_info_v1 PSI_file_info;
2303 typedef struct PSI_stage_info_v1 PSI_stage_info;
2304 typedef struct PSI_statement_info_v1 PSI_statement_info;
2305 typedef struct PSI_socket_info_v1 PSI_socket_info;
2306 typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
2307 typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
2308 typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
2309 typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
2310 typedef struct PSI_file_locker_state_v1 PSI_file_locker_state;
2311 typedef struct PSI_table_locker_state_v1 PSI_table_locker_state;
2312 typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
2313 typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
2314 #endif
2315 
2316 #ifdef USE_PSI_2
2317 typedef struct PSI_v2 PSI;
2318 typedef struct PSI_mutex_info_v2 PSI_mutex_info;
2319 typedef struct PSI_rwlock_info_v2 PSI_rwlock_info;
2320 typedef struct PSI_cond_info_v2 PSI_cond_info;
2321 typedef struct PSI_thread_info_v2 PSI_thread_info;
2322 typedef struct PSI_file_info_v2 PSI_file_info;
2323 typedef struct PSI_stage_info_v2 PSI_stage_info;
2324 typedef struct PSI_statement_info_v2 PSI_statement_info;
2325 typedef struct PSI_socket_info_v2 PSI_socket_info;
2326 typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
2327 typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
2328 typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
2329 typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
2330 typedef struct PSI_file_locker_state_v2 PSI_file_locker_state;
2331 typedef struct PSI_table_locker_state_v2 PSI_table_locker_state;
2332 typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
2333 typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
2334 #endif
2335 
2336 #else /* HAVE_PSI_INTERFACE */
2337 
2343 struct PSI_none
2344 {
2345  int opaque;
2346 };
2347 typedef struct PSI_none PSI;
2348 
2355 {
2357  unsigned int m_key;
2359  const char *m_name;
2361  int m_flags;
2362 };
2363 
2373 
2374 #endif /* HAVE_PSI_INTERFACE */
2375 
2376 extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
2377 
2378 /*
2379  Allow to override PSI_XXX_CALL at compile time
2380  with more efficient implementations, if available.
2381  If nothing better is available,
2382  make a dynamic call using the PSI_server function pointer.
2383 */
2384 
2385 #ifndef PSI_MUTEX_CALL
2386 #define PSI_MUTEX_CALL(M) PSI_DYNAMIC_CALL(M)
2387 #endif
2388 
2389 #ifndef PSI_RWLOCK_CALL
2390 #define PSI_RWLOCK_CALL(M) PSI_DYNAMIC_CALL(M)
2391 #endif
2392 
2393 #ifndef PSI_COND_CALL
2394 #define PSI_COND_CALL(M) PSI_DYNAMIC_CALL(M)
2395 #endif
2396 
2397 #ifndef PSI_THREAD_CALL
2398 #define PSI_THREAD_CALL(M) PSI_DYNAMIC_CALL(M)
2399 #endif
2400 
2401 #ifndef PSI_FILE_CALL
2402 #define PSI_FILE_CALL(M) PSI_DYNAMIC_CALL(M)
2403 #endif
2404 
2405 #ifndef PSI_SOCKET_CALL
2406 #define PSI_SOCKET_CALL(M) PSI_DYNAMIC_CALL(M)
2407 #endif
2408 
2409 #ifndef PSI_STAGE_CALL
2410 #define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M)
2411 #endif
2412 
2413 #ifndef PSI_STATEMENT_CALL
2414 #define PSI_STATEMENT_CALL(M) PSI_DYNAMIC_CALL(M)
2415 #endif
2416 
2417 #ifndef PSI_TABLE_CALL
2418 #define PSI_TABLE_CALL(M) PSI_DYNAMIC_CALL(M)
2419 #endif
2420 
2421 #ifndef PSI_IDLE_CALL
2422 #define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M)
2423 #endif
2424 
2425 #define PSI_DYNAMIC_CALL(M) PSI_server->M
2426 
2429 C_MODE_END
2430 #endif /* MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H */
2431