This file is indexed.

/usr/share/mysql/mysql_performance_tables.sql is in mariadb-server-5.5 5.5.36-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
--
-- PERFORMANCE SCHEMA INSTALLATION
-- Note that this script is also reused by mysql_upgrade,
-- so we have to be very careful here to not destroy any
-- existing database named 'performance_schema' if it
-- can contain user data.
-- In case of downgrade, it's ok to drop unknown tables
-- from a future version, as long as they belong to the
-- performance schema engine.
--

set @have_old_pfs= (select count(*) from information_schema.schemata where schema_name='performance_schema');

SET @l1="SET @broken_tables = (select count(*) from information_schema.tables";
SET @l2=" where engine != \'PERFORMANCE_SCHEMA\' and table_schema=\'performance_schema\')";
SET @cmd=concat(@l1,@l2);

-- Work around for bug#49542
SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_tables = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @l1="SET @broken_views = (select count(*) from information_schema.views";
SET @l2=" where table_schema='performance_schema')";
SET @cmd=concat(@l1,@l2);

-- Work around for bug#49542
SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_views = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @broken_routines = (select count(*) from mysql.proc where db='performance_schema');

SET @broken_events = (select count(*) from mysql.event where db='performance_schema');

SET @broken_pfs= (select @broken_tables + @broken_views + @broken_routines + @broken_events);

--
-- The performance schema database.
-- Only drop and create the database if this is safe (no broken_pfs).
-- This database is created, even in --without-perfschema builds,
-- so that the database name is always reserved by the MySQL implementation.
-- This script must be executed AFTER we have fixed the proc table, to
-- avoid errors with old proc tables.
--

SET @cmd= "DROP DATABASE IF EXISTS performance_schema";

SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @cmd= "CREATE DATABASE performance_schema character set utf8";

SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- From this point, only create the performance schema tables
-- if the server is build with performance schema
--

set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO');

--
-- TABLE COND_INSTANCES
--

SET @l1="CREATE TABLE performance_schema.cond_instances(";
SET @l2="NAME VARCHAR(128) not null,";
SET @l3="OBJECT_INSTANCE_BEGIN BIGINT not null";
SET @l4=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE EVENTS_WAITS_CURRENT
--

SET @l1="CREATE TABLE performance_schema.events_waits_current(";
SET @l2="THREAD_ID INTEGER not null,";
SET @l3="EVENT_ID BIGINT unsigned not null,";
SET @l4="EVENT_NAME VARCHAR(128) not null,";
SET @l5="SOURCE VARCHAR(64),";
SET @l6="TIMER_START BIGINT unsigned,";
SET @l7="TIMER_END BIGINT unsigned,";
SET @l8="TIMER_WAIT BIGINT unsigned,";
SET @l9="SPINS INTEGER unsigned,";
SET @l10="OBJECT_SCHEMA VARCHAR(64),";
SET @l11="OBJECT_NAME VARCHAR(512),";
SET @l12="OBJECT_TYPE VARCHAR(64),";
SET @l13="OBJECT_INSTANCE_BEGIN BIGINT not null,";
SET @l14="NESTING_EVENT_ID BIGINT unsigned,";
SET @l15="OPERATION VARCHAR(16) not null,";
SET @l16="NUMBER_OF_BYTES BIGINT unsigned,";
SET @l17="FLAGS INTEGER unsigned";
SET @l18=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9,@l10,@l11,@l12,@l13,@l14,@l15,@l16,@l17,@l18);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE EVENTS_WAITS_HISTORY
--

SET @l1="CREATE TABLE performance_schema.events_waits_history(";
-- lines 2 to 18 are unchanged from EVENTS_WAITS_CURRENT

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9,@l10,@l11,@l12,@l13,@l14,@l15,@l16,@l17,@l18);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE EVENTS_WAITS_HISTORY_LONG
--

SET @l1="CREATE TABLE performance_schema.events_waits_history_long(";
-- lines 2 to 18 are unchanged from EVENTS_WAITS_CURRENT

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9,@l10,@l11,@l12,@l13,@l14,@l15,@l16,@l17,@l18);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE EVENTS_WAITS_SUMMARY_BY_INSTANCE
--

SET @l1="CREATE TABLE performance_schema.events_waits_summary_by_instance(";
SET @l2="EVENT_NAME VARCHAR(128) not null,";
SET @l3="OBJECT_INSTANCE_BEGIN BIGINT not null,";
SET @l4="COUNT_STAR BIGINT unsigned not null,";
SET @l5="SUM_TIMER_WAIT BIGINT unsigned not null,";
SET @l6="MIN_TIMER_WAIT BIGINT unsigned not null,";
SET @l7="AVG_TIMER_WAIT BIGINT unsigned not null,";
SET @l8="MAX_TIMER_WAIT BIGINT unsigned not null";
SET @l9=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME
--

SET @l1="CREATE TABLE performance_schema.events_waits_summary_by_thread_by_event_name(";
SET @l2="THREAD_ID INTEGER not null,";
SET @l3="EVENT_NAME VARCHAR(128) not null,";
SET @l4="COUNT_STAR BIGINT unsigned not null,";
SET @l5="SUM_TIMER_WAIT BIGINT unsigned not null,";
SET @l6="MIN_TIMER_WAIT BIGINT unsigned not null,";
SET @l7="AVG_TIMER_WAIT BIGINT unsigned not null,";
SET @l8="MAX_TIMER_WAIT BIGINT unsigned not null";
SET @l9=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8,@l9);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME
--

