MySQL  8.0.16
Source Code Documentation
psi_table_bits.h
Go to the documentation of this file.
1 /* Copyright (c) 2008, 2019, 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 COMPONENTS_SERVICES_PSI_TABLE_BITS_H
24 #define COMPONENTS_SERVICES_PSI_TABLE_BITS_H
25 
26 /**
27  @file
28  Performance schema instrumentation interface.
29 
30  @defgroup psi_abi_table Table Instrumentation (ABI)
31  @ingroup psi_abi
32  @{
33 */
34 
35 struct TABLE_SHARE;
36 
37 /**
38  Interface for an instrumented table operation.
39  This is an opaque structure.
40 */
41 struct PSI_table_locker;
43 
44 /** IO operation performed on an instrumented table. */
46  /** Row fetch. */
48  /** Row write. */
50  /** Row update. */
52  /** Row delete. */
54 };
56 
57 /**
58  State data storage for @c start_table_io_wait_v1_t,
59  @c start_table_lock_wait_v1_t.
60  This structure provide temporary storage to a table locker.
61  The content of this structure is considered opaque,
62  the fields are only hints of what an implementation
63  of the psi interface can use.
64  This memory is provided by the instrumented code for performance reasons.
65  @sa start_table_io_wait_v1_t
66  @sa start_table_lock_wait_v1_t
67 */
69  /** Internal state. */
70  unsigned int m_flags;
71  /** Current io operation. */
73  /** Current table handle. */
74  struct PSI_table *m_table;
75  /** Current table share. */
77  /** Current thread. */
79  /** Timer start. */
80  unsigned long long m_timer_start;
81  /** Timer function. */
82  unsigned long long (*m_timer)(void);
83  /** Internal data. */
84  void *m_wait;
85  /**
86  Implementation specific.
87  For table io, the table io index.
88  For table lock, the lock type.
89  */
90  unsigned int m_index;
91 };
93 
94 /**
95  Interface for an instrumented table share.
96  This is an opaque structure.
97 */
98 struct PSI_table_share;
100 
101 /**
102  Interface for an instrumented table handle.
103  This is an opaque structure.
104 */
105 struct PSI_table;
106 typedef struct PSI_table PSI_table;
107 
108 /** Lock operation performed on an instrumented table. */
110  /** Table lock, in the server layer. */
112  /** Table lock, in the storage engine layer. */
114 };
116 
117 /**
118  Acquire a table share instrumentation.
119  @param temporary True for temporary tables
120  @param share The SQL layer table share
121  @return a table share instrumentation, or NULL
122 */
123 typedef struct PSI_table_share *(*get_table_share_v1_t)(
124  bool temporary, struct TABLE_SHARE *share);
125 
126 /**
127  Release a table share.
128  @param share the table share to release
129 */
130 typedef void (*release_table_share_v1_t)(struct PSI_table_share *share);
131 
132 /**
133  Drop a table share.
134  @param temporary True for temporary tables
135  @param schema_name the table schema name
136  @param schema_name_length the table schema name length
137  @param table_name the table name
138  @param table_name_length the table name length
139 */
140 typedef void (*drop_table_share_v1_t)(bool temporary, const char *schema_name,
141  int schema_name_length,
142  const char *table_name,
143  int table_name_length);
144 
145 /**
146  Open an instrumentation table handle.
147  @param share the table to open
148  @param identity table handle identity
149  @return a table handle, or NULL
150 */
151 typedef struct PSI_table *(*open_table_v1_t)(struct PSI_table_share *share,
152  const void *identity);
153 
154 /**
155  Unbind a table handle from the current thread.
156  This operation happens when an opened table is added to the open table cache.
157  @param table the table to unbind
158 */
159 typedef void (*unbind_table_v1_t)(struct PSI_table *table);
160 
161 /**
162  Rebind a table handle to the current thread.
163  This operation happens when a table from the open table cache
164  is reused for a thread.
165  @param table the table to unbind
166 */
167 typedef PSI_table *(*rebind_table_v1_t)(PSI_table_share *share,
168  const void *identity, PSI_table *table);
169 
170 /**
171  Close an instrumentation table handle.
172  Note that the table handle is invalid after this call.
173  @param table the table handle to close
174 */
175 typedef void (*close_table_v1_t)(struct TABLE_SHARE *server_share,
176  struct PSI_table *table);
177 
178 /**
179  Record a table instrumentation io wait start event.
180  @param state data storage for the locker
181  @param table the instrumented table
182  @param op the operation to perform
183  @param index the operation index
184  @param src_file the source file name
185  @param src_line the source line number
186 */
187 typedef struct PSI_table_locker *(*start_table_io_wait_v1_t)(
188  struct PSI_table_locker_state *state, struct PSI_table *table,
189  enum PSI_table_io_operation op, unsigned int index, const char *src_file,
190  unsigned int src_line);
191 
192 /**
193  Record a table instrumentation io wait end event.
194  @param locker a table locker for the running thread
195  @param numrows the number of rows involved in io
196 */
197 typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker,
198  unsigned long long numrows);
199 
200 /**
201  Record a table instrumentation lock wait start event.
202  @param state data storage for the locker
203  @param table the instrumented table
204  @param op the operation to perform
205  @param flags the operation flags
206  @param src_file the source file name
207  @param src_line the source line number
208 */
209 typedef struct PSI_table_locker *(*start_table_lock_wait_v1_t)(
210  struct PSI_table_locker_state *state, struct PSI_table *table,
211  enum PSI_table_lock_operation op, unsigned long flags, const char *src_file,
212  unsigned int src_line);
213 
214 /**
215  Record a table instrumentation lock wait end event.
216  @param locker a table locker for the running thread
217 */
218 typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
219 
220 /**
221  Record a table unlock event.
222  @param table instrumentation for the table being unlocked
223 */
224 typedef void (*unlock_table_v1_t)(struct PSI_table *table);
225 
226 /** @} (end of group psi_abi_table) */
227 
228 #endif /* COMPONENTS_SERVICES_PSI_TABLE_BITS_H */
Row delete.
Definition: psi_table_bits.h:53
void(* unbind_table_v1_t)(struct PSI_table *table)
Unbind a table handle from the current thread.
Definition: psi_table_bits.h:159
void * m_wait
Internal data.
Definition: psi_table_bits.h:84
This structure is shared between different table objects.
Definition: table.h:646
Table lock, in the storage engine layer.
Definition: psi_table_bits.h:113
void(* drop_table_share_v1_t)(bool temporary, const char *schema_name, int schema_name_length, const char *table_name, int table_name_length)
Drop a table share.
Definition: psi_table_bits.h:140
State data storage for start_table_io_wait_v1_t, start_table_lock_wait_v1_t.
Definition: psi_table_bits.h:68
PSI_table_io_operation
IO operation performed on an instrumented table.
Definition: psi_table_bits.h:45
Row update.
Definition: psi_table_bits.h:51
unsigned long long(* m_timer)(void)
Timer function.
Definition: psi_table_bits.h:82
unsigned long long m_timer_start
Timer start.
Definition: psi_table_bits.h:80
unsigned int m_flags
Internal state.
Definition: psi_table_bits.h:70
Row write.
Definition: psi_table_bits.h:49
void(* end_table_io_wait_v1_t)(struct PSI_table_locker *locker, unsigned long long numrows)
Record a table instrumentation io wait end event.
Definition: psi_table_bits.h:197
char * index(const char *, int c)
Definition: mysql.cc:2840
PSI_table_lock_operation
Lock operation performed on an instrumented table.
Definition: psi_table_bits.h:109
void(* close_table_v1_t)(struct TABLE_SHARE *server_share, struct PSI_table *table)
Close an instrumentation table handle.
Definition: psi_table_bits.h:175
Row fetch.
Definition: psi_table_bits.h:47
struct PSI_table_locker PSI_table_locker
Definition: psi_table_bits.h:42
enum PSI_table_io_operation m_io_operation
Current io operation.
Definition: psi_table_bits.h:72
struct PSI_table * m_table
Current table handle.
Definition: psi_table_bits.h:74
struct PSI_table_share PSI_table_share
Definition: psi_table_bits.h:99
struct PSI_thread * m_thread
Current thread.
Definition: psi_table_bits.h:78
void(* unlock_table_v1_t)(struct PSI_table *table)
Record a table unlock event.
Definition: psi_table_bits.h:224
Table lock, in the server layer.
Definition: psi_table_bits.h:111
unsigned int m_index
Implementation specific.
Definition: psi_table_bits.h:90
struct PSI_table_share * m_table_share
Current table share.
Definition: psi_table_bits.h:76
struct PSI_table PSI_table
Definition: psi_table_bits.h:106
static int flags[50]
Definition: hp_test1.cc:39
void(* release_table_share_v1_t)(struct PSI_table_share *share)
Release a table share.
Definition: psi_table_bits.h:130
struct PSI_thread PSI_thread
Definition: psi_thread_bits.h:71
void(* end_table_lock_wait_v1_t)(struct PSI_table_locker *locker)
Record a table instrumentation lock wait end event.
Definition: psi_table_bits.h:218
const char * table_name
Definition: rules_table_service.cc:55