1 /* Copyright (c) 2008, 2020, 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, version 2.0,
5   as published by the Free Software Foundation.
6 
7   This program is also distributed with certain software (including
8   but not limited to OpenSSL) that is licensed under separate terms,
9   as designated in a particular file or component or in included license
10   documentation.  The authors of MySQL hereby grant you an additional
11   permission to link the program and your derivative works with the
12   separately licensed software that they have included with MySQL.
13 
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License, version 2.0, for more details.
18 
19   You should have received a copy of the GNU General Public License
20   along with this program; if not, write to the Free Software
21   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
22 
23 #ifndef PFS_H
24 #define PFS_H
25 
26 /**
27   @file storage/perfschema/pfs.h
28   Performance schema instrumentation (declarations).
29 */
30 
31 #define HAVE_PSI_1
32 
33 #include <mysql/psi/psi_base.h>
34 #include <mysql/psi/psi_data_lock.h>
35 
36 #include "my_thread.h"
37 #include "my_thread_local.h"
38 
39 #include <mysql/components/service_implementation.h>
40 
41 struct PFS_thread;
42 class PFS_table_context;
43 
44 /**
45   Entry point to the performance schema implementation.
46   This singleton is used to discover the performance schema services.
47 */
48 extern struct PSI_cond_bootstrap pfs_cond_bootstrap;
49 extern struct PSI_data_lock_bootstrap pfs_data_lock_bootstrap;
50 extern struct PSI_error_bootstrap pfs_error_bootstrap;
51 extern struct PSI_file_bootstrap pfs_file_bootstrap;
52 extern struct PSI_idle_bootstrap pfs_idle_bootstrap;
53 extern struct PSI_mdl_bootstrap pfs_mdl_bootstrap;
54 extern struct PSI_memory_bootstrap pfs_memory_bootstrap;
55 extern struct PSI_mutex_bootstrap pfs_mutex_bootstrap;
56 extern struct PSI_rwlock_bootstrap pfs_rwlock_bootstrap;
57 extern struct PSI_socket_bootstrap pfs_socket_bootstrap;
58 extern struct PSI_stage_bootstrap pfs_stage_bootstrap;
59 extern struct PSI_statement_bootstrap pfs_statement_bootstrap;
60 extern struct PSI_system_bootstrap pfs_system_bootstrap;
61 extern struct PSI_table_bootstrap pfs_table_bootstrap;
62 extern struct PSI_thread_bootstrap pfs_thread_bootstrap;
63 extern struct PSI_transaction_bootstrap pfs_transaction_bootstrap;
64 extern struct PSI_tls_channel_bootstrap pfs_tls_channel_bootstrap;
65 
66 /** Performance schema Thread Local Storage.  */
67 extern thread_local PFS_thread *THR_PFS;
68 
69 /**
70   Performance schema Thread Local Storage keys; indexes into THR_PFS_contexts.
71 */
72 enum THR_PFS_key {
73   THR_PFS_SV,   // session_variables
74   THR_PFS_VG,   // global_variables
75   THR_PFS_VBT,  // variables_by_thread
76   THR_PFS_SG,   // global_status
77   THR_PFS_SS,   // session_status
78   THR_PFS_SBT,  // status_by_thread
79   THR_PFS_SBU,  // status_by_user
80   THR_PFS_SBH,  // status_by_host
81   THR_PFS_NUM_KEYS
82 };
83 
84 /* Only Innodb so far */
85 #define COUNT_DATA_LOCK_ENGINES 1
86 
87 extern PSI_engine_data_lock_inspector *g_data_lock_inspector[];
88 extern unsigned int g_data_lock_inspector_count;
89 
90 #endif
91