SET @l1="CREATE TABLE performance_schema.events_waits_summary_global_by_event_name(";
SET @l2="EVENT_NAME VARCHAR(128) not null,";
SET @l3="COUNT_STAR BIGINT unsigned not null,";
SET @l4="SUM_TIMER_WAIT BIGINT unsigned not null,";
SET @l5="MIN_TIMER_WAIT BIGINT unsigned not null,";
SET @l6="AVG_TIMER_WAIT BIGINT unsigned not null,";
SET @l7="MAX_TIMER_WAIT BIGINT unsigned not null";
SET @l8=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE FILE_INSTANCES
--

SET @l1="CREATE TABLE performance_schema.file_instances(";
SET @l2="FILE_NAME VARCHAR(512) not null,";
SET @l3="EVENT_NAME VARCHAR(128) not null,";
SET @l4="OPEN_COUNT INTEGER unsigned not null";
SET @l5=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE FILE_SUMMARY_BY_EVENT_NAME
--

SET @l1="CREATE TABLE performance_schema.file_summary_by_event_name(";
SET @l2="EVENT_NAME VARCHAR(128) not null,";
SET @l3="COUNT_READ BIGINT unsigned not null,";
SET @l4="COUNT_WRITE BIGINT unsigned not null,";
SET @l5="SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,";
SET @l6="SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null";
SET @l7=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE FILE_SUMMARY_BY_INSTANCE
--

SET @l1="CREATE TABLE performance_schema.file_summary_by_instance(";
SET @l2="FILE_NAME VARCHAR(512) not null,";
SET @l3="EVENT_NAME VARCHAR(128) not null,";
SET @l4="COUNT_READ BIGINT unsigned not null,";
SET @l5="COUNT_WRITE BIGINT unsigned not null,";
SET @l6="SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,";
SET @l7="SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null";
SET @l8=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6,@l7,@l8);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE MUTEX_INSTANCES
--

SET @l1="CREATE TABLE performance_schema.mutex_instances(";
SET @l2="NAME VARCHAR(128) not null,";
SET @l3="OBJECT_INSTANCE_BEGIN BIGINT not null,";
SET @l4="LOCKED_BY_THREAD_ID INTEGER";
SET @l5=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE PERFORMANCE_TIMERS
--

SET @l1="CREATE TABLE performance_schema.performance_timers(";
SET @l2="TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null,";
SET @l3="TIMER_FREQUENCY BIGINT,";
SET @l4="TIMER_RESOLUTION BIGINT,";
SET @l5="TIMER_OVERHEAD BIGINT";
SET @l6=") ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE RWLOCK_INSTANCES
--

SET @l1="CREATE TABLE performance_schema.rwlock_instances(";
SET @l2="NAME VARCHAR(128) not null,";
SET @l3="OBJECT_INSTANCE_BEGIN BIGINT not null,";
SET @l4="WRITE_LOCKED_BY_THREAD_ID INTEGER,";
SET @l5="READ_LOCKED_BY_COUNT INTEGER unsigned not null";
SET @l6=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE SETUP_CONSUMERS
--

SET @l1="CREATE TABLE performance_schema.setup_consumers(";
SET @l2="NAME VARCHAR(64) not null,";
SET @l3="ENABLED ENUM ('YES', 'NO') not null";
SET @l4=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE SETUP_INSTRUMENTS
--

SET @l1="CREATE TABLE performance_schema.setup_instruments(";
SET @l2="NAME VARCHAR(128) not null,";
SET @l3="ENABLED ENUM ('YES', 'NO') not null,";
SET @l4="TIMED ENUM ('YES', 'NO') not null";
SET @l5=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE SETUP_TIMERS
--

SET @l1="CREATE TABLE performance_schema.setup_timers(";
SET @l2="NAME VARCHAR(64) not null,";
SET @l3="TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null";
SET @l4=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- TABLE THREADS
--

SET @l1="CREATE TABLE performance_schema.threads(";
SET @l2="THREAD_ID INTEGER not null,";
SET @l3="PROCESSLIST_ID INTEGER,";
SET @l4="NAME VARCHAR(128) not null";
SET @l5=")ENGINE=PERFORMANCE_SCHEMA;";

SET @cmd=concat(@l1,@l2,@l3,@l4,@l5);

SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

--
-- Unlike 'performance_schema', the 'mysql' database is reserved already,
-- so no user procedure is supposed to be there.
--
-- NOTE: until upgrade is finished, stored routines are not available,
-- because system tables (e.g. mysql.proc) might be not usable.
--
drop procedure if exists mysql.die;
create procedure mysql.die() signal sqlstate 'HY000' set message_text='Unexpected content found in the performance_schema database.';

--
-- For broken upgrades, SIGNAL the error
--

SET @cmd="call mysql.die()";

SET @str = IF(@broken_pfs > 0, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

drop procedure mysql.die;