1-- Copyright (c) 2007, 2018, 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--
24-- The system tables of MySQL Server
25--
26
27set sql_mode='';
28set default_storage_engine=myisam;
29
30CREATE TABLE IF NOT EXISTS db (   Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(32) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges';
31
32-- Remember for later if db table already existed
33set @had_db_table= @@warning_count != 0;
34
35CREATE TABLE IF NOT EXISTS user (   Host char(60) binary DEFAULT '' NOT NULL, User char(32) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tablespace_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0  NOT NULL, max_updates int(11) unsigned DEFAULT 0  NOT NULL, max_connections int(11) unsigned DEFAULT 0  NOT NULL, max_user_connections int(11) unsigned DEFAULT 0  NOT NULL, plugin char(64) DEFAULT 'mysql_native_password' NOT NULL, authentication_string TEXT, password_expired ENUM('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, password_last_changed timestamp NULL DEFAULT NULL, password_lifetime smallint unsigned NULL DEFAULT NULL, account_locked ENUM('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges';
36
37-- Remember for later if user table already existed
38set @had_user_table= @@warning_count != 0;
39
40
41CREATE TABLE IF NOT EXISTS func (  name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin   comment='User defined functions';
42
43
44CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl varchar(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=InnoDB STATS_PERSISTENT=0 CHARACTER SET utf8 COLLATE utf8_general_ci comment='MySQL plugins';
45
46
47CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) engine=InnoDB STATS_PERSISTENT=0 CHARACTER SET utf8 comment='MySQL Foreign Servers table';
48
49
50CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(32) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(93) DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin   comment='Table privileges';
51
52CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(32) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin   comment='Column privileges';
53
54
55CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url text not null, primary key (help_topic_id), unique index (name) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8 comment='help topics';
56
57
58CREATE TABLE IF NOT EXISTS help_category ( help_category_id smallint unsigned not null, name  char(64) not null, parent_category_id smallint unsigned null, url text not null, primary key (help_category_id), unique index (name) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8 comment='help categories';
59
60
61CREATE TABLE IF NOT EXISTS help_relation ( help_topic_id int unsigned not null, help_keyword_id  int unsigned not null, primary key (help_keyword_id, help_topic_id) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8 comment='keyword-topic relation';
62
63
64CREATE TABLE IF NOT EXISTS help_keyword (   help_keyword_id  int unsigned not null, name char(64) not null, primary key (help_keyword_id), unique index (name) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8 comment='help keywords';
65
66
67CREATE TABLE IF NOT EXISTS time_zone_name (   Name char(64) NOT NULL, Time_zone_id int unsigned NOT NULL, PRIMARY KEY Name (Name) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8   comment='Time zone names';
68
69
70CREATE TABLE IF NOT EXISTS time_zone (   Time_zone_id int unsigned NOT NULL auto_increment, Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY TzId (Time_zone_id) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8   comment='Time zones';
71
72
73CREATE TABLE IF NOT EXISTS time_zone_transition (   Time_zone_id int unsigned NOT NULL, Transition_time bigint signed NOT NULL, Transition_type_id int unsigned NOT NULL, PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8   comment='Time zone transitions';
74
75
76CREATE TABLE IF NOT EXISTS time_zone_transition_type (   Time_zone_id int unsigned NOT NULL, Transition_type_id int unsigned NOT NULL, Offset int signed DEFAULT 0 NOT NULL, Is_DST tinyint unsigned DEFAULT 0 NOT NULL, Abbreviation char(8) DEFAULT '' NOT NULL, PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8   comment='Time zone transition types';
77
78
79CREATE TABLE IF NOT EXISTS time_zone_leap_second (   Transition_time bigint signed NOT NULL, Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8   comment='Leap seconds information for time zones';
80
81
82CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(93) collate utf8_bin DEFAULT '' NOT NULL, created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment text collate utf8_bin NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
83
84CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(32) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(93) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin   comment='Procedure privileges';
85
86-- Create general_log
87CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host MEDIUMTEXT NOT NULL, thread_id BIGINT(21) UNSIGNED NOT NULL, server_id INTEGER UNSIGNED NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMBLOB NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log";
88
89-- Create slow_log
90CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host MEDIUMTEXT NOT NULL, query_time TIME(6) NOT NULL, lock_time TIME(6) NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMBLOB NOT NULL, thread_id BIGINT(21) UNSIGNED NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log";
91
92CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(93) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modified TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode  set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator INTEGER UNSIGNED NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
93
94
95CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts INT UNSIGNED NOT NULL, updates INT UNSIGNED NOT NULL, deletes INT UNSIGNED NOT NULL, schemaops INT UNSIGNED NOT NULL, orig_server_id INT UNSIGNED NOT NULL, orig_epoch BIGINT UNSIGNED NOT NULL, gci INT UNSIGNED NOT NULL, next_position BIGINT UNSIGNED NOT NULL, next_file VARCHAR(255) NOT NULL, PRIMARY KEY(epoch, orig_server_id, orig_epoch)) ENGINE=MYISAM;
96
97SET @sql_mode_orig=@@SESSION.sql_mode;
98SET SESSION sql_mode='NO_ENGINE_SUBSTITUTION';
99
100SET @create_innodb_table_stats="CREATE TABLE IF NOT EXISTS innodb_table_stats (
101	database_name			VARCHAR(64) NOT NULL,
102	table_name			VARCHAR(199) NOT NULL,
103	last_update			TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
104	n_rows				BIGINT UNSIGNED NOT NULL,
105	clustered_index_size		BIGINT UNSIGNED NOT NULL,
106	sum_of_other_index_sizes	BIGINT UNSIGNED NOT NULL,
107	PRIMARY KEY (database_name, table_name)
108) ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0";
109
110SET @create_innodb_index_stats="CREATE TABLE IF NOT EXISTS innodb_index_stats (
111	database_name			VARCHAR(64) NOT NULL,
112	table_name			VARCHAR(199) NOT NULL,
113	index_name			VARCHAR(64) NOT NULL,
114	last_update			TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
115	/* there are at least:
116	stat_name='size'
117	stat_name='n_leaf_pages'
118	stat_name='n_diff_pfx%' */
119	stat_name			VARCHAR(64) NOT NULL,
120	stat_value			BIGINT UNSIGNED NOT NULL,
121	sample_size			BIGINT UNSIGNED,
122	stat_description		VARCHAR(1024) NOT NULL,
123	PRIMARY KEY (database_name, table_name, index_name, stat_name)
124) ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0";
125
126set @have_innodb= (select count(engine) from information_schema.engines where engine='INNODB' and support != 'NO');
127
128SET @str=IF(@have_innodb <> 0, @create_innodb_table_stats, "SET @dummy = 0");
129PREPARE stmt FROM @str;
130EXECUTE stmt;
131DROP PREPARE stmt;
132
133SET @str=IF(@have_innodb <> 0, @create_innodb_index_stats, "SET @dummy = 0");
134PREPARE stmt FROM @str;
135EXECUTE stmt;
136DROP PREPARE stmt;
137
138SET SESSION sql_mode=@sql_mode_orig;
139
140SET @cmd="CREATE TABLE IF NOT EXISTS slave_relay_log_info (
141  Number_of_lines INTEGER UNSIGNED NOT NULL COMMENT 'Number of lines in the file or rows in the table. Used to version table definitions.',
142  Relay_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the current relay log file.',
143  Relay_log_pos BIGINT UNSIGNED NOT NULL COMMENT 'The relay log position of the last executed event.',
144  Master_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log file from which the events in the relay log file were read.',
145  Master_log_pos BIGINT UNSIGNED NOT NULL COMMENT 'The master log position of the last executed event.',
146  Sql_delay INTEGER NOT NULL COMMENT 'The number of seconds that the slave must lag behind the master.',
147  Number_of_workers INTEGER UNSIGNED NOT NULL,
148  Id INTEGER UNSIGNED NOT NULL COMMENT 'Internal Id that uniquely identifies this record.',
149  Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication',
150  PRIMARY KEY(Channel_name)) DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT 'Relay Log Information'";
151
152SET @str=IF(@have_innodb <> 0, CONCAT(@cmd, ' ENGINE= INNODB;'), CONCAT(@cmd, ' ENGINE= MYISAM;'));
153PREPARE stmt FROM @str;
154EXECUTE stmt;
155DROP PREPARE stmt;
156
157SET @cmd= "CREATE TABLE IF NOT EXISTS slave_master_info (
158  Number_of_lines INTEGER UNSIGNED NOT NULL COMMENT 'Number of lines in the file.',
159  Master_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log currently being read from the master.',
160  Master_log_pos BIGINT UNSIGNED NOT NULL COMMENT 'The master log position of the last read event.',
161  Host CHAR(64) CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The host name of the master.',
162  User_name TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',
163  User_password TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',
164  Port INTEGER UNSIGNED NOT NULL COMMENT 'The network port used to connect to the master.',
165  Connect_retry INTEGER UNSIGNED NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',
166  Enabled_ssl BOOLEAN NOT NULL COMMENT 'Indicates whether the server supports SSL connections.',
167  Ssl_ca TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',
168  Ssl_capath TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',
169  Ssl_cert TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',
170  Ssl_cipher TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',
171  Ssl_key TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',
172  Ssl_verify_server_cert BOOLEAN NOT NULL COMMENT 'Whether to verify the server certificate.',
173  Heartbeat FLOAT NOT NULL COMMENT '',
174  Bind TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',
175  Ignored_server_ids TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored, followed by the actual server IDs',
176  Uuid TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',
177  Retry_count BIGINT UNSIGNED NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.',
178  Ssl_crl TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',
179  Ssl_crlpath TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',
180  Enabled_auto_position BOOLEAN NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',
181  Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication',
182  Tls_version TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Tls version',
183  PRIMARY KEY(Channel_name)) DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT 'Master Information'";
184
185SET @str=IF(@have_innodb <> 0, CONCAT(@cmd, ' ENGINE= INNODB;'), CONCAT(@cmd, ' ENGINE= MYISAM;'));
186PREPARE stmt FROM @str;
187EXECUTE stmt;
188DROP PREPARE stmt;
189
190SET @cmd= "CREATE TABLE IF NOT EXISTS slave_worker_info (
191  Id INTEGER UNSIGNED NOT NULL,
192  Relay_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
193  Relay_log_pos BIGINT UNSIGNED NOT NULL,
194  Master_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
195  Master_log_pos BIGINT UNSIGNED NOT NULL,
196  Checkpoint_relay_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
197  Checkpoint_relay_log_pos BIGINT UNSIGNED NOT NULL,
198  Checkpoint_master_log_name TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
199  Checkpoint_master_log_pos BIGINT UNSIGNED NOT NULL,
200  Checkpoint_seqno INT UNSIGNED NOT NULL,
201  Checkpoint_group_size INTEGER UNSIGNED NOT NULL,
202  Checkpoint_group_bitmap BLOB NOT NULL,
203  Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication',
204  PRIMARY KEY(Channel_name, Id)) DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT 'Worker Information'";
205
206SET @str=IF(@have_innodb <> 0, CONCAT(@cmd, ' ENGINE= INNODB;'), CONCAT(@cmd, ' ENGINE= MYISAM;'));
207PREPARE stmt FROM @str;
208EXECUTE stmt;
209DROP PREPARE stmt;
210
211SET @cmd= "CREATE TABLE IF NOT EXISTS gtid_executed (
212    source_uuid CHAR(36) NOT NULL COMMENT 'uuid of the source where the transaction was originally executed.',
213    interval_start BIGINT NOT NULL COMMENT 'First number of interval.',
214    interval_end BIGINT NOT NULL COMMENT 'Last number of interval.',
215    PRIMARY KEY(source_uuid, interval_start))";
216
217SET @str=IF(@have_innodb <> 0, CONCAT(@cmd, ' ENGINE= INNODB;'), CONCAT(@cmd, ' ENGINE= MYISAM;'));
218PREPARE stmt FROM @str;
219EXECUTE stmt;
220DROP PREPARE stmt;
221
222--
223-- Optimizer Cost Model configuration
224--
225
226-- Server cost constants
227
228CREATE TABLE IF NOT EXISTS server_cost (
229  cost_name   VARCHAR(64) NOT NULL,
230  cost_value  FLOAT DEFAULT NULL,
231  last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
232  comment     VARCHAR(1024) DEFAULT NULL,
233  PRIMARY KEY (cost_name)
234) ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_general_ci STATS_PERSISTENT=0;
235
236INSERT IGNORE INTO server_cost(cost_name) VALUES
237  ("row_evaluate_cost"), ("key_compare_cost"),
238  ("memory_temptable_create_cost"), ("memory_temptable_row_cost"),
239  ("disk_temptable_create_cost"), ("disk_temptable_row_cost");
240
241-- Engine cost constants
242
243CREATE TABLE IF NOT EXISTS engine_cost (
244  engine_name VARCHAR(64) NOT NULL,
245  device_type INTEGER NOT NULL,
246  cost_name   VARCHAR(64) NOT NULL,
247  cost_value  FLOAT DEFAULT NULL,
248  last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
249  comment     VARCHAR(1024) DEFAULT NULL,
250  PRIMARY KEY (cost_name, engine_name, device_type)
251) ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_general_ci STATS_PERSISTENT=0;
252
253INSERT IGNORE INTO engine_cost(engine_name, device_type, cost_name) VALUES
254  ("default", 0, "memory_block_read_cost"),
255  ("default", 0, "io_block_read_cost");
256
257--
258-- PERFORMANCE SCHEMA INSTALLATION
259-- Note that this script is also reused by mysql_upgrade,
260-- so we have to be very careful here to not destroy any
261-- existing database named 'performance_schema' if it
262-- can contain user data.
263-- In case of downgrade, it's ok to drop unknown tables
264-- from a future version, as long as they belong to the
265-- performance schema engine.
266--
267
268set @have_old_pfs= (select count(*) from information_schema.schemata where schema_name='performance_schema');
269
270SET @cmd="SET @broken_tables = (select count(*) from information_schema.tables"
271  " where engine != \'PERFORMANCE_SCHEMA\' and table_schema=\'performance_schema\')";
272
273-- Work around for bug#49542
274SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_tables = 0');
275PREPARE stmt FROM @str;
276EXECUTE stmt;
277DROP PREPARE stmt;
278
279SET @cmd="SET @broken_views = (select count(*) from information_schema.views"
280  " where table_schema='performance_schema')";
281
282-- Work around for bug#49542
283SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_views = 0');
284PREPARE stmt FROM @str;
285EXECUTE stmt;
286DROP PREPARE stmt;
287
288SET @broken_routines = (select count(*) from mysql.proc where db='performance_schema');
289
290SET @broken_events = (select count(*) from mysql.event where db='performance_schema');
291
292SET @broken_pfs= (select @broken_tables + @broken_views + @broken_routines + @broken_events);
293
294--
295-- The performance schema database.
296-- Only drop and create the database if this is safe (no broken_pfs).
297-- This database is created, even in --without-perfschema builds,
298-- so that the database name is always reserved by the MySQL implementation.
299--
300
301SET @cmd= "DROP DATABASE IF EXISTS performance_schema";
302
303SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0');
304PREPARE stmt FROM @str;
305EXECUTE stmt;
306DROP PREPARE stmt;
307
308SET @cmd= "CREATE DATABASE performance_schema character set utf8";
309
310SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0');
311PREPARE stmt FROM @str;
312EXECUTE stmt;
313DROP PREPARE stmt;
314
315--
316-- From this point, only create the performance schema tables
317-- if the server is built with performance schema
318--
319
320set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA');
321
322--
323-- TABLE COND_INSTANCES
324--
325
326SET @cmd="CREATE TABLE performance_schema.cond_instances("
327  "NAME VARCHAR(128) not null,"
328  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null"
329  ")ENGINE=PERFORMANCE_SCHEMA;";
330
331SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
332PREPARE stmt FROM @str;
333EXECUTE stmt;
334DROP PREPARE stmt;
335
336--
337-- TABLE EVENTS_WAITS_CURRENT
338--
339
340SET @cmd="CREATE TABLE performance_schema.events_waits_current("
341  "THREAD_ID BIGINT unsigned not null,"
342  "EVENT_ID BIGINT unsigned not null,"
343  "END_EVENT_ID BIGINT unsigned,"
344  "EVENT_NAME VARCHAR(128) not null,"
345  "SOURCE VARCHAR(64),"
346  "TIMER_START BIGINT unsigned,"
347  "TIMER_END BIGINT unsigned,"
348  "TIMER_WAIT BIGINT unsigned,"
349  "SPINS INTEGER unsigned,"
350  "OBJECT_SCHEMA VARCHAR(64),"
351  "OBJECT_NAME VARCHAR(512),"
352  "INDEX_NAME VARCHAR(64),"
353  "OBJECT_TYPE VARCHAR(64),"
354  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
355  "NESTING_EVENT_ID BIGINT unsigned,"
356  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT'),"
357  "OPERATION VARCHAR(32) not null,"
358  "NUMBER_OF_BYTES BIGINT,"
359  "FLAGS INTEGER unsigned"
360  ")ENGINE=PERFORMANCE_SCHEMA;";
361
362SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
363PREPARE stmt FROM @str;
364EXECUTE stmt;
365DROP PREPARE stmt;
366
367--
368-- TABLE EVENTS_WAITS_HISTORY
369--
370
371SET @cmd="CREATE TABLE performance_schema.events_waits_history("
372  "THREAD_ID BIGINT unsigned not null,"
373  "EVENT_ID BIGINT unsigned not null,"
374  "END_EVENT_ID BIGINT unsigned,"
375  "EVENT_NAME VARCHAR(128) not null,"
376  "SOURCE VARCHAR(64),"
377  "TIMER_START BIGINT unsigned,"
378  "TIMER_END BIGINT unsigned,"
379  "TIMER_WAIT BIGINT unsigned,"
380  "SPINS INTEGER unsigned,"
381  "OBJECT_SCHEMA VARCHAR(64),"
382  "OBJECT_NAME VARCHAR(512),"
383  "INDEX_NAME VARCHAR(64),"
384  "OBJECT_TYPE VARCHAR(64),"
385  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
386  "NESTING_EVENT_ID BIGINT unsigned,"
387  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT'),"
388  "OPERATION VARCHAR(32) not null,"
389  "NUMBER_OF_BYTES BIGINT,"
390  "FLAGS INTEGER unsigned"
391  ")ENGINE=PERFORMANCE_SCHEMA;";
392
393SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
394PREPARE stmt FROM @str;
395EXECUTE stmt;
396DROP PREPARE stmt;
397
398--
399-- TABLE EVENTS_WAITS_HISTORY_LONG
400--
401
402SET @cmd="CREATE TABLE performance_schema.events_waits_history_long("
403  "THREAD_ID BIGINT unsigned not null,"
404  "EVENT_ID BIGINT unsigned not null,"
405  "END_EVENT_ID BIGINT unsigned,"
406  "EVENT_NAME VARCHAR(128) not null,"
407  "SOURCE VARCHAR(64),"
408  "TIMER_START BIGINT unsigned,"
409  "TIMER_END BIGINT unsigned,"
410  "TIMER_WAIT BIGINT unsigned,"
411  "SPINS INTEGER unsigned,"
412  "OBJECT_SCHEMA VARCHAR(64),"
413  "OBJECT_NAME VARCHAR(512),"
414  "INDEX_NAME VARCHAR(64),"
415  "OBJECT_TYPE VARCHAR(64),"
416  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
417  "NESTING_EVENT_ID BIGINT unsigned,"
418  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT'),"
419  "OPERATION VARCHAR(32) not null,"
420  "NUMBER_OF_BYTES BIGINT,"
421  "FLAGS INTEGER unsigned"
422  ")ENGINE=PERFORMANCE_SCHEMA;";
423
424SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
425PREPARE stmt FROM @str;
426EXECUTE stmt;
427DROP PREPARE stmt;
428
429--
430-- TABLE EVENTS_WAITS_SUMMARY_BY_INSTANCE
431--
432
433SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_instance("
434  "EVENT_NAME VARCHAR(128) not null,"
435  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
436  "COUNT_STAR BIGINT unsigned not null,"
437  "SUM_TIMER_WAIT BIGINT unsigned not null,"
438  "MIN_TIMER_WAIT BIGINT unsigned not null,"
439  "AVG_TIMER_WAIT BIGINT unsigned not null,"
440  "MAX_TIMER_WAIT BIGINT unsigned not null"
441  ")ENGINE=PERFORMANCE_SCHEMA;";
442
443SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
444PREPARE stmt FROM @str;
445EXECUTE stmt;
446DROP PREPARE stmt;
447
448--
449-- TABLE EVENTS_WAITS_SUMMARY_BY_HOST_BY_EVENT_NAME
450--
451
452SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_host_by_event_name("
453  "HOST CHAR(60) collate utf8_bin default null,"
454  "EVENT_NAME VARCHAR(128) not null,"
455  "COUNT_STAR BIGINT unsigned not null,"
456  "SUM_TIMER_WAIT BIGINT unsigned not null,"
457  "MIN_TIMER_WAIT BIGINT unsigned not null,"
458  "AVG_TIMER_WAIT BIGINT unsigned not null,"
459  "MAX_TIMER_WAIT BIGINT unsigned not null"
460  ")ENGINE=PERFORMANCE_SCHEMA;";
461
462SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
463PREPARE stmt FROM @str;
464EXECUTE stmt;
465DROP PREPARE stmt;
466
467--
468-- TABLE EVENTS_WAITS_SUMMARY_BY_USER_BY_EVENT_NAME
469--
470
471SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_user_by_event_name("
472  "USER CHAR(32) collate utf8_bin default null,"
473  "EVENT_NAME VARCHAR(128) not null,"
474  "COUNT_STAR BIGINT unsigned not null,"
475  "SUM_TIMER_WAIT BIGINT unsigned not null,"
476  "MIN_TIMER_WAIT BIGINT unsigned not null,"
477  "AVG_TIMER_WAIT BIGINT unsigned not null,"
478  "MAX_TIMER_WAIT BIGINT unsigned not null"
479  ")ENGINE=PERFORMANCE_SCHEMA;";
480
481SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
482PREPARE stmt FROM @str;
483EXECUTE stmt;
484DROP PREPARE stmt;
485
486--
487-- TABLE EVENTS_WAITS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
488--
489
490SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_account_by_event_name("
491  "USER CHAR(32) collate utf8_bin default null,"
492  "HOST CHAR(60) collate utf8_bin default null,"
493  "EVENT_NAME VARCHAR(128) not null,"
494  "COUNT_STAR BIGINT unsigned not null,"
495  "SUM_TIMER_WAIT BIGINT unsigned not null,"
496  "MIN_TIMER_WAIT BIGINT unsigned not null,"
497  "AVG_TIMER_WAIT BIGINT unsigned not null,"
498  "MAX_TIMER_WAIT BIGINT unsigned not null"
499  ")ENGINE=PERFORMANCE_SCHEMA;";
500
501SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
502PREPARE stmt FROM @str;
503EXECUTE stmt;
504DROP PREPARE stmt;
505
506--
507-- TABLE EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME
508--
509
510SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_thread_by_event_name("
511  "THREAD_ID BIGINT unsigned not null,"
512  "EVENT_NAME VARCHAR(128) not null,"
513  "COUNT_STAR BIGINT unsigned not null,"
514  "SUM_TIMER_WAIT BIGINT unsigned not null,"
515  "MIN_TIMER_WAIT BIGINT unsigned not null,"
516  "AVG_TIMER_WAIT BIGINT unsigned not null,"
517  "MAX_TIMER_WAIT BIGINT unsigned not null"
518  ")ENGINE=PERFORMANCE_SCHEMA;";
519
520SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
521PREPARE stmt FROM @str;
522EXECUTE stmt;
523DROP PREPARE stmt;
524
525--
526-- TABLE EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME
527--
528
529SET @cmd="CREATE TABLE performance_schema.events_waits_summary_global_by_event_name("
530  "EVENT_NAME VARCHAR(128) not null,"
531  "COUNT_STAR BIGINT unsigned not null,"
532  "SUM_TIMER_WAIT BIGINT unsigned not null,"
533  "MIN_TIMER_WAIT BIGINT unsigned not null,"
534  "AVG_TIMER_WAIT BIGINT unsigned not null,"
535  "MAX_TIMER_WAIT BIGINT unsigned not null"
536  ")ENGINE=PERFORMANCE_SCHEMA;";
537
538SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
539PREPARE stmt FROM @str;
540EXECUTE stmt;
541DROP PREPARE stmt;
542
543--
544-- TABLE FILE_INSTANCES
545--
546
547SET @cmd="CREATE TABLE performance_schema.file_instances("
548  "FILE_NAME VARCHAR(512) not null,"
549  "EVENT_NAME VARCHAR(128) not null,"
550  "OPEN_COUNT INTEGER unsigned not null"
551  ")ENGINE=PERFORMANCE_SCHEMA;";
552
553SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
554PREPARE stmt FROM @str;
555EXECUTE stmt;
556DROP PREPARE stmt;
557
558--
559-- TABLE FILE_SUMMARY_BY_EVENT_NAME
560--
561
562SET @cmd="CREATE TABLE performance_schema.file_summary_by_event_name("
563  "EVENT_NAME VARCHAR(128) not null,"
564  "COUNT_STAR BIGINT unsigned not null,"
565  "SUM_TIMER_WAIT BIGINT unsigned not null,"
566  "MIN_TIMER_WAIT BIGINT unsigned not null,"
567  "AVG_TIMER_WAIT BIGINT unsigned not null,"
568  "MAX_TIMER_WAIT BIGINT unsigned not null,"
569  "COUNT_READ BIGINT unsigned not null,"
570  "SUM_TIMER_READ BIGINT unsigned not null,"
571  "MIN_TIMER_READ BIGINT unsigned not null,"
572  "AVG_TIMER_READ BIGINT unsigned not null,"
573  "MAX_TIMER_READ BIGINT unsigned not null,"
574  "SUM_NUMBER_OF_BYTES_READ BIGINT not null,"
575  "COUNT_WRITE BIGINT unsigned not null,"
576  "SUM_TIMER_WRITE BIGINT unsigned not null,"
577  "MIN_TIMER_WRITE BIGINT unsigned not null,"
578  "AVG_TIMER_WRITE BIGINT unsigned not null,"
579  "MAX_TIMER_WRITE BIGINT unsigned not null,"
580  "SUM_NUMBER_OF_BYTES_WRITE BIGINT not null,"
581  "COUNT_MISC BIGINT unsigned not null,"
582  "SUM_TIMER_MISC BIGINT unsigned not null,"
583  "MIN_TIMER_MISC BIGINT unsigned not null,"
584  "AVG_TIMER_MISC BIGINT unsigned not null,"
585  "MAX_TIMER_MISC BIGINT unsigned not null"
586  ")ENGINE=PERFORMANCE_SCHEMA;";
587
588SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
589PREPARE stmt FROM @str;
590EXECUTE stmt;
591DROP PREPARE stmt;
592
593--
594-- TABLE FILE_SUMMARY_BY_INSTANCE
595--
596
597SET @cmd="CREATE TABLE performance_schema.file_summary_by_instance("
598  "FILE_NAME VARCHAR(512) not null,"
599  "EVENT_NAME VARCHAR(128) not null,"
600  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
601  "COUNT_STAR BIGINT unsigned not null,"
602  "SUM_TIMER_WAIT BIGINT unsigned not null,"
603  "MIN_TIMER_WAIT BIGINT unsigned not null,"
604  "AVG_TIMER_WAIT BIGINT unsigned not null,"
605  "MAX_TIMER_WAIT BIGINT unsigned not null,"
606  "COUNT_READ BIGINT unsigned not null,"
607  "SUM_TIMER_READ BIGINT unsigned not null,"
608  "MIN_TIMER_READ BIGINT unsigned not null,"
609  "AVG_TIMER_READ BIGINT unsigned not null,"
610  "MAX_TIMER_READ BIGINT unsigned not null,"
611  "SUM_NUMBER_OF_BYTES_READ BIGINT not null,"
612  "COUNT_WRITE BIGINT unsigned not null,"
613  "SUM_TIMER_WRITE BIGINT unsigned not null,"
614  "MIN_TIMER_WRITE BIGINT unsigned not null,"
615  "AVG_TIMER_WRITE BIGINT unsigned not null,"
616  "MAX_TIMER_WRITE BIGINT unsigned not null,"
617  "SUM_NUMBER_OF_BYTES_WRITE BIGINT not null,"
618  "COUNT_MISC BIGINT unsigned not null,"
619  "SUM_TIMER_MISC BIGINT unsigned not null,"
620  "MIN_TIMER_MISC BIGINT unsigned not null,"
621  "AVG_TIMER_MISC BIGINT unsigned not null,"
622  "MAX_TIMER_MISC BIGINT unsigned not null"
623  ")ENGINE=PERFORMANCE_SCHEMA;";
624
625SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
626PREPARE stmt FROM @str;
627EXECUTE stmt;
628DROP PREPARE stmt;
629
630
631--
632-- TABLE SOCKET_INSTANCES
633--
634
635SET @cmd="CREATE TABLE performance_schema.socket_instances("
636  "EVENT_NAME VARCHAR(128) not null,"
637  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
638  "THREAD_ID BIGINT unsigned,"
639  "SOCKET_ID INTEGER not null,"
640  "IP VARCHAR(64) not null,"
641  "PORT INTEGER not null,"
642  "STATE ENUM('IDLE','ACTIVE') not null"
643  ")ENGINE=PERFORMANCE_SCHEMA;";
644
645SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
646PREPARE stmt FROM @str;
647EXECUTE stmt;
648DROP PREPARE stmt;
649
650--
651-- TABLE SOCKET_SUMMARY_BY_INSTANCE
652--
653
654SET @cmd="CREATE TABLE performance_schema.socket_summary_by_instance("
655  "EVENT_NAME VARCHAR(128) not null,"
656  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
657  "COUNT_STAR BIGINT unsigned not null,"
658  "SUM_TIMER_WAIT BIGINT unsigned not null,"
659  "MIN_TIMER_WAIT BIGINT unsigned not null,"
660  "AVG_TIMER_WAIT BIGINT unsigned not null,"
661  "MAX_TIMER_WAIT BIGINT unsigned not null,"
662  "COUNT_READ BIGINT unsigned not null,"
663  "SUM_TIMER_READ BIGINT unsigned not null,"
664  "MIN_TIMER_READ BIGINT unsigned not null,"
665  "AVG_TIMER_READ BIGINT unsigned not null,"
666  "MAX_TIMER_READ BIGINT unsigned not null,"
667  "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,"
668  "COUNT_WRITE BIGINT unsigned not null,"
669  "SUM_TIMER_WRITE BIGINT unsigned not null,"
670  "MIN_TIMER_WRITE BIGINT unsigned not null,"
671  "AVG_TIMER_WRITE BIGINT unsigned not null,"
672  "MAX_TIMER_WRITE BIGINT unsigned not null,"
673  "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null,"
674  "COUNT_MISC BIGINT unsigned not null,"
675  "SUM_TIMER_MISC BIGINT unsigned not null,"
676  "MIN_TIMER_MISC BIGINT unsigned not null,"
677  "AVG_TIMER_MISC BIGINT unsigned not null,"
678  "MAX_TIMER_MISC BIGINT unsigned not null"
679  ")ENGINE=PERFORMANCE_SCHEMA;";
680
681SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
682PREPARE stmt FROM @str;
683EXECUTE stmt;
684DROP PREPARE stmt;
685
686--
687-- TABLE SOCKET_SUMMARY_BY_INSTANCE
688--
689
690SET @cmd="CREATE TABLE performance_schema.socket_summary_by_event_name("
691  "EVENT_NAME VARCHAR(128) not null,"
692  "COUNT_STAR BIGINT unsigned not null,"
693  "SUM_TIMER_WAIT BIGINT unsigned not null,"
694  "MIN_TIMER_WAIT BIGINT unsigned not null,"
695  "AVG_TIMER_WAIT BIGINT unsigned not null,"
696  "MAX_TIMER_WAIT BIGINT unsigned not null,"
697  "COUNT_READ BIGINT unsigned not null,"
698  "SUM_TIMER_READ BIGINT unsigned not null,"
699  "MIN_TIMER_READ BIGINT unsigned not null,"
700  "AVG_TIMER_READ BIGINT unsigned not null,"
701  "MAX_TIMER_READ BIGINT unsigned not null,"
702  "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,"
703  "COUNT_WRITE BIGINT unsigned not null,"
704  "SUM_TIMER_WRITE BIGINT unsigned not null,"
705  "MIN_TIMER_WRITE BIGINT unsigned not null,"
706  "AVG_TIMER_WRITE BIGINT unsigned not null,"
707  "MAX_TIMER_WRITE BIGINT unsigned not null,"
708  "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null,"
709  "COUNT_MISC BIGINT unsigned not null,"
710  "SUM_TIMER_MISC BIGINT unsigned not null,"
711  "MIN_TIMER_MISC BIGINT unsigned not null,"
712  "AVG_TIMER_MISC BIGINT unsigned not null,"
713  "MAX_TIMER_MISC BIGINT unsigned not null"
714  ")ENGINE=PERFORMANCE_SCHEMA;";
715
716SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
717PREPARE stmt FROM @str;
718EXECUTE stmt;
719DROP PREPARE stmt;
720
721--
722-- TABLE HOST_CACHE
723--
724
725SET @cmd="CREATE TABLE performance_schema.host_cache("
726  "IP VARCHAR(64) not null,"
727  "HOST VARCHAR(255) collate utf8_bin,"
728  "HOST_VALIDATED ENUM ('YES', 'NO') not null,"
729  "SUM_CONNECT_ERRORS BIGINT not null,"
730  "COUNT_HOST_BLOCKED_ERRORS BIGINT not null,"
731  "COUNT_NAMEINFO_TRANSIENT_ERRORS BIGINT not null,"
732  "COUNT_NAMEINFO_PERMANENT_ERRORS BIGINT not null,"
733  "COUNT_FORMAT_ERRORS BIGINT not null,"
734  "COUNT_ADDRINFO_TRANSIENT_ERRORS BIGINT not null,"
735  "COUNT_ADDRINFO_PERMANENT_ERRORS BIGINT not null,"
736  "COUNT_FCRDNS_ERRORS BIGINT not null,"
737  "COUNT_HOST_ACL_ERRORS BIGINT not null,"
738  "COUNT_NO_AUTH_PLUGIN_ERRORS BIGINT not null,"
739  "COUNT_AUTH_PLUGIN_ERRORS BIGINT not null,"
740  "COUNT_HANDSHAKE_ERRORS BIGINT not null,"
741  "COUNT_PROXY_USER_ERRORS BIGINT not null,"
742  "COUNT_PROXY_USER_ACL_ERRORS BIGINT not null,"
743  "COUNT_AUTHENTICATION_ERRORS BIGINT not null,"
744  "COUNT_SSL_ERRORS BIGINT not null,"
745  "COUNT_MAX_USER_CONNECTIONS_ERRORS BIGINT not null,"
746  "COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS BIGINT not null,"
747  "COUNT_DEFAULT_DATABASE_ERRORS BIGINT not null,"
748  "COUNT_INIT_CONNECT_ERRORS BIGINT not null,"
749  "COUNT_LOCAL_ERRORS BIGINT not null,"
750  "COUNT_UNKNOWN_ERRORS BIGINT not null,"
751  "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0,"
752  "LAST_SEEN TIMESTAMP(0) NOT NULL default 0,"
753  "FIRST_ERROR_SEEN TIMESTAMP(0) null default 0,"
754  "LAST_ERROR_SEEN TIMESTAMP(0) null default 0"
755  ")ENGINE=PERFORMANCE_SCHEMA;";
756
757SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
758PREPARE stmt FROM @str;
759EXECUTE stmt;
760DROP PREPARE stmt;
761
762--
763-- TABLE MUTEX_INSTANCES
764--
765
766SET @cmd="CREATE TABLE performance_schema.mutex_instances("
767  "NAME VARCHAR(128) not null,"
768  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
769  "LOCKED_BY_THREAD_ID BIGINT unsigned"
770  ")ENGINE=PERFORMANCE_SCHEMA;";
771
772SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
773PREPARE stmt FROM @str;
774EXECUTE stmt;
775DROP PREPARE stmt;
776
777--
778-- TABLE OBJECTS_SUMMARY_GLOBAL_BY_TYPE
779--
780
781SET @cmd="CREATE TABLE performance_schema.objects_summary_global_by_type("
782  "OBJECT_TYPE VARCHAR(64),"
783  "OBJECT_SCHEMA VARCHAR(64),"
784  "OBJECT_NAME VARCHAR(64),"
785  "COUNT_STAR BIGINT unsigned not null,"
786  "SUM_TIMER_WAIT BIGINT unsigned not null,"
787  "MIN_TIMER_WAIT BIGINT unsigned not null,"
788  "AVG_TIMER_WAIT BIGINT unsigned not null,"
789  "MAX_TIMER_WAIT BIGINT unsigned not null"
790  ")ENGINE=PERFORMANCE_SCHEMA;";
791
792SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
793PREPARE stmt FROM @str;
794EXECUTE stmt;
795DROP PREPARE stmt;
796
797--
798-- TABLE PERFORMANCE_TIMERS
799--
800
801SET @cmd="CREATE TABLE performance_schema.performance_timers("
802  "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null,"
803  "TIMER_FREQUENCY BIGINT,"
804  "TIMER_RESOLUTION BIGINT,"
805  "TIMER_OVERHEAD BIGINT"
806  ") ENGINE=PERFORMANCE_SCHEMA;";
807
808SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
809PREPARE stmt FROM @str;
810EXECUTE stmt;
811DROP PREPARE stmt;
812
813--
814-- TABLE RWLOCK_INSTANCES
815--
816
817SET @cmd="CREATE TABLE performance_schema.rwlock_instances("
818  "NAME VARCHAR(128) not null,"
819  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
820  "WRITE_LOCKED_BY_THREAD_ID BIGINT unsigned,"
821  "READ_LOCKED_BY_COUNT INTEGER unsigned not null"
822  ")ENGINE=PERFORMANCE_SCHEMA;";
823
824SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
825PREPARE stmt FROM @str;
826EXECUTE stmt;
827DROP PREPARE stmt;
828
829--
830-- TABLE SETUP_ACTORS
831--
832
833SET @cmd="CREATE TABLE performance_schema.setup_actors("
834  "HOST CHAR(60) collate utf8_bin default '%' not null,"
835  "USER CHAR(32) collate utf8_bin default '%' not null,"
836  "ROLE CHAR(16) collate utf8_bin default '%' not null,"
837  "ENABLED ENUM ('YES', 'NO') not null default 'YES',"
838  "HISTORY ENUM ('YES', 'NO') not null default 'YES'"
839  ")ENGINE=PERFORMANCE_SCHEMA;";
840
841SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
842PREPARE stmt FROM @str;
843EXECUTE stmt;
844DROP PREPARE stmt;
845
846--
847-- TABLE SETUP_CONSUMERS
848--
849
850SET @cmd="CREATE TABLE performance_schema.setup_consumers("
851  "NAME VARCHAR(64) not null,"
852  "ENABLED ENUM ('YES', 'NO') not null"
853  ")ENGINE=PERFORMANCE_SCHEMA;";
854
855SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
856PREPARE stmt FROM @str;
857EXECUTE stmt;
858DROP PREPARE stmt;
859
860--
861-- TABLE SETUP_INSTRUMENTS
862--
863
864SET @cmd="CREATE TABLE performance_schema.setup_instruments("
865  "NAME VARCHAR(128) not null,"
866  "ENABLED ENUM ('YES', 'NO') not null,"
867  "TIMED ENUM ('YES', 'NO') not null"
868  ")ENGINE=PERFORMANCE_SCHEMA;";
869
870SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
871PREPARE stmt FROM @str;
872EXECUTE stmt;
873DROP PREPARE stmt;
874
875--
876-- TABLE SETUP_OBJECTS
877--
878
879SET @cmd="CREATE TABLE performance_schema.setup_objects("
880  "OBJECT_TYPE ENUM ('EVENT', 'FUNCTION', 'PROCEDURE', 'TABLE', 'TRIGGER') not null default 'TABLE',"
881  "OBJECT_SCHEMA VARCHAR(64) default '%',"
882  "OBJECT_NAME VARCHAR(64) not null default '%',"
883  "ENABLED ENUM ('YES', 'NO') not null default 'YES',"
884  "TIMED ENUM ('YES', 'NO') not null default 'YES'"
885  ")ENGINE=PERFORMANCE_SCHEMA;";
886
887SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
888PREPARE stmt FROM @str;
889EXECUTE stmt;
890DROP PREPARE stmt;
891
892--
893-- TABLE SETUP_TIMERS
894--
895
896SET @cmd="CREATE TABLE performance_schema.setup_timers("
897  "NAME VARCHAR(64) not null,"
898  "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null"
899  ")ENGINE=PERFORMANCE_SCHEMA;";
900
901SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
902PREPARE stmt FROM @str;
903EXECUTE stmt;
904DROP PREPARE stmt;
905
906--
907-- TABLE TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE
908--
909
910SET @cmd="CREATE TABLE performance_schema.table_io_waits_summary_by_index_usage("
911  "OBJECT_TYPE VARCHAR(64),"
912  "OBJECT_SCHEMA VARCHAR(64),"
913  "OBJECT_NAME VARCHAR(64),"
914  "INDEX_NAME VARCHAR(64),"
915  "COUNT_STAR BIGINT unsigned not null,"
916  "SUM_TIMER_WAIT BIGINT unsigned not null,"
917  "MIN_TIMER_WAIT BIGINT unsigned not null,"
918  "AVG_TIMER_WAIT BIGINT unsigned not null,"
919  "MAX_TIMER_WAIT BIGINT unsigned not null,"
920  "COUNT_READ BIGINT unsigned not null,"
921  "SUM_TIMER_READ BIGINT unsigned not null,"
922  "MIN_TIMER_READ BIGINT unsigned not null,"
923  "AVG_TIMER_READ BIGINT unsigned not null,"
924  "MAX_TIMER_READ BIGINT unsigned not null,"
925  "COUNT_WRITE BIGINT unsigned not null,"
926  "SUM_TIMER_WRITE BIGINT unsigned not null,"
927  "MIN_TIMER_WRITE BIGINT unsigned not null,"
928  "AVG_TIMER_WRITE BIGINT unsigned not null,"
929  "MAX_TIMER_WRITE BIGINT unsigned not null,"
930  "COUNT_FETCH BIGINT unsigned not null,"
931  "SUM_TIMER_FETCH BIGINT unsigned not null,"
932  "MIN_TIMER_FETCH BIGINT unsigned not null,"
933  "AVG_TIMER_FETCH BIGINT unsigned not null,"
934  "MAX_TIMER_FETCH BIGINT unsigned not null,"
935  "COUNT_INSERT BIGINT unsigned not null,"
936  "SUM_TIMER_INSERT BIGINT unsigned not null,"
937  "MIN_TIMER_INSERT BIGINT unsigned not null,"
938  "AVG_TIMER_INSERT BIGINT unsigned not null,"
939  "MAX_TIMER_INSERT BIGINT unsigned not null,"
940  "COUNT_UPDATE BIGINT unsigned not null,"
941  "SUM_TIMER_UPDATE BIGINT unsigned not null,"
942  "MIN_TIMER_UPDATE BIGINT unsigned not null,"
943  "AVG_TIMER_UPDATE BIGINT unsigned not null,"
944  "MAX_TIMER_UPDATE BIGINT unsigned not null,"
945  "COUNT_DELETE BIGINT unsigned not null,"
946  "SUM_TIMER_DELETE BIGINT unsigned not null,"
947  "MIN_TIMER_DELETE BIGINT unsigned not null,"
948  "AVG_TIMER_DELETE BIGINT unsigned not null,"
949  "MAX_TIMER_DELETE BIGINT unsigned not null"
950  ")ENGINE=PERFORMANCE_SCHEMA;";
951
952SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
953PREPARE stmt FROM @str;
954EXECUTE stmt;
955DROP PREPARE stmt;
956
957--
958-- TABLE TABLE_IO_WAITS_SUMMARY_BY_TABLE
959--
960
961SET @cmd="CREATE TABLE performance_schema.table_io_waits_summary_by_table("
962  "OBJECT_TYPE VARCHAR(64),"
963  "OBJECT_SCHEMA VARCHAR(64),"
964  "OBJECT_NAME VARCHAR(64),"
965  "COUNT_STAR BIGINT unsigned not null,"
966  "SUM_TIMER_WAIT BIGINT unsigned not null,"
967  "MIN_TIMER_WAIT BIGINT unsigned not null,"
968  "AVG_TIMER_WAIT BIGINT unsigned not null,"
969  "MAX_TIMER_WAIT BIGINT unsigned not null,"
970  "COUNT_READ BIGINT unsigned not null,"
971  "SUM_TIMER_READ BIGINT unsigned not null,"
972  "MIN_TIMER_READ BIGINT unsigned not null,"
973  "AVG_TIMER_READ BIGINT unsigned not null,"
974  "MAX_TIMER_READ BIGINT unsigned not null,"
975  "COUNT_WRITE BIGINT unsigned not null,"
976  "SUM_TIMER_WRITE BIGINT unsigned not null,"
977  "MIN_TIMER_WRITE BIGINT unsigned not null,"
978  "AVG_TIMER_WRITE BIGINT unsigned not null,"
979  "MAX_TIMER_WRITE BIGINT unsigned not null,"
980  "COUNT_FETCH BIGINT unsigned not null,"
981  "SUM_TIMER_FETCH BIGINT unsigned not null,"
982  "MIN_TIMER_FETCH BIGINT unsigned not null,"
983  "AVG_TIMER_FETCH BIGINT unsigned not null,"
984  "MAX_TIMER_FETCH BIGINT unsigned not null,"
985  "COUNT_INSERT BIGINT unsigned not null,"
986  "SUM_TIMER_INSERT BIGINT unsigned not null,"
987  "MIN_TIMER_INSERT BIGINT unsigned not null,"
988  "AVG_TIMER_INSERT BIGINT unsigned not null,"
989  "MAX_TIMER_INSERT BIGINT unsigned not null,"
990  "COUNT_UPDATE BIGINT unsigned not null,"
991  "SUM_TIMER_UPDATE BIGINT unsigned not null,"
992  "MIN_TIMER_UPDATE BIGINT unsigned not null,"
993  "AVG_TIMER_UPDATE BIGINT unsigned not null,"
994  "MAX_TIMER_UPDATE BIGINT unsigned not null,"
995  "COUNT_DELETE BIGINT unsigned not null,"
996  "SUM_TIMER_DELETE BIGINT unsigned not null,"
997  "MIN_TIMER_DELETE BIGINT unsigned not null,"
998  "AVG_TIMER_DELETE BIGINT unsigned not null,"
999  "MAX_TIMER_DELETE BIGINT unsigned not null"
1000  ")ENGINE=PERFORMANCE_SCHEMA;";
1001
1002SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1003PREPARE stmt FROM @str;
1004EXECUTE stmt;
1005DROP PREPARE stmt;
1006
1007--
1008-- TABLE TABLE_LOCK_WAITS_SUMMARY_BY_TABLE
1009--
1010
1011SET @cmd="CREATE TABLE performance_schema.table_lock_waits_summary_by_table("
1012  "OBJECT_TYPE VARCHAR(64),"
1013  "OBJECT_SCHEMA VARCHAR(64),"
1014  "OBJECT_NAME VARCHAR(64),"
1015  "COUNT_STAR BIGINT unsigned not null,"
1016  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1017  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1018  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1019  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1020  "COUNT_READ BIGINT unsigned not null,"
1021  "SUM_TIMER_READ BIGINT unsigned not null,"
1022  "MIN_TIMER_READ BIGINT unsigned not null,"
1023  "AVG_TIMER_READ BIGINT unsigned not null,"
1024  "MAX_TIMER_READ BIGINT unsigned not null,"
1025  "COUNT_WRITE BIGINT unsigned not null,"
1026  "SUM_TIMER_WRITE BIGINT unsigned not null,"
1027  "MIN_TIMER_WRITE BIGINT unsigned not null,"
1028  "AVG_TIMER_WRITE BIGINT unsigned not null,"
1029  "MAX_TIMER_WRITE BIGINT unsigned not null,"
1030  "COUNT_READ_NORMAL BIGINT unsigned not null,"
1031  "SUM_TIMER_READ_NORMAL BIGINT unsigned not null,"
1032  "MIN_TIMER_READ_NORMAL BIGINT unsigned not null,"
1033  "AVG_TIMER_READ_NORMAL BIGINT unsigned not null,"
1034  "MAX_TIMER_READ_NORMAL BIGINT unsigned not null,"
1035  "COUNT_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
1036  "SUM_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
1037  "MIN_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
1038  "AVG_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
1039  "MAX_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
1040  "COUNT_READ_HIGH_PRIORITY BIGINT unsigned not null,"
1041  "SUM_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
1042  "MIN_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
1043  "AVG_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
1044  "MAX_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
1045  "COUNT_READ_NO_INSERT BIGINT unsigned not null,"
1046  "SUM_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
1047  "MIN_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
1048  "AVG_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
1049  "MAX_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
1050  "COUNT_READ_EXTERNAL BIGINT unsigned not null,"
1051  "SUM_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
1052  "MIN_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
1053  "AVG_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
1054  "MAX_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
1055  "COUNT_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
1056  "SUM_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
1057  "MIN_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
1058  "AVG_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
1059  "MAX_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
1060  "COUNT_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
1061  "SUM_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
1062  "MIN_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
1063  "AVG_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
1064  "MAX_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
1065  "COUNT_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
1066  "SUM_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
1067  "MIN_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
1068  "AVG_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
1069  "MAX_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
1070  "COUNT_WRITE_NORMAL BIGINT unsigned not null,"
1071  "SUM_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
1072  "MIN_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
1073  "AVG_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
1074  "MAX_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
1075  "COUNT_WRITE_EXTERNAL BIGINT unsigned not null,"
1076  "SUM_TIMER_WRITE_EXTERNAL BIGINT unsigned not null,"
1077  "MIN_TIMER_WRITE_EXTERNAL BIGINT unsigned not null,"
1078  "AVG_TIMER_WRITE_EXTERNAL BIGINT unsigned not null,"
1079  "MAX_TIMER_WRITE_EXTERNAL BIGINT unsigned not null"
1080  ")ENGINE=PERFORMANCE_SCHEMA;";
1081
1082SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1083PREPARE stmt FROM @str;
1084EXECUTE stmt;
1085DROP PREPARE stmt;
1086
1087--
1088-- TABLE THREADS
1089--
1090
1091SET @cmd="CREATE TABLE performance_schema.threads("
1092  "THREAD_ID BIGINT unsigned not null,"
1093  "NAME VARCHAR(128) not null,"
1094  "TYPE VARCHAR(10) not null,"
1095  "PROCESSLIST_ID BIGINT unsigned,"
1096  "PROCESSLIST_USER VARCHAR(32),"
1097  "PROCESSLIST_HOST VARCHAR(60),"
1098  "PROCESSLIST_DB VARCHAR(64),"
1099  "PROCESSLIST_COMMAND VARCHAR(16),"
1100  "PROCESSLIST_TIME BIGINT,"
1101  "PROCESSLIST_STATE VARCHAR(64),"
1102  "PROCESSLIST_INFO LONGTEXT,"
1103  "PARENT_THREAD_ID BIGINT unsigned,"
1104  "ROLE VARCHAR(64),"
1105  "INSTRUMENTED ENUM ('YES', 'NO') not null,"
1106  "HISTORY ENUM ('YES', 'NO') not null,"
1107  "CONNECTION_TYPE VARCHAR(16),"
1108  "THREAD_OS_ID BIGINT unsigned"
1109  ")ENGINE=PERFORMANCE_SCHEMA;";
1110
1111SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1112PREPARE stmt FROM @str;
1113EXECUTE stmt;
1114DROP PREPARE stmt;
1115
1116--
1117-- TABLE EVENTS_STAGES_CURRENT
1118--
1119
1120SET @cmd="CREATE TABLE performance_schema.events_stages_current("
1121  "THREAD_ID BIGINT unsigned not null,"
1122  "EVENT_ID BIGINT unsigned not null,"
1123  "END_EVENT_ID BIGINT unsigned,"
1124  "EVENT_NAME VARCHAR(128) not null,"
1125  "SOURCE VARCHAR(64),"
1126  "TIMER_START BIGINT unsigned,"
1127  "TIMER_END BIGINT unsigned,"
1128  "TIMER_WAIT BIGINT unsigned,"
1129  "WORK_COMPLETED BIGINT unsigned,"
1130  "WORK_ESTIMATED BIGINT unsigned,"
1131  "NESTING_EVENT_ID BIGINT unsigned,"
1132  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT')"
1133  ")ENGINE=PERFORMANCE_SCHEMA;";
1134
1135SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1136PREPARE stmt FROM @str;
1137EXECUTE stmt;
1138DROP PREPARE stmt;
1139
1140--
1141-- TABLE EVENTS_STAGES_HISTORY
1142--
1143
1144SET @cmd="CREATE TABLE performance_schema.events_stages_history("
1145  "THREAD_ID BIGINT unsigned not null,"
1146  "EVENT_ID BIGINT unsigned not null,"
1147  "END_EVENT_ID BIGINT unsigned,"
1148  "EVENT_NAME VARCHAR(128) not null,"
1149  "SOURCE VARCHAR(64),"
1150  "TIMER_START BIGINT unsigned,"
1151  "TIMER_END BIGINT unsigned,"
1152  "TIMER_WAIT BIGINT unsigned,"
1153  "WORK_COMPLETED BIGINT unsigned,"
1154  "WORK_ESTIMATED BIGINT unsigned,"
1155  "NESTING_EVENT_ID BIGINT unsigned,"
1156  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT')"
1157  ")ENGINE=PERFORMANCE_SCHEMA;";
1158
1159SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1160PREPARE stmt FROM @str;
1161EXECUTE stmt;
1162DROP PREPARE stmt;
1163
1164--
1165-- TABLE EVENTS_STAGES_HISTORY_LONG
1166--
1167
1168SET @cmd="CREATE TABLE performance_schema.events_stages_history_long("
1169  "THREAD_ID BIGINT unsigned not null,"
1170  "EVENT_ID BIGINT unsigned not null,"
1171  "END_EVENT_ID BIGINT unsigned,"
1172  "EVENT_NAME VARCHAR(128) not null,"
1173  "SOURCE VARCHAR(64),"
1174  "TIMER_START BIGINT unsigned,"
1175  "TIMER_END BIGINT unsigned,"
1176  "TIMER_WAIT BIGINT unsigned,"
1177  "WORK_COMPLETED BIGINT unsigned,"
1178  "WORK_ESTIMATED BIGINT unsigned,"
1179  "NESTING_EVENT_ID BIGINT unsigned,"
1180  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT')"
1181  ")ENGINE=PERFORMANCE_SCHEMA;";
1182
1183SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1184PREPARE stmt FROM @str;
1185EXECUTE stmt;
1186DROP PREPARE stmt;
1187
1188--
1189-- TABLE EVENTS_STAGES_SUMMARY_BY_THREAD_BY_EVENT_NAME
1190--
1191
1192SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_thread_by_event_name("
1193  "THREAD_ID BIGINT unsigned not null,"
1194  "EVENT_NAME VARCHAR(128) not null,"
1195  "COUNT_STAR BIGINT unsigned not null,"
1196  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1197  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1198  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1199  "MAX_TIMER_WAIT BIGINT unsigned not null"
1200  ")ENGINE=PERFORMANCE_SCHEMA;";
1201
1202SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1203PREPARE stmt FROM @str;
1204EXECUTE stmt;
1205DROP PREPARE stmt;
1206
1207--
1208-- TABLE EVENTS_STAGES_SUMMARY_BY_HOST_BY_EVENT_NAME
1209--
1210
1211SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_host_by_event_name("
1212  "HOST CHAR(60) collate utf8_bin default null,"
1213  "EVENT_NAME VARCHAR(128) not null,"
1214  "COUNT_STAR BIGINT unsigned not null,"
1215  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1216  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1217  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1218  "MAX_TIMER_WAIT BIGINT unsigned not null"
1219  ")ENGINE=PERFORMANCE_SCHEMA;";
1220
1221SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1222PREPARE stmt FROM @str;
1223EXECUTE stmt;
1224DROP PREPARE stmt;
1225
1226--
1227-- TABLE EVENTS_STAGES_SUMMARY_BY_USER_BY_EVENT_NAME
1228--
1229
1230SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_user_by_event_name("
1231  "USER CHAR(32) collate utf8_bin default null,"
1232  "EVENT_NAME VARCHAR(128) not null,"
1233  "COUNT_STAR BIGINT unsigned not null,"
1234  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1235  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1236  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1237  "MAX_TIMER_WAIT BIGINT unsigned not null"
1238  ")ENGINE=PERFORMANCE_SCHEMA;";
1239
1240SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1241PREPARE stmt FROM @str;
1242EXECUTE stmt;
1243DROP PREPARE stmt;
1244
1245--
1246-- TABLE EVENTS_STAGES_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
1247--
1248
1249SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_account_by_event_name("
1250  "USER CHAR(32) collate utf8_bin default null,"
1251  "HOST CHAR(60) collate utf8_bin default null,"
1252  "EVENT_NAME VARCHAR(128) not null,"
1253  "COUNT_STAR BIGINT unsigned not null,"
1254  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1255  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1256  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1257  "MAX_TIMER_WAIT BIGINT unsigned not null"
1258  ")ENGINE=PERFORMANCE_SCHEMA;";
1259
1260SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1261PREPARE stmt FROM @str;
1262EXECUTE stmt;
1263DROP PREPARE stmt;
1264
1265--
1266-- TABLE EVENTS_STAGES_SUMMARY_GLOBAL_BY_EVENT_NAME
1267--
1268
1269SET @cmd="CREATE TABLE performance_schema.events_stages_summary_global_by_event_name("
1270  "EVENT_NAME VARCHAR(128) not null,"
1271  "COUNT_STAR BIGINT unsigned not null,"
1272  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1273  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1274  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1275  "MAX_TIMER_WAIT BIGINT unsigned not null"
1276  ")ENGINE=PERFORMANCE_SCHEMA;";
1277
1278SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1279PREPARE stmt FROM @str;
1280EXECUTE stmt;
1281DROP PREPARE stmt;
1282
1283--
1284-- TABLE EVENTS_STATEMENTS_CURRENT
1285--
1286
1287SET @cmd="CREATE TABLE performance_schema.events_statements_current("
1288  "THREAD_ID BIGINT unsigned not null,"
1289  "EVENT_ID BIGINT unsigned not null,"
1290  "END_EVENT_ID BIGINT unsigned,"
1291  "EVENT_NAME VARCHAR(128) not null,"
1292  "SOURCE VARCHAR(64),"
1293  "TIMER_START BIGINT unsigned,"
1294  "TIMER_END BIGINT unsigned,"
1295  "TIMER_WAIT BIGINT unsigned,"
1296  "LOCK_TIME bigint unsigned not null,"
1297  "SQL_TEXT LONGTEXT,"
1298  "DIGEST VARCHAR(32),"
1299  "DIGEST_TEXT LONGTEXT,"
1300  "CURRENT_SCHEMA VARCHAR(64),"
1301  "OBJECT_TYPE VARCHAR(64),"
1302  "OBJECT_SCHEMA VARCHAR(64),"
1303  "OBJECT_NAME VARCHAR(64),"
1304  "OBJECT_INSTANCE_BEGIN BIGINT unsigned,"
1305  "MYSQL_ERRNO INTEGER,"
1306  "RETURNED_SQLSTATE VARCHAR(5),"
1307  "MESSAGE_TEXT VARCHAR(128),"
1308  "ERRORS BIGINT unsigned not null,"
1309  "WARNINGS BIGINT unsigned not null,"
1310  "ROWS_AFFECTED BIGINT unsigned not null,"
1311  "ROWS_SENT BIGINT unsigned not null,"
1312  "ROWS_EXAMINED BIGINT unsigned not null,"
1313  "CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
1314  "CREATED_TMP_TABLES BIGINT unsigned not null,"
1315  "SELECT_FULL_JOIN BIGINT unsigned not null,"
1316  "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
1317  "SELECT_RANGE BIGINT unsigned not null,"
1318  "SELECT_RANGE_CHECK BIGINT unsigned not null,"
1319  "SELECT_SCAN BIGINT unsigned not null,"
1320  "SORT_MERGE_PASSES BIGINT unsigned not null,"
1321  "SORT_RANGE BIGINT unsigned not null,"
1322  "SORT_ROWS BIGINT unsigned not null,"
1323  "SORT_SCAN BIGINT unsigned not null,"
1324  "NO_INDEX_USED BIGINT unsigned not null,"
1325  "NO_GOOD_INDEX_USED BIGINT unsigned not null,"
1326  "NESTING_EVENT_ID BIGINT unsigned,"
1327  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT'),"
1328  "NESTING_EVENT_LEVEL INTEGER"
1329  ")ENGINE=PERFORMANCE_SCHEMA;";
1330
1331SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1332PREPARE stmt FROM @str;
1333EXECUTE stmt;
1334DROP PREPARE stmt;
1335
1336--
1337-- TABLE EVENTS_STATEMENTS_HISTORY
1338--
1339
1340SET @cmd="CREATE TABLE performance_schema.events_statements_history("
1341  "THREAD_ID BIGINT unsigned not null,"
1342  "EVENT_ID BIGINT unsigned not null,"
1343  "END_EVENT_ID BIGINT unsigned,"
1344  "EVENT_NAME VARCHAR(128) not null,"
1345  "SOURCE VARCHAR(64),"
1346  "TIMER_START BIGINT unsigned,"
1347  "TIMER_END BIGINT unsigned,"
1348  "TIMER_WAIT BIGINT unsigned,"
1349  "LOCK_TIME bigint unsigned not null,"
1350  "SQL_TEXT LONGTEXT,"
1351  "DIGEST VARCHAR(32),"
1352  "DIGEST_TEXT LONGTEXT,"
1353  "CURRENT_SCHEMA VARCHAR(64),"
1354  "OBJECT_TYPE VARCHAR(64),"
1355  "OBJECT_SCHEMA VARCHAR(64),"
1356  "OBJECT_NAME VARCHAR(64),"
1357  "OBJECT_INSTANCE_BEGIN BIGINT unsigned,"
1358  "MYSQL_ERRNO INTEGER,"
1359  "RETURNED_SQLSTATE VARCHAR(5),"
1360  "MESSAGE_TEXT VARCHAR(128),"
1361  "ERRORS BIGINT unsigned not null,"
1362  "WARNINGS BIGINT unsigned not null,"
1363  "ROWS_AFFECTED BIGINT unsigned not null,"
1364  "ROWS_SENT BIGINT unsigned not null,"
1365  "ROWS_EXAMINED BIGINT unsigned not null,"
1366  "CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
1367  "CREATED_TMP_TABLES BIGINT unsigned not null,"
1368  "SELECT_FULL_JOIN BIGINT unsigned not null,"
1369  "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
1370  "SELECT_RANGE BIGINT unsigned not null,"
1371  "SELECT_RANGE_CHECK BIGINT unsigned not null,"
1372  "SELECT_SCAN BIGINT unsigned not null,"
1373  "SORT_MERGE_PASSES BIGINT unsigned not null,"
1374  "SORT_RANGE BIGINT unsigned not null,"
1375  "SORT_ROWS BIGINT unsigned not null,"
1376  "SORT_SCAN BIGINT unsigned not null,"
1377  "NO_INDEX_USED BIGINT unsigned not null,"
1378  "NO_GOOD_INDEX_USED BIGINT unsigned not null,"
1379  "NESTING_EVENT_ID BIGINT unsigned,"
1380  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT'),"
1381  "NESTING_EVENT_LEVEL INTEGER"
1382  ")ENGINE=PERFORMANCE_SCHEMA;";
1383
1384SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1385PREPARE stmt FROM @str;
1386EXECUTE stmt;
1387DROP PREPARE stmt;
1388
1389--
1390-- TABLE EVENTS_STATEMENTS_HISTORY_LONG
1391--
1392
1393SET @cmd="CREATE TABLE performance_schema.events_statements_history_long("
1394  "THREAD_ID BIGINT unsigned not null,"
1395  "EVENT_ID BIGINT unsigned not null,"
1396  "END_EVENT_ID BIGINT unsigned,"
1397  "EVENT_NAME VARCHAR(128) not null,"
1398  "SOURCE VARCHAR(64),"
1399  "TIMER_START BIGINT unsigned,"
1400  "TIMER_END BIGINT unsigned,"
1401  "TIMER_WAIT BIGINT unsigned,"
1402  "LOCK_TIME bigint unsigned not null,"
1403  "SQL_TEXT LONGTEXT,"
1404  "DIGEST VARCHAR(32),"
1405  "DIGEST_TEXT LONGTEXT,"
1406  "CURRENT_SCHEMA VARCHAR(64),"
1407  "OBJECT_TYPE VARCHAR(64),"
1408  "OBJECT_SCHEMA VARCHAR(64),"
1409  "OBJECT_NAME VARCHAR(64),"
1410  "OBJECT_INSTANCE_BEGIN BIGINT unsigned,"
1411  "MYSQL_ERRNO INTEGER,"
1412  "RETURNED_SQLSTATE VARCHAR(5),"
1413  "MESSAGE_TEXT VARCHAR(128),"
1414  "ERRORS BIGINT unsigned not null,"
1415  "WARNINGS BIGINT unsigned not null,"
1416  "ROWS_AFFECTED BIGINT unsigned not null,"
1417  "ROWS_SENT BIGINT unsigned not null,"
1418  "ROWS_EXAMINED BIGINT unsigned not null,"
1419  "CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
1420  "CREATED_TMP_TABLES BIGINT unsigned not null,"
1421  "SELECT_FULL_JOIN BIGINT unsigned not null,"
1422  "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
1423  "SELECT_RANGE BIGINT unsigned not null,"
1424  "SELECT_RANGE_CHECK BIGINT unsigned not null,"
1425  "SELECT_SCAN BIGINT unsigned not null,"
1426  "SORT_MERGE_PASSES BIGINT unsigned not null,"
1427  "SORT_RANGE BIGINT unsigned not null,"
1428  "SORT_ROWS BIGINT unsigned not null,"
1429  "SORT_SCAN BIGINT unsigned not null,"
1430  "NO_INDEX_USED BIGINT unsigned not null,"
1431  "NO_GOOD_INDEX_USED BIGINT unsigned not null,"
1432  "NESTING_EVENT_ID BIGINT unsigned,"
1433  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT'),"
1434  "NESTING_EVENT_LEVEL INTEGER"
1435  ")ENGINE=PERFORMANCE_SCHEMA;";
1436
1437SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1438PREPARE stmt FROM @str;
1439EXECUTE stmt;
1440DROP PREPARE stmt;
1441
1442--
1443-- TABLE EVENTS_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME
1444--
1445
1446SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_thread_by_event_name("
1447  "THREAD_ID BIGINT unsigned not null,"
1448  "EVENT_NAME VARCHAR(128) not null,"
1449  "COUNT_STAR BIGINT unsigned not null,"
1450  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1451  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1452  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1453  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1454  "SUM_LOCK_TIME BIGINT unsigned not null,"
1455  "SUM_ERRORS BIGINT unsigned not null,"
1456  "SUM_WARNINGS BIGINT unsigned not null,"
1457  "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
1458  "SUM_ROWS_SENT BIGINT unsigned not null,"
1459  "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
1460  "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
1461  "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
1462  "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
1463  "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
1464  "SUM_SELECT_RANGE BIGINT unsigned not null,"
1465  "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
1466  "SUM_SELECT_SCAN BIGINT unsigned not null,"
1467  "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
1468  "SUM_SORT_RANGE BIGINT unsigned not null,"
1469  "SUM_SORT_ROWS BIGINT unsigned not null,"
1470  "SUM_SORT_SCAN BIGINT unsigned not null,"
1471  "SUM_NO_INDEX_USED BIGINT unsigned not null,"
1472  "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
1473  ")ENGINE=PERFORMANCE_SCHEMA;";
1474
1475SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1476PREPARE stmt FROM @str;
1477EXECUTE stmt;
1478DROP PREPARE stmt;
1479
1480--
1481-- TABLE EVENTS_STATEMENTS_SUMMARY_BY_HOST_BY_EVENT_NAME
1482--
1483
1484SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_host_by_event_name("
1485  "HOST CHAR(60) collate utf8_bin default null,"
1486  "EVENT_NAME VARCHAR(128) not null,"
1487  "COUNT_STAR BIGINT unsigned not null,"
1488  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1489  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1490  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1491  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1492  "SUM_LOCK_TIME BIGINT unsigned not null,"
1493  "SUM_ERRORS BIGINT unsigned not null,"
1494  "SUM_WARNINGS BIGINT unsigned not null,"
1495  "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
1496  "SUM_ROWS_SENT BIGINT unsigned not null,"
1497  "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
1498  "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
1499  "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
1500  "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
1501  "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
1502  "SUM_SELECT_RANGE BIGINT unsigned not null,"
1503  "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
1504  "SUM_SELECT_SCAN BIGINT unsigned not null,"
1505  "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
1506  "SUM_SORT_RANGE BIGINT unsigned not null,"
1507  "SUM_SORT_ROWS BIGINT unsigned not null,"
1508  "SUM_SORT_SCAN BIGINT unsigned not null,"
1509  "SUM_NO_INDEX_USED BIGINT unsigned not null,"
1510  "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
1511  ")ENGINE=PERFORMANCE_SCHEMA;";
1512
1513SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1514PREPARE stmt FROM @str;
1515EXECUTE stmt;
1516DROP PREPARE stmt;
1517
1518--
1519-- TABLE EVENTS_STATEMENTS_SUMMARY_BY_USER_BY_EVENT_NAME
1520--
1521
1522SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_user_by_event_name("
1523  "USER CHAR(32) collate utf8_bin default null,"
1524  "EVENT_NAME VARCHAR(128) not null,"
1525  "COUNT_STAR BIGINT unsigned not null,"
1526  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1527  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1528  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1529  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1530  "SUM_LOCK_TIME BIGINT unsigned not null,"
1531  "SUM_ERRORS BIGINT unsigned not null,"
1532  "SUM_WARNINGS BIGINT unsigned not null,"
1533  "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
1534  "SUM_ROWS_SENT BIGINT unsigned not null,"
1535  "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
1536  "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
1537  "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
1538  "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
1539  "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
1540  "SUM_SELECT_RANGE BIGINT unsigned not null,"
1541  "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
1542  "SUM_SELECT_SCAN BIGINT unsigned not null,"
1543  "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
1544  "SUM_SORT_RANGE BIGINT unsigned not null,"
1545  "SUM_SORT_ROWS BIGINT unsigned not null,"
1546  "SUM_SORT_SCAN BIGINT unsigned not null,"
1547  "SUM_NO_INDEX_USED BIGINT unsigned not null,"
1548  "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
1549  ")ENGINE=PERFORMANCE_SCHEMA;";
1550
1551SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1552PREPARE stmt FROM @str;
1553EXECUTE stmt;
1554DROP PREPARE stmt;
1555
1556--
1557-- TABLE EVENTS_STATEMENTS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
1558--
1559
1560SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_account_by_event_name("
1561  "USER CHAR(32) collate utf8_bin default null,"
1562  "HOST CHAR(60) collate utf8_bin default null,"
1563  "EVENT_NAME VARCHAR(128) not null,"
1564  "COUNT_STAR BIGINT unsigned not null,"
1565  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1566  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1567  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1568  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1569  "SUM_LOCK_TIME BIGINT unsigned not null,"
1570  "SUM_ERRORS BIGINT unsigned not null,"
1571  "SUM_WARNINGS BIGINT unsigned not null,"
1572  "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
1573  "SUM_ROWS_SENT BIGINT unsigned not null,"
1574  "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
1575  "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
1576  "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
1577  "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
1578  "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
1579  "SUM_SELECT_RANGE BIGINT unsigned not null,"
1580  "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
1581  "SUM_SELECT_SCAN BIGINT unsigned not null,"
1582  "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
1583  "SUM_SORT_RANGE BIGINT unsigned not null,"
1584  "SUM_SORT_ROWS BIGINT unsigned not null,"
1585  "SUM_SORT_SCAN BIGINT unsigned not null,"
1586  "SUM_NO_INDEX_USED BIGINT unsigned not null,"
1587  "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
1588  ")ENGINE=PERFORMANCE_SCHEMA;";
1589
1590SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1591PREPARE stmt FROM @str;
1592EXECUTE stmt;
1593DROP PREPARE stmt;
1594
1595--
1596-- TABLE EVENTS_STATEMENTS_SUMMARY_GLOBAL_BY_EVENT_NAME
1597--
1598
1599SET @cmd="CREATE TABLE performance_schema.events_statements_summary_global_by_event_name("
1600  "EVENT_NAME VARCHAR(128) not null,"
1601  "COUNT_STAR BIGINT unsigned not null,"
1602  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1603  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1604  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1605  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1606  "SUM_LOCK_TIME BIGINT unsigned not null,"
1607  "SUM_ERRORS BIGINT unsigned not null,"
1608  "SUM_WARNINGS BIGINT unsigned not null,"
1609  "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
1610  "SUM_ROWS_SENT BIGINT unsigned not null,"
1611  "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
1612  "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
1613  "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
1614  "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
1615  "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
1616  "SUM_SELECT_RANGE BIGINT unsigned not null,"
1617  "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
1618  "SUM_SELECT_SCAN BIGINT unsigned not null,"
1619  "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
1620  "SUM_SORT_RANGE BIGINT unsigned not null,"
1621  "SUM_SORT_ROWS BIGINT unsigned not null,"
1622  "SUM_SORT_SCAN BIGINT unsigned not null,"
1623  "SUM_NO_INDEX_USED BIGINT unsigned not null,"
1624  "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
1625  ")ENGINE=PERFORMANCE_SCHEMA;";
1626
1627SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1628PREPARE stmt FROM @str;
1629EXECUTE stmt;
1630DROP PREPARE stmt;
1631
1632--
1633-- TABLE EVENTS_TRANSACTIONS_CURRENT
1634--
1635
1636SET @cmd="CREATE TABLE performance_schema.events_transactions_current("
1637  "THREAD_ID BIGINT unsigned not null,"
1638  "EVENT_ID BIGINT unsigned not null,"
1639  "END_EVENT_ID BIGINT unsigned,"
1640  "EVENT_NAME VARCHAR(128) not null,"
1641  "STATE ENUM('ACTIVE', 'COMMITTED', 'ROLLED BACK'),"
1642  "TRX_ID BIGINT unsigned,"
1643  "GTID VARCHAR(64),"
1644  "XID_FORMAT_ID INTEGER,"
1645  "XID_GTRID VARCHAR(130),"
1646  "XID_BQUAL VARCHAR(130),"
1647  "XA_STATE VARCHAR(64),"
1648  "SOURCE VARCHAR(64),"
1649  "TIMER_START BIGINT unsigned,"
1650  "TIMER_END BIGINT unsigned,"
1651  "TIMER_WAIT BIGINT unsigned,"
1652  "ACCESS_MODE ENUM('READ ONLY', 'READ WRITE'),"
1653  "ISOLATION_LEVEL VARCHAR(64),"
1654  "AUTOCOMMIT ENUM('YES','NO') not null,"
1655  "NUMBER_OF_SAVEPOINTS BIGINT unsigned,"
1656  "NUMBER_OF_ROLLBACK_TO_SAVEPOINT BIGINT unsigned,"
1657  "NUMBER_OF_RELEASE_SAVEPOINT BIGINT unsigned,"
1658  "OBJECT_INSTANCE_BEGIN BIGINT unsigned,"
1659  "NESTING_EVENT_ID BIGINT unsigned,"
1660  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT')"
1661  ")ENGINE=PERFORMANCE_SCHEMA;";
1662
1663SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1664PREPARE stmt FROM @str;
1665EXECUTE stmt;
1666DROP PREPARE stmt;
1667
1668--
1669-- TABLE EVENTS_TRANSACTIONS_HISTORY
1670--
1671
1672SET @cmd="CREATE TABLE performance_schema.events_transactions_history("
1673  "THREAD_ID BIGINT unsigned not null,"
1674  "EVENT_ID BIGINT unsigned not null,"
1675  "END_EVENT_ID BIGINT unsigned,"
1676  "EVENT_NAME VARCHAR(128) not null,"
1677  "STATE ENUM('ACTIVE', 'COMMITTED', 'ROLLED BACK'),"
1678  "TRX_ID BIGINT unsigned,"
1679  "GTID VARCHAR(64),"
1680  "XID_FORMAT_ID INTEGER,"
1681  "XID_GTRID VARCHAR(130),"
1682  "XID_BQUAL VARCHAR(130),"
1683  "XA_STATE VARCHAR(64),"
1684  "SOURCE VARCHAR(64),"
1685  "TIMER_START BIGINT unsigned,"
1686  "TIMER_END BIGINT unsigned,"
1687  "TIMER_WAIT BIGINT unsigned,"
1688  "ACCESS_MODE ENUM('READ ONLY', 'READ WRITE'),"
1689  "ISOLATION_LEVEL VARCHAR(64),"
1690  "AUTOCOMMIT ENUM('YES','NO') not null,"
1691  "NUMBER_OF_SAVEPOINTS BIGINT unsigned,"
1692  "NUMBER_OF_ROLLBACK_TO_SAVEPOINT BIGINT unsigned,"
1693  "NUMBER_OF_RELEASE_SAVEPOINT BIGINT unsigned,"
1694  "OBJECT_INSTANCE_BEGIN BIGINT unsigned,"
1695  "NESTING_EVENT_ID BIGINT unsigned,"
1696  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT')"
1697  ")ENGINE=PERFORMANCE_SCHEMA;";
1698
1699SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1700PREPARE stmt FROM @str;
1701EXECUTE stmt;
1702DROP PREPARE stmt;
1703
1704--
1705-- TABLE EVENTS_TRANSACTIONS_HISTORY_LONG
1706--
1707
1708SET @cmd="CREATE TABLE performance_schema.events_transactions_history_long("
1709  "THREAD_ID BIGINT unsigned not null,"
1710  "EVENT_ID BIGINT unsigned not null,"
1711  "END_EVENT_ID BIGINT unsigned,"
1712  "EVENT_NAME VARCHAR(128) not null,"
1713  "STATE ENUM('ACTIVE', 'COMMITTED', 'ROLLED BACK'),"
1714  "TRX_ID BIGINT unsigned,"
1715  "GTID VARCHAR(64),"
1716  "XID_FORMAT_ID INTEGER,"
1717  "XID_GTRID VARCHAR(130),"
1718  "XID_BQUAL VARCHAR(130),"
1719  "XA_STATE VARCHAR(64),"
1720  "SOURCE VARCHAR(64),"
1721  "TIMER_START BIGINT unsigned,"
1722  "TIMER_END BIGINT unsigned,"
1723  "TIMER_WAIT BIGINT unsigned,"
1724  "ACCESS_MODE ENUM('READ ONLY', 'READ WRITE'),"
1725  "ISOLATION_LEVEL VARCHAR(64),"
1726  "AUTOCOMMIT ENUM('YES','NO') not null,"
1727  "NUMBER_OF_SAVEPOINTS BIGINT unsigned,"
1728  "NUMBER_OF_ROLLBACK_TO_SAVEPOINT BIGINT unsigned,"
1729  "NUMBER_OF_RELEASE_SAVEPOINT BIGINT unsigned,"
1730  "OBJECT_INSTANCE_BEGIN BIGINT unsigned,"
1731  "NESTING_EVENT_ID BIGINT unsigned,"
1732  "NESTING_EVENT_TYPE ENUM('TRANSACTION', 'STATEMENT', 'STAGE', 'WAIT')"
1733  ")ENGINE=PERFORMANCE_SCHEMA;";
1734
1735SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1736PREPARE stmt FROM @str;
1737EXECUTE stmt;
1738DROP PREPARE stmt;
1739
1740--
1741-- TABLE EVENTS_TRANSACTIONS_SUMMARY_BY_THREAD_BY_EVENT_NAME
1742--
1743
1744SET @cmd="CREATE TABLE performance_schema.events_transactions_summary_by_thread_by_event_name("
1745  "THREAD_ID BIGINT unsigned not null,"
1746  "EVENT_NAME VARCHAR(128) not null,"
1747  "COUNT_STAR BIGINT unsigned not null,"
1748  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1749  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1750  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1751  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1752  "COUNT_READ_WRITE BIGINT unsigned not null,"
1753  "SUM_TIMER_READ_WRITE BIGINT unsigned not null,"
1754  "MIN_TIMER_READ_WRITE BIGINT unsigned not null,"
1755  "AVG_TIMER_READ_WRITE BIGINT unsigned not null,"
1756  "MAX_TIMER_READ_WRITE BIGINT unsigned not null,"
1757  "COUNT_READ_ONLY BIGINT unsigned not null,"
1758  "SUM_TIMER_READ_ONLY BIGINT unsigned not null,"
1759  "MIN_TIMER_READ_ONLY BIGINT unsigned not null,"
1760  "AVG_TIMER_READ_ONLY BIGINT unsigned not null,"
1761  "MAX_TIMER_READ_ONLY BIGINT unsigned not null"
1762  ")ENGINE=PERFORMANCE_SCHEMA;";
1763
1764SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1765PREPARE stmt FROM @str;
1766EXECUTE stmt;
1767DROP PREPARE stmt;
1768
1769--
1770-- TABLE EVENTS_TRANSACTIONS_SUMMARY_BY_HOST_BY_EVENT_NAME
1771--
1772
1773SET @cmd="CREATE TABLE performance_schema.events_transactions_summary_by_host_by_event_name("
1774  "HOST CHAR(60) collate utf8_bin default null,"
1775  "EVENT_NAME VARCHAR(128) not null,"
1776  "COUNT_STAR BIGINT unsigned not null,"
1777  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1778  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1779  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1780  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1781  "COUNT_READ_WRITE BIGINT unsigned not null,"
1782  "SUM_TIMER_READ_WRITE BIGINT unsigned not null,"
1783  "MIN_TIMER_READ_WRITE BIGINT unsigned not null,"
1784  "AVG_TIMER_READ_WRITE BIGINT unsigned not null,"
1785  "MAX_TIMER_READ_WRITE BIGINT unsigned not null,"
1786  "COUNT_READ_ONLY BIGINT unsigned not null,"
1787  "SUM_TIMER_READ_ONLY BIGINT unsigned not null,"
1788  "MIN_TIMER_READ_ONLY BIGINT unsigned not null,"
1789  "AVG_TIMER_READ_ONLY BIGINT unsigned not null,"
1790  "MAX_TIMER_READ_ONLY BIGINT unsigned not null"
1791  ")ENGINE=PERFORMANCE_SCHEMA;";
1792
1793SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1794PREPARE stmt FROM @str;
1795EXECUTE stmt;
1796DROP PREPARE stmt;
1797
1798--
1799-- TABLE EVENTS_TRANSACTIONS_SUMMARY_BY_USER_BY_EVENT_NAME
1800--
1801
1802SET @cmd="CREATE TABLE performance_schema.events_transactions_summary_by_user_by_event_name("
1803  "USER CHAR(32) collate utf8_bin default null,"
1804  "EVENT_NAME VARCHAR(128) not null,"
1805  "COUNT_STAR BIGINT unsigned not null,"
1806  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1807  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1808  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1809  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1810  "COUNT_READ_WRITE BIGINT unsigned not null,"
1811  "SUM_TIMER_READ_WRITE BIGINT unsigned not null,"
1812  "MIN_TIMER_READ_WRITE BIGINT unsigned not null,"
1813  "AVG_TIMER_READ_WRITE BIGINT unsigned not null,"
1814  "MAX_TIMER_READ_WRITE BIGINT unsigned not null,"
1815  "COUNT_READ_ONLY BIGINT unsigned not null,"
1816  "SUM_TIMER_READ_ONLY BIGINT unsigned not null,"
1817  "MIN_TIMER_READ_ONLY BIGINT unsigned not null,"
1818  "AVG_TIMER_READ_ONLY BIGINT unsigned not null,"
1819  "MAX_TIMER_READ_ONLY BIGINT unsigned not null"
1820  ")ENGINE=PERFORMANCE_SCHEMA;";
1821
1822SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1823PREPARE stmt FROM @str;
1824EXECUTE stmt;
1825DROP PREPARE stmt;
1826
1827--
1828-- TABLE EVENTS_TRANSACTIONS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
1829--
1830
1831SET @cmd="CREATE TABLE performance_schema.events_transactions_summary_by_account_by_event_name("
1832  "USER CHAR(32) collate utf8_bin default null,"
1833  "HOST CHAR(60) collate utf8_bin default null,"
1834  "EVENT_NAME VARCHAR(128) not null,"
1835  "COUNT_STAR BIGINT unsigned not null,"
1836  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1837  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1838  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1839  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1840  "COUNT_READ_WRITE BIGINT unsigned not null,"
1841  "SUM_TIMER_READ_WRITE BIGINT unsigned not null,"
1842  "MIN_TIMER_READ_WRITE BIGINT unsigned not null,"
1843  "AVG_TIMER_READ_WRITE BIGINT unsigned not null,"
1844  "MAX_TIMER_READ_WRITE BIGINT unsigned not null,"
1845  "COUNT_READ_ONLY BIGINT unsigned not null,"
1846  "SUM_TIMER_READ_ONLY BIGINT unsigned not null,"
1847  "MIN_TIMER_READ_ONLY BIGINT unsigned not null,"
1848  "AVG_TIMER_READ_ONLY BIGINT unsigned not null,"
1849  "MAX_TIMER_READ_ONLY BIGINT unsigned not null"
1850  ")ENGINE=PERFORMANCE_SCHEMA;";
1851
1852SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1853PREPARE stmt FROM @str;
1854EXECUTE stmt;
1855DROP PREPARE stmt;
1856
1857--
1858-- TABLE EVENTS_TRANSACTIONS_SUMMARY_GLOBAL_BY_EVENT_NAME
1859--
1860
1861SET @cmd="CREATE TABLE performance_schema.events_transactions_summary_global_by_event_name("
1862  "EVENT_NAME VARCHAR(128) not null,"
1863  "COUNT_STAR BIGINT unsigned not null,"
1864  "SUM_TIMER_WAIT BIGINT unsigned not null,"
1865  "MIN_TIMER_WAIT BIGINT unsigned not null,"
1866  "AVG_TIMER_WAIT BIGINT unsigned not null,"
1867  "MAX_TIMER_WAIT BIGINT unsigned not null,"
1868  "COUNT_READ_WRITE BIGINT unsigned not null,"
1869  "SUM_TIMER_READ_WRITE BIGINT unsigned not null,"
1870  "MIN_TIMER_READ_WRITE BIGINT unsigned not null,"
1871  "AVG_TIMER_READ_WRITE BIGINT unsigned not null,"
1872  "MAX_TIMER_READ_WRITE BIGINT unsigned not null,"
1873  "COUNT_READ_ONLY BIGINT unsigned not null,"
1874  "SUM_TIMER_READ_ONLY BIGINT unsigned not null,"
1875  "MIN_TIMER_READ_ONLY BIGINT unsigned not null,"
1876  "AVG_TIMER_READ_ONLY BIGINT unsigned not null,"
1877  "MAX_TIMER_READ_ONLY BIGINT unsigned not null"
1878  ")ENGINE=PERFORMANCE_SCHEMA;";
1879
1880SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1881PREPARE stmt FROM @str;
1882EXECUTE stmt;
1883DROP PREPARE stmt;
1884
1885--
1886-- TABLE HOSTS
1887--
1888
1889SET @cmd="CREATE TABLE performance_schema.hosts("
1890  "HOST CHAR(60) collate utf8_bin default null,"
1891  "CURRENT_CONNECTIONS bigint not null,"
1892  "TOTAL_CONNECTIONS bigint not null"
1893  ")ENGINE=PERFORMANCE_SCHEMA;";
1894
1895SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1896PREPARE stmt FROM @str;
1897EXECUTE stmt;
1898DROP PREPARE stmt;
1899
1900--
1901-- TABLE USERS
1902--
1903
1904SET @cmd="CREATE TABLE performance_schema.users("
1905  "USER CHAR(32) collate utf8_bin default null,"
1906  "CURRENT_CONNECTIONS bigint not null,"
1907  "TOTAL_CONNECTIONS bigint not null"
1908  ")ENGINE=PERFORMANCE_SCHEMA;";
1909
1910SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1911PREPARE stmt FROM @str;
1912EXECUTE stmt;
1913DROP PREPARE stmt;
1914
1915--
1916-- TABLE ACCOUNTS
1917--
1918
1919SET @cmd="CREATE TABLE performance_schema.accounts("
1920  "USER CHAR(32) collate utf8_bin default null,"
1921  "HOST CHAR(60) collate utf8_bin default null,"
1922  "CURRENT_CONNECTIONS bigint not null,"
1923  "TOTAL_CONNECTIONS bigint not null"
1924  ")ENGINE=PERFORMANCE_SCHEMA;";
1925
1926SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1927PREPARE stmt FROM @str;
1928EXECUTE stmt;
1929DROP PREPARE stmt;
1930
1931--
1932-- TABLE MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME
1933--
1934
1935SET @cmd="CREATE TABLE performance_schema.memory_summary_global_by_event_name("
1936  "EVENT_NAME VARCHAR(128) not null,"
1937  "COUNT_ALLOC BIGINT unsigned not null,"
1938  "COUNT_FREE BIGINT unsigned not null,"
1939  "SUM_NUMBER_OF_BYTES_ALLOC BIGINT unsigned not null,"
1940  "SUM_NUMBER_OF_BYTES_FREE BIGINT unsigned not null,"
1941  "LOW_COUNT_USED BIGINT not null,"
1942  "CURRENT_COUNT_USED BIGINT not null,"
1943  "HIGH_COUNT_USED BIGINT not null,"
1944  "LOW_NUMBER_OF_BYTES_USED BIGINT not null,"
1945  "CURRENT_NUMBER_OF_BYTES_USED BIGINT not null,"
1946  "HIGH_NUMBER_OF_BYTES_USED BIGINT not null"
1947  ")ENGINE=PERFORMANCE_SCHEMA;";
1948
1949SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1950PREPARE stmt FROM @str;
1951EXECUTE stmt;
1952DROP PREPARE stmt;
1953
1954--
1955-- TABLE MEMORY_SUMMARY_BY_THREAD_BY_EVENT_NAME
1956--
1957
1958SET @cmd="CREATE TABLE performance_schema.memory_summary_by_thread_by_event_name("
1959  "THREAD_ID BIGINT unsigned not null,"
1960  "EVENT_NAME VARCHAR(128) not null,"
1961  "COUNT_ALLOC BIGINT unsigned not null,"
1962  "COUNT_FREE BIGINT unsigned not null,"
1963  "SUM_NUMBER_OF_BYTES_ALLOC BIGINT unsigned not null,"
1964  "SUM_NUMBER_OF_BYTES_FREE BIGINT unsigned not null,"
1965  "LOW_COUNT_USED BIGINT not null,"
1966  "CURRENT_COUNT_USED BIGINT not null,"
1967  "HIGH_COUNT_USED BIGINT not null,"
1968  "LOW_NUMBER_OF_BYTES_USED BIGINT not null,"
1969  "CURRENT_NUMBER_OF_BYTES_USED BIGINT not null,"
1970  "HIGH_NUMBER_OF_BYTES_USED BIGINT not null"
1971  ")ENGINE=PERFORMANCE_SCHEMA;";
1972
1973SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1974PREPARE stmt FROM @str;
1975EXECUTE stmt;
1976DROP PREPARE stmt;
1977
1978--
1979-- TABLE MEMORY_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
1980--
1981
1982SET @cmd="CREATE TABLE performance_schema.memory_summary_by_account_by_event_name("
1983  "USER CHAR(32) collate utf8_bin default null,"
1984  "HOST CHAR(60) collate utf8_bin default null,"
1985  "EVENT_NAME VARCHAR(128) not null,"
1986  "COUNT_ALLOC BIGINT unsigned not null,"
1987  "COUNT_FREE BIGINT unsigned not null,"
1988  "SUM_NUMBER_OF_BYTES_ALLOC BIGINT unsigned not null,"
1989  "SUM_NUMBER_OF_BYTES_FREE BIGINT unsigned not null,"
1990  "LOW_COUNT_USED BIGINT not null,"
1991  "CURRENT_COUNT_USED BIGINT not null,"
1992  "HIGH_COUNT_USED BIGINT not null,"
1993  "LOW_NUMBER_OF_BYTES_USED BIGINT not null,"
1994  "CURRENT_NUMBER_OF_BYTES_USED BIGINT not null,"
1995  "HIGH_NUMBER_OF_BYTES_USED BIGINT not null"
1996  ")ENGINE=PERFORMANCE_SCHEMA;";
1997
1998SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
1999PREPARE stmt FROM @str;
2000EXECUTE stmt;
2001DROP PREPARE stmt;
2002
2003--
2004-- TABLE MEMORY_SUMMARY_BY_HOST_BY_EVENT_NAME
2005--
2006
2007SET @cmd="CREATE TABLE performance_schema.memory_summary_by_host_by_event_name("
2008  "HOST CHAR(60) collate utf8_bin default null,"
2009  "EVENT_NAME VARCHAR(128) not null,"
2010  "COUNT_ALLOC BIGINT unsigned not null,"
2011  "COUNT_FREE BIGINT unsigned not null,"
2012  "SUM_NUMBER_OF_BYTES_ALLOC BIGINT unsigned not null,"
2013  "SUM_NUMBER_OF_BYTES_FREE BIGINT unsigned not null,"
2014  "LOW_COUNT_USED BIGINT not null,"
2015  "CURRENT_COUNT_USED BIGINT not null,"
2016  "HIGH_COUNT_USED BIGINT not null,"
2017  "LOW_NUMBER_OF_BYTES_USED BIGINT not null,"
2018  "CURRENT_NUMBER_OF_BYTES_USED BIGINT not null,"
2019  "HIGH_NUMBER_OF_BYTES_USED BIGINT not null"
2020  ")ENGINE=PERFORMANCE_SCHEMA;";
2021
2022SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2023PREPARE stmt FROM @str;
2024EXECUTE stmt;
2025DROP PREPARE stmt;
2026
2027--
2028-- TABLE MEMORY_SUMMARY_BY_USER_BY_EVENT_NAME
2029--
2030
2031SET @cmd="CREATE TABLE performance_schema.memory_summary_by_user_by_event_name("
2032  "USER CHAR(32) collate utf8_bin default null,"
2033  "EVENT_NAME VARCHAR(128) not null,"
2034  "COUNT_ALLOC BIGINT unsigned not null,"
2035  "COUNT_FREE BIGINT unsigned not null,"
2036  "SUM_NUMBER_OF_BYTES_ALLOC BIGINT unsigned not null,"
2037  "SUM_NUMBER_OF_BYTES_FREE BIGINT unsigned not null,"
2038  "LOW_COUNT_USED BIGINT not null,"
2039  "CURRENT_COUNT_USED BIGINT not null,"
2040  "HIGH_COUNT_USED BIGINT not null,"
2041  "LOW_NUMBER_OF_BYTES_USED BIGINT not null,"
2042  "CURRENT_NUMBER_OF_BYTES_USED BIGINT not null,"
2043  "HIGH_NUMBER_OF_BYTES_USED BIGINT not null"
2044  ")ENGINE=PERFORMANCE_SCHEMA;";
2045
2046SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2047PREPARE stmt FROM @str;
2048EXECUTE stmt;
2049DROP PREPARE stmt;
2050
2051--
2052-- TABLE EVENTS_STATEMENTS_SUMMARY_BY_DIGEST
2053--
2054
2055SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_digest("
2056  "SCHEMA_NAME VARCHAR(64),"
2057  "DIGEST VARCHAR(32),"
2058  "DIGEST_TEXT LONGTEXT,"
2059  "COUNT_STAR BIGINT unsigned not null,"
2060  "SUM_TIMER_WAIT BIGINT unsigned not null,"
2061  "MIN_TIMER_WAIT BIGINT unsigned not null,"
2062  "AVG_TIMER_WAIT BIGINT unsigned not null,"
2063  "MAX_TIMER_WAIT BIGINT unsigned not null,"
2064  "SUM_LOCK_TIME BIGINT unsigned not null,"
2065  "SUM_ERRORS BIGINT unsigned not null,"
2066  "SUM_WARNINGS BIGINT unsigned not null,"
2067  "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
2068  "SUM_ROWS_SENT BIGINT unsigned not null,"
2069  "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
2070  "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
2071  "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
2072  "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
2073  "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
2074  "SUM_SELECT_RANGE BIGINT unsigned not null,"
2075  "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
2076  "SUM_SELECT_SCAN BIGINT unsigned not null,"
2077  "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
2078  "SUM_SORT_RANGE BIGINT unsigned not null,"
2079  "SUM_SORT_ROWS BIGINT unsigned not null,"
2080  "SUM_SORT_SCAN BIGINT unsigned not null,"
2081  "SUM_NO_INDEX_USED BIGINT unsigned not null,"
2082  "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null,"
2083  "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0,"
2084  "LAST_SEEN TIMESTAMP(0) NOT NULL default 0"
2085  ")ENGINE=PERFORMANCE_SCHEMA;";
2086
2087
2088SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2089PREPARE stmt FROM @str;
2090EXECUTE stmt;
2091DROP PREPARE stmt;
2092
2093--
2094-- TABLE EVENTS_STATEMENTS_SUMMARY_BY_PROGRAM
2095--
2096
2097SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_program("
2098  "OBJECT_TYPE enum('EVENT', 'FUNCTION', 'PROCEDURE', 'TABLE', 'TRIGGER'),"
2099  "OBJECT_SCHEMA varchar(64) NOT NULL,"
2100  "OBJECT_NAME varchar(64) NOT NULL,"
2101  "COUNT_STAR bigint(20) unsigned NOT NULL,"
2102  "SUM_TIMER_WAIT bigint(20) unsigned NOT NULL,"
2103  "MIN_TIMER_WAIT bigint(20) unsigned NOT NULL,"
2104  "AVG_TIMER_WAIT bigint(20) unsigned NOT NULL,"
2105  "MAX_TIMER_WAIT bigint(20) unsigned NOT NULL,"
2106  "COUNT_STATEMENTS bigint(20) unsigned NOT NULL,"
2107  "SUM_STATEMENTS_WAIT bigint(20) unsigned NOT NULL,"
2108  "MIN_STATEMENTS_WAIT bigint(20) unsigned NOT NULL,"
2109  "AVG_STATEMENTS_WAIT bigint(20) unsigned NOT NULL,"
2110  "MAX_STATEMENTS_WAIT bigint(20) unsigned NOT NULL,"
2111  "SUM_LOCK_TIME bigint(20) unsigned NOT NULL,"
2112  "SUM_ERRORS bigint(20) unsigned NOT NULL,"
2113  "SUM_WARNINGS bigint(20) unsigned NOT NULL,"
2114  "SUM_ROWS_AFFECTED bigint(20) unsigned NOT NULL,"
2115  "SUM_ROWS_SENT bigint(20) unsigned NOT NULL,"
2116  "SUM_ROWS_EXAMINED bigint(20) unsigned NOT NULL,"
2117  "SUM_CREATED_TMP_DISK_TABLES bigint(20) unsigned NOT NULL,"
2118  "SUM_CREATED_TMP_TABLES bigint(20) unsigned NOT NULL,"
2119  "SUM_SELECT_FULL_JOIN bigint(20) unsigned NOT NULL,"
2120  "SUM_SELECT_FULL_RANGE_JOIN bigint(20) unsigned NOT NULL,"
2121  "SUM_SELECT_RANGE bigint(20) unsigned NOT NULL,"
2122  "SUM_SELECT_RANGE_CHECK bigint(20) unsigned NOT NULL,"
2123  "SUM_SELECT_SCAN bigint(20) unsigned NOT NULL,"
2124  "SUM_SORT_MERGE_PASSES bigint(20) unsigned NOT NULL,"
2125  "SUM_SORT_RANGE bigint(20) unsigned NOT NULL,"
2126  "SUM_SORT_ROWS bigint(20) unsigned NOT NULL,"
2127  "SUM_SORT_SCAN bigint(20) unsigned NOT NULL,"
2128  "SUM_NO_INDEX_USED bigint(20) unsigned NOT NULL,"
2129  "SUM_NO_GOOD_INDEX_USED bigint(20) unsigned NOT NULL"
2130  ")ENGINE=PERFORMANCE_SCHEMA;";
2131
2132SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2133PREPARE stmt FROM @str;
2134EXECUTE stmt;
2135DROP PREPARE stmt;
2136
2137--
2138-- TABLE PREPARED_STATEMENT_INSTANCES
2139--
2140
2141SET @cmd="CREATE TABLE performance_schema.prepared_statements_instances("
2142  "OBJECT_INSTANCE_BEGIN bigint(20) unsigned NOT NULL,"
2143  "STATEMENT_ID bigint(20) unsigned NOT NULL,"
2144  "STATEMENT_NAME varchar(64) default NULL,"
2145  "SQL_TEXT longtext NOT NULL,"
2146  "OWNER_THREAD_ID bigint(20) unsigned NOT NULL,"
2147  "OWNER_EVENT_ID bigint(20) unsigned NOT NULL,"
2148  "OWNER_OBJECT_TYPE enum('EVENT','FUNCTION','PROCEDURE','TABLE','TRIGGER') DEFAULT NULL,"
2149  "OWNER_OBJECT_SCHEMA varchar(64) DEFAULT NULL,"
2150  "OWNER_OBJECT_NAME varchar(64) DEFAULT NULL,"
2151  "TIMER_PREPARE bigint(20) unsigned NOT NULL,"
2152  "COUNT_REPREPARE bigint(20) unsigned NOT NULL,"
2153  "COUNT_EXECUTE bigint(20) unsigned NOT NULL,"
2154  "SUM_TIMER_EXECUTE bigint(20) unsigned NOT NULL,"
2155  "MIN_TIMER_EXECUTE bigint(20) unsigned NOT NULL,"
2156  "AVG_TIMER_EXECUTE bigint(20) unsigned NOT NULL,"
2157  "MAX_TIMER_EXECUTE bigint(20) unsigned NOT NULL,"
2158  "SUM_LOCK_TIME bigint(20) unsigned NOT NULL,"
2159  "SUM_ERRORS bigint(20) unsigned NOT NULL,"
2160  "SUM_WARNINGS bigint(20) unsigned NOT NULL,"
2161  "SUM_ROWS_AFFECTED bigint(20) unsigned NOT NULL,"
2162  "SUM_ROWS_SENT bigint(20) unsigned NOT NULL,"
2163  "SUM_ROWS_EXAMINED bigint(20) unsigned NOT NULL,"
2164  "SUM_CREATED_TMP_DISK_TABLES bigint(20) unsigned NOT NULL,"
2165  "SUM_CREATED_TMP_TABLES bigint(20) unsigned NOT NULL,"
2166  "SUM_SELECT_FULL_JOIN bigint(20) unsigned NOT NULL,"
2167  "SUM_SELECT_FULL_RANGE_JOIN bigint(20) unsigned NOT NULL,"
2168  "SUM_SELECT_RANGE bigint(20) unsigned NOT NULL,"
2169  "SUM_SELECT_RANGE_CHECK bigint(20) unsigned NOT NULL,"
2170  "SUM_SELECT_SCAN bigint(20) unsigned NOT NULL,"
2171  "SUM_SORT_MERGE_PASSES bigint(20) unsigned NOT NULL,"
2172  "SUM_SORT_RANGE bigint(20) unsigned NOT NULL,"
2173  "SUM_SORT_ROWS bigint(20) unsigned NOT NULL,"
2174  "SUM_SORT_SCAN bigint(20) unsigned NOT NULL,"
2175  "SUM_NO_INDEX_USED bigint(20) unsigned NOT NULL,"
2176  "SUM_NO_GOOD_INDEX_USED bigint(20) unsigned NOT NULL"
2177  ")ENGINE=PERFORMANCE_SCHEMA;";
2178
2179SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2180PREPARE stmt FROM @str;
2181EXECUTE stmt;
2182DROP PREPARE stmt;
2183
2184--
2185-- TABLE replication_connection_configuration
2186--
2187
2188SET @cmd="CREATE TABLE performance_schema.replication_connection_configuration("
2189  "CHANNEL_NAME CHAR(64) collate utf8_general_ci not null,"
2190  "HOST CHAR(60) collate utf8_bin not null,"
2191  "PORT INTEGER not null,"
2192  "USER CHAR(32) collate utf8_bin not null,"
2193  "NETWORK_INTERFACE CHAR(60) collate utf8_bin not null,"
2194  "AUTO_POSITION ENUM('1','0') not null,"
2195  "SSL_ALLOWED ENUM('YES','NO','IGNORED') not null,"
2196  "SSL_CA_FILE VARCHAR(512) not null,"
2197  "SSL_CA_PATH VARCHAR(512) not null,"
2198  "SSL_CERTIFICATE VARCHAR(512) not null,"
2199  "SSL_CIPHER VARCHAR(512) not null,"
2200  "SSL_KEY VARCHAR(512) not null,"
2201  "SSL_VERIFY_SERVER_CERTIFICATE ENUM('YES','NO') not null,"
2202  "SSL_CRL_FILE VARCHAR(255) not null,"
2203  "SSL_CRL_PATH VARCHAR(255) not null,"
2204  "CONNECTION_RETRY_INTERVAL INTEGER not null,"
2205  "CONNECTION_RETRY_COUNT BIGINT unsigned not null,"
2206  "HEARTBEAT_INTERVAL DOUBLE(10,3) unsigned not null COMMENT 'Number of seconds after which a heartbeat will be sent .',"
2207  "TLS_VERSION VARCHAR(255) not null"
2208  ") ENGINE=PERFORMANCE_SCHEMA;";
2209
2210SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2211PREPARE stmt FROM @str;
2212EXECUTE stmt;
2213DROP PREPARE stmt;
2214
2215
2216--
2217-- TABLE replication_group_member_stats
2218--
2219
2220SET @cmd="CREATE TABLE performance_schema.replication_group_member_stats("
2221  "CHANNEL_NAME CHAR(64) collate utf8_general_ci not null,"
2222  "VIEW_ID CHAR(60) collate utf8_bin not null,"
2223  "MEMBER_ID CHAR(36) collate utf8_bin not null,"
2224  "COUNT_TRANSACTIONS_IN_QUEUE BIGINT unsigned not null,"
2225  "COUNT_TRANSACTIONS_CHECKED BIGINT unsigned not null,"
2226  "COUNT_CONFLICTS_DETECTED BIGINT unsigned not null,"
2227  "COUNT_TRANSACTIONS_ROWS_VALIDATING BIGINT unsigned not null,"
2228  "TRANSACTIONS_COMMITTED_ALL_MEMBERS LONGTEXT not null,"
2229  "LAST_CONFLICT_FREE_TRANSACTION TEXT not null"
2230  ") ENGINE=PERFORMANCE_SCHEMA;";
2231
2232SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2233PREPARE stmt FROM @str;
2234EXECUTE stmt;
2235DROP PREPARE stmt;
2236
2237
2238--
2239-- TABLE replication_group_members
2240--
2241
2242SET @cmd="CREATE TABLE performance_schema.replication_group_members("
2243  "CHANNEL_NAME CHAR(64) collate utf8_general_ci not null,"
2244  "MEMBER_ID CHAR(36) collate utf8_bin not null,"
2245  "MEMBER_HOST CHAR(60) collate utf8_bin not null,"
2246  "MEMBER_PORT INTEGER,"
2247  "MEMBER_STATE CHAR(64) collate utf8_bin not null"
2248  ") ENGINE=PERFORMANCE_SCHEMA;";
2249
2250 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2251 PREPARE stmt FROM @str;
2252 EXECUTE stmt;
2253 DROP PREPARE stmt;
2254
2255--
2256-- TABLE replication_connection_status
2257--
2258
2259SET @cmd="CREATE TABLE performance_schema.replication_connection_status("
2260  "CHANNEL_NAME CHAR(64) collate utf8_general_ci not null,"
2261  "GROUP_NAME CHAR(36) collate utf8_bin not null,"
2262  "SOURCE_UUID CHAR(36) collate utf8_bin not null,"
2263  "THREAD_ID BIGINT unsigned,"
2264  "SERVICE_STATE ENUM('ON','OFF','CONNECTING') not null,"
2265  "COUNT_RECEIVED_HEARTBEATS bigint unsigned NOT NULL DEFAULT 0,"
2266  "LAST_HEARTBEAT_TIMESTAMP TIMESTAMP(0) not null COMMENT 'Shows when the most recent heartbeat signal was received.',"
2267  "RECEIVED_TRANSACTION_SET LONGTEXT not null,"
2268  "LAST_ERROR_NUMBER INTEGER not null,"
2269  "LAST_ERROR_MESSAGE VARCHAR(1024) not null,"
2270  "LAST_ERROR_TIMESTAMP TIMESTAMP(0) not null"
2271  ") ENGINE=PERFORMANCE_SCHEMA;";
2272
2273SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2274PREPARE stmt FROM @str;
2275EXECUTE stmt;
2276DROP PREPARE stmt;
2277
2278--
2279-- TABLE replication_applier_configuration
2280--
2281
2282SET @cmd="CREATE TABLE performance_schema.replication_applier_configuration("
2283  "CHANNEL_NAME CHAR(64) collate utf8_general_ci not null,"
2284  "DESIRED_DELAY INTEGER not null"
2285  ") ENGINE=PERFORMANCE_SCHEMA;";
2286
2287SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2288PREPARE stmt FROM @str;
2289EXECUTE stmt;
2290DROP PREPARE stmt;
2291
2292--
2293-- TABLE replication_applier_status
2294--
2295
2296SET @cmd="CREATE TABLE performance_schema.replication_applier_status("
2297  "CHANNEL_NAME CHAR(64) collate utf8_general_ci not null,"
2298  "SERVICE_STATE ENUM('ON','OFF') not null,"
2299  "REMAINING_DELAY INTEGER unsigned,"
2300  "COUNT_TRANSACTIONS_RETRIES BIGINT unsigned not null"
2301  ") ENGINE=PERFORMANCE_SCHEMA;";
2302
2303SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2304PREPARE stmt FROM @str;
2305EXECUTE stmt;
2306DROP PREPARE stmt;
2307
2308--
2309-- TABLE replication_applier_status_by_coordinator
2310--
2311
2312SET @cmd="CREATE TABLE performance_schema.replication_applier_status_by_coordinator("
2313  "CHANNEL_NAME CHAR(64) collate utf8_general_ci not null,"
2314  "THREAD_ID BIGINT UNSIGNED,"
2315  "SERVICE_STATE ENUM('ON','OFF') not null,"
2316  "LAST_ERROR_NUMBER INTEGER not null,"
2317  "LAST_ERROR_MESSAGE VARCHAR(1024) not null,"
2318  "LAST_ERROR_TIMESTAMP TIMESTAMP(0) not null"
2319  ") ENGINE=PERFORMANCE_SCHEMA;";
2320
2321SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2322PREPARE stmt FROM @str;
2323EXECUTE stmt;
2324DROP PREPARE stmt;
2325
2326--
2327-- TABLE replication_applier_status_by_worker
2328--
2329
2330SET @cmd="CREATE TABLE performance_schema.replication_applier_status_by_worker("
2331  "CHANNEL_NAME CHAR(64) collate utf8_general_ci not null,"
2332  "WORKER_ID BIGINT UNSIGNED not null,"
2333  "THREAD_ID BIGINT UNSIGNED,"
2334  "SERVICE_STATE ENUM('ON','OFF') not null,"
2335  "LAST_SEEN_TRANSACTION CHAR(57) not null,"
2336  "LAST_ERROR_NUMBER INTEGER not null,"
2337  "LAST_ERROR_MESSAGE VARCHAR(1024) not null,"
2338  "LAST_ERROR_TIMESTAMP TIMESTAMP(0) not null"
2339  ") ENGINE=PERFORMANCE_SCHEMA;";
2340
2341SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2342PREPARE stmt FROM @str;
2343EXECUTE stmt;
2344DROP PREPARE stmt;
2345
2346--
2347-- TABLE SESSION_CONNECT_ATTRS
2348--
2349
2350SET @cmd="CREATE TABLE performance_schema.session_connect_attrs("
2351  "PROCESSLIST_ID INT NOT NULL,"
2352  "ATTR_NAME VARCHAR(32) NOT NULL,"
2353  "ATTR_VALUE VARCHAR(1024),"
2354  "ORDINAL_POSITION INT"
2355  ")ENGINE=PERFORMANCE_SCHEMA CHARACTER SET utf8 COLLATE utf8_bin;";
2356
2357SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2358PREPARE stmt FROM @str;
2359EXECUTE stmt;
2360DROP PREPARE stmt;
2361
2362--
2363-- TABLE SESSION_ACCOUNT_CONNECT_ATTRS
2364--
2365
2366SET @cmd="CREATE TABLE performance_schema.session_account_connect_attrs "
2367         " LIKE performance_schema.session_connect_attrs;";
2368
2369SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2370PREPARE stmt FROM @str;
2371EXECUTE stmt;
2372DROP PREPARE stmt;
2373
2374--
2375-- TABLE TABLE_HANDLES
2376--
2377
2378SET @cmd="CREATE TABLE performance_schema.table_handles("
2379  "OBJECT_TYPE VARCHAR(64) not null,"
2380  "OBJECT_SCHEMA VARCHAR(64) not null,"
2381  "OBJECT_NAME VARCHAR(64) not null,"
2382  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
2383  "OWNER_THREAD_ID BIGINT unsigned,"
2384  "OWNER_EVENT_ID BIGINT unsigned,"
2385  "INTERNAL_LOCK VARCHAR(64),"
2386  "EXTERNAL_LOCK VARCHAR(64)"
2387  ")ENGINE=PERFORMANCE_SCHEMA;";
2388
2389SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2390PREPARE stmt FROM @str;
2391EXECUTE stmt;
2392DROP PREPARE stmt;
2393
2394--
2395-- TABLE METADATA_LOCKS
2396--
2397
2398SET @cmd="CREATE TABLE performance_schema.metadata_locks("
2399  "OBJECT_TYPE VARCHAR(64) not null,"
2400  "OBJECT_SCHEMA VARCHAR(64),"
2401  "OBJECT_NAME VARCHAR(64),"
2402  "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
2403  "LOCK_TYPE VARCHAR(32) not null,"
2404  "LOCK_DURATION VARCHAR(32) not null,"
2405  "LOCK_STATUS VARCHAR(32) not null,"
2406  "SOURCE VARCHAR(64),"
2407  "OWNER_THREAD_ID BIGINT unsigned,"
2408  "OWNER_EVENT_ID BIGINT unsigned"
2409  ")ENGINE=PERFORMANCE_SCHEMA;";
2410
2411SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2412PREPARE stmt FROM @str;
2413EXECUTE stmt;
2414DROP PREPARE stmt;
2415
2416--
2417-- TABLE USER_VARIABLES_BY_THREAD
2418--
2419
2420SET @cmd="CREATE TABLE performance_schema.user_variables_by_thread("
2421  "THREAD_ID BIGINT unsigned not null,"
2422  "VARIABLE_NAME VARCHAR(64) not null,"
2423  "VARIABLE_VALUE LONGBLOB"
2424  ")ENGINE=PERFORMANCE_SCHEMA;";
2425
2426SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2427PREPARE stmt FROM @str;
2428EXECUTE stmt;
2429DROP PREPARE stmt;
2430
2431--
2432-- TABLE VARIABLES_BY_THREAD
2433--
2434
2435SET @cmd="CREATE TABLE performance_schema.variables_by_thread("
2436  "THREAD_ID BIGINT unsigned not null,"
2437  "VARIABLE_NAME VARCHAR(64) not null,"
2438  "VARIABLE_VALUE VARCHAR(1024)"
2439  ")ENGINE=PERFORMANCE_SCHEMA;";
2440
2441SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2442PREPARE stmt FROM @str;
2443EXECUTE stmt;
2444DROP PREPARE stmt;
2445
2446--
2447-- TABLE GLOBAL_VARIABLES
2448--
2449
2450SET @cmd="CREATE TABLE performance_schema.global_variables("
2451  "VARIABLE_NAME VARCHAR(64) not null,"
2452  "VARIABLE_VALUE VARCHAR(1024)"
2453  ")ENGINE=PERFORMANCE_SCHEMA;";
2454
2455SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2456PREPARE stmt FROM @str;
2457EXECUTE stmt;
2458DROP PREPARE stmt;
2459
2460--
2461-- TABLE SESSION_VARIABLES
2462--
2463
2464SET @cmd="CREATE TABLE performance_schema.session_variables("
2465  "VARIABLE_NAME VARCHAR(64) not null,"
2466  "VARIABLE_VALUE VARCHAR(1024)"
2467  ")ENGINE=PERFORMANCE_SCHEMA;";
2468
2469SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2470PREPARE stmt FROM @str;
2471EXECUTE stmt;
2472DROP PREPARE stmt;
2473
2474--
2475-- TABLE STATUS_BY_THREAD
2476--
2477
2478SET @cmd="CREATE TABLE performance_schema.status_by_thread("
2479  "THREAD_ID BIGINT unsigned not null,"
2480  "VARIABLE_NAME VARCHAR(64) not null,"
2481  "VARIABLE_VALUE VARCHAR(1024)"
2482  ")ENGINE=PERFORMANCE_SCHEMA;";
2483
2484SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2485PREPARE stmt FROM @str;
2486EXECUTE stmt;
2487DROP PREPARE stmt;
2488
2489--
2490-- TABLE STATUS_BY_USER
2491--
2492
2493SET @cmd="CREATE TABLE performance_schema.status_by_user("
2494  "USER CHAR(32) collate utf8_bin default null,"
2495  "VARIABLE_NAME VARCHAR(64) not null,"
2496  "VARIABLE_VALUE VARCHAR(1024)"
2497  ")ENGINE=PERFORMANCE_SCHEMA;";
2498
2499SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2500PREPARE stmt FROM @str;
2501EXECUTE stmt;
2502DROP PREPARE stmt;
2503
2504--
2505-- TABLE STATUS_BY_HOST
2506--
2507
2508SET @cmd="CREATE TABLE performance_schema.status_by_host("
2509  "HOST CHAR(60) collate utf8_bin default null,"
2510  "VARIABLE_NAME VARCHAR(64) not null,"
2511  "VARIABLE_VALUE VARCHAR(1024)"
2512  ")ENGINE=PERFORMANCE_SCHEMA;";
2513
2514SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2515PREPARE stmt FROM @str;
2516EXECUTE stmt;
2517DROP PREPARE stmt;
2518
2519--
2520-- TABLE STATUS_BY_ACCOUNT
2521--
2522
2523SET @cmd="CREATE TABLE performance_schema.status_by_account("
2524  "USER CHAR(32) collate utf8_bin default null,"
2525  "HOST CHAR(60) collate utf8_bin default null,"
2526  "VARIABLE_NAME VARCHAR(64) not null,"
2527  "VARIABLE_VALUE VARCHAR(1024)"
2528  ")ENGINE=PERFORMANCE_SCHEMA;";
2529
2530SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2531PREPARE stmt FROM @str;
2532EXECUTE stmt;
2533DROP PREPARE stmt;
2534
2535--
2536-- TABLE GLOBAL_STATUS
2537--
2538
2539SET @cmd="CREATE TABLE performance_schema.global_status("
2540  "VARIABLE_NAME VARCHAR(64) not null,"
2541  "VARIABLE_VALUE VARCHAR(1024)"
2542  ")ENGINE=PERFORMANCE_SCHEMA;";
2543
2544SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2545PREPARE stmt FROM @str;
2546EXECUTE stmt;
2547DROP PREPARE stmt;
2548
2549--
2550-- TABLE SESSION_STATUS
2551--
2552
2553SET @cmd="CREATE TABLE performance_schema.session_status("
2554  "VARIABLE_NAME VARCHAR(64) not null,"
2555  "VARIABLE_VALUE VARCHAR(1024)"
2556  ")ENGINE=PERFORMANCE_SCHEMA;";
2557
2558SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
2559PREPARE stmt FROM @str;
2560EXECUTE stmt;
2561DROP PREPARE stmt;
2562
2563CREATE TABLE IF NOT EXISTS proxies_priv (Host char(60) binary DEFAULT '' NOT NULL, User char(32) binary DEFAULT '' NOT NULL, Proxied_host char(60) binary DEFAULT '' NOT NULL, Proxied_user char(32) binary DEFAULT '' NOT NULL, With_grant BOOL DEFAULT 0 NOT NULL, Grantor char(93) DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY Host (Host,User,Proxied_host,Proxied_user), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User proxy privileges';
2564
2565-- Remember for later if proxies_priv table already existed
2566set @had_proxies_priv_table= @@warning_count != 0;
2567
2568#
2569# SQL commands for creating the tables in MySQL Server which
2570# are used by the NDBINFO storage engine to access system
2571# information and statistics from MySQL Cluster
2572#
2573# Only create objects if NDBINFO is supported
2574SELECT @have_ndbinfo:= COUNT(*) FROM information_schema.engines WHERE engine='NDBINFO' AND support IN ('YES', 'DEFAULT');
2575
2576# Only create objects if version >= 7.1
2577SET @str=IF(@have_ndbinfo,'SELECT @have_ndbinfo:= (@@ndbinfo_version >= (7 << 16) | (1 << 8)) || @ndbinfo_skip_version_check','SET @dummy = 0');
2578PREPARE stmt FROM @str;
2579EXECUTE stmt;
2580DROP PREPARE stmt;
2581
2582SET @str=IF(@have_ndbinfo,'CREATE DATABASE IF NOT EXISTS `ndbinfo`','SET @dummy = 0');
2583PREPARE stmt FROM @str;
2584EXECUTE stmt;
2585DROP PREPARE stmt;
2586
2587# Set NDBINFO in offline mode during (re)create of tables
2588# and views to avoid errors caused by no such table or
2589# different table definition in NDB
2590SET @str=IF(@have_ndbinfo,'SET @@global.ndbinfo_offline=TRUE','SET @dummy = 0');
2591PREPARE stmt FROM @str;
2592EXECUTE stmt;
2593DROP PREPARE stmt;
2594
2595# Drop obsolete lookups in ndbinfo
2596SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`blocks`','SET @dummy = 0');
2597PREPARE stmt FROM @str;
2598EXECUTE stmt;
2599DROP PREPARE stmt;
2600
2601SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`dict_obj_types`','SET @dummy = 0');
2602PREPARE stmt FROM @str;
2603EXECUTE stmt;
2604DROP PREPARE stmt;
2605
2606SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`config_params`','SET @dummy = 0');
2607PREPARE stmt FROM @str;
2608EXECUTE stmt;
2609DROP PREPARE stmt;
2610
2611SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$dbtc_apiconnect_state`','SET @dummy = 0');
2612PREPARE stmt FROM @str;
2613EXECUTE stmt;
2614DROP PREPARE stmt;
2615
2616SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$dblqh_tcconnect_state`','SET @dummy = 0');
2617PREPARE stmt FROM @str;
2618EXECUTE stmt;
2619DROP PREPARE stmt;
2620
2621# Drop any old views in ndbinfo
2622SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`transporters`','SET @dummy = 0');
2623PREPARE stmt FROM @str;
2624EXECUTE stmt;
2625DROP PREPARE stmt;
2626
2627SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`logspaces`','SET @dummy = 0');
2628PREPARE stmt FROM @str;
2629EXECUTE stmt;
2630DROP PREPARE stmt;
2631
2632SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`logbuffers`','SET @dummy = 0');
2633PREPARE stmt FROM @str;
2634EXECUTE stmt;
2635DROP PREPARE stmt;
2636
2637SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`resources`','SET @dummy = 0');
2638PREPARE stmt FROM @str;
2639EXECUTE stmt;
2640DROP PREPARE stmt;
2641
2642SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`counters`','SET @dummy = 0');
2643PREPARE stmt FROM @str;
2644EXECUTE stmt;
2645DROP PREPARE stmt;
2646
2647SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`nodes`','SET @dummy = 0');
2648PREPARE stmt FROM @str;
2649EXECUTE stmt;
2650DROP PREPARE stmt;
2651
2652SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`memoryusage`','SET @dummy = 0');
2653PREPARE stmt FROM @str;
2654EXECUTE stmt;
2655DROP PREPARE stmt;
2656
2657SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`diskpagebuffer`','SET @dummy = 0');
2658PREPARE stmt FROM @str;
2659EXECUTE stmt;
2660DROP PREPARE stmt;
2661
2662SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`diskpagebuffer`','SET @dummy = 0');
2663PREPARE stmt FROM @str;
2664EXECUTE stmt;
2665DROP PREPARE stmt;
2666
2667SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`threadblocks`','SET @dummy = 0');
2668PREPARE stmt FROM @str;
2669EXECUTE stmt;
2670DROP PREPARE stmt;
2671
2672SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`threadstat`','SET @dummy = 0');
2673PREPARE stmt FROM @str;
2674EXECUTE stmt;
2675DROP PREPARE stmt;
2676
2677SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`disk_write_speed_base`','SET @dummy = 0');
2678PREPARE stmt FROM @str;
2679EXECUTE stmt;
2680DROP PREPARE stmt;
2681
2682SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`disk_write_speed_aggregate`','SET @dummy = 0');
2683PREPARE stmt FROM @str;
2684EXECUTE stmt;
2685DROP PREPARE stmt;
2686
2687SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`restart_info`','SET @dummy = 0');
2688PREPARE stmt FROM @str;
2689EXECUTE stmt;
2690DROP PREPARE stmt;
2691
2692SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`cluster_transactions`','SET @dummy = 0');
2693PREPARE stmt FROM @str;
2694EXECUTE stmt;
2695DROP PREPARE stmt;
2696
2697SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`server_transactions`','SET @dummy = 0');
2698PREPARE stmt FROM @str;
2699EXECUTE stmt;
2700DROP PREPARE stmt;
2701
2702SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`cluster_operations`','SET @dummy = 0');
2703PREPARE stmt FROM @str;
2704EXECUTE stmt;
2705DROP PREPARE stmt;
2706
2707SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`server_operations`','SET @dummy = 0');
2708PREPARE stmt FROM @str;
2709EXECUTE stmt;
2710DROP PREPARE stmt;
2711
2712SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`membership`','SET @dummy = 0');
2713PREPARE stmt FROM @str;
2714EXECUTE stmt;
2715DROP PREPARE stmt;
2716
2717SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`arbitrator_validity_detail`','SET @dummy = 0');
2718PREPARE stmt FROM @str;
2719EXECUTE stmt;
2720DROP PREPARE stmt;
2721
2722SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`arbitrator_validity_summary`','SET @dummy = 0');
2723PREPARE stmt FROM @str;
2724EXECUTE stmt;
2725DROP PREPARE stmt;
2726
2727SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`memory_per_fragment`','SET @dummy = 0');
2728PREPARE stmt FROM @str;
2729EXECUTE stmt;
2730DROP PREPARE stmt;
2731
2732SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`operations_per_fragment`','SET @dummy = 0');
2733PREPARE stmt FROM @str;
2734EXECUTE stmt;
2735DROP PREPARE stmt;
2736
2737SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`blocks`','SET @dummy = 0');
2738PREPARE stmt FROM @str;
2739EXECUTE stmt;
2740DROP PREPARE stmt;
2741
2742SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`dict_obj_types`','SET @dummy = 0');
2743PREPARE stmt FROM @str;
2744EXECUTE stmt;
2745DROP PREPARE stmt;
2746
2747SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`config_params`','SET @dummy = 0');
2748PREPARE stmt FROM @str;
2749EXECUTE stmt;
2750DROP PREPARE stmt;
2751
2752# Drop any old lookup tables in ndbinfo
2753SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$blocks`','SET @dummy = 0');
2754PREPARE stmt FROM @str;
2755EXECUTE stmt;
2756DROP PREPARE stmt;
2757
2758SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$dict_obj_types`','SET @dummy = 0');
2759PREPARE stmt FROM @str;
2760EXECUTE stmt;
2761DROP PREPARE stmt;
2762
2763SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$config_params`','SET @dummy = 0');
2764PREPARE stmt FROM @str;
2765EXECUTE stmt;
2766DROP PREPARE stmt;
2767
2768SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$dbtc_apiconnect_state`','SET @dummy = 0');
2769PREPARE stmt FROM @str;
2770EXECUTE stmt;
2771DROP PREPARE stmt;
2772
2773SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$dblqh_tcconnect_state`','SET @dummy = 0');
2774PREPARE stmt FROM @str;
2775EXECUTE stmt;
2776DROP PREPARE stmt;
2777
2778# ndbinfo.ndb$tables
2779SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$tables`','SET @dummy = 0');
2780PREPARE stmt FROM @str;
2781EXECUTE stmt;
2782DROP PREPARE stmt;
2783
2784SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$tables` (`table_id` INT UNSIGNED,`table_name` VARCHAR(512),`comment` VARCHAR(512)) COMMENT="metadata for tables available through ndbinfo" ENGINE=NDBINFO','SET @dummy = 0');
2785PREPARE stmt FROM @str;
2786EXECUTE stmt;
2787DROP PREPARE stmt;
2788
2789# ndbinfo.ndb$columns
2790SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$columns`','SET @dummy = 0');
2791PREPARE stmt FROM @str;
2792EXECUTE stmt;
2793DROP PREPARE stmt;
2794
2795SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$columns` (`table_id` INT UNSIGNED,`column_id` INT UNSIGNED,`column_name` VARCHAR(512),`column_type` INT UNSIGNED,`comment` VARCHAR(512)) COMMENT="metadata for columns available through ndbinfo " ENGINE=NDBINFO','SET @dummy = 0');
2796PREPARE stmt FROM @str;
2797EXECUTE stmt;
2798DROP PREPARE stmt;
2799
2800# ndbinfo.ndb$test
2801SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$test`','SET @dummy = 0');
2802PREPARE stmt FROM @str;
2803EXECUTE stmt;
2804DROP PREPARE stmt;
2805
2806SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$test` (`node_id` INT UNSIGNED,`block_number` INT UNSIGNED,`block_instance` INT UNSIGNED,`counter` INT UNSIGNED,`counter2` BIGINT UNSIGNED) COMMENT="for testing" ENGINE=NDBINFO','SET @dummy = 0');
2807PREPARE stmt FROM @str;
2808EXECUTE stmt;
2809DROP PREPARE stmt;
2810
2811# ndbinfo.ndb$pools
2812SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$pools`','SET @dummy = 0');
2813PREPARE stmt FROM @str;
2814EXECUTE stmt;
2815DROP PREPARE stmt;
2816
2817SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$pools` (`node_id` INT UNSIGNED,`block_number` INT UNSIGNED,`block_instance` INT UNSIGNED,`pool_name` VARCHAR(512),`used` BIGINT UNSIGNED COMMENT "currently in use",`total` BIGINT UNSIGNED COMMENT "total allocated",`high` BIGINT UNSIGNED COMMENT "in use high water mark",`entry_size` BIGINT UNSIGNED COMMENT "size in bytes of each object",`config_param1` INT UNSIGNED COMMENT "config param 1 affecting pool",`config_param2` INT UNSIGNED COMMENT "config param 2 affecting pool",`config_param3` INT UNSIGNED COMMENT "config param 3 affecting pool",`config_param4` INT UNSIGNED COMMENT "config param 4 affecting pool") COMMENT="pool usage" ENGINE=NDBINFO','SET @dummy = 0');
2818PREPARE stmt FROM @str;
2819EXECUTE stmt;
2820DROP PREPARE stmt;
2821
2822# ndbinfo.ndb$transporters
2823SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$transporters`','SET @dummy = 0');
2824PREPARE stmt FROM @str;
2825EXECUTE stmt;
2826DROP PREPARE stmt;
2827
2828SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$transporters` (`node_id` INT UNSIGNED COMMENT "Node id reporting",`remote_node_id` INT UNSIGNED COMMENT "Node id at other end of link",`connection_status` INT UNSIGNED COMMENT "State of inter-node link",`remote_address` VARCHAR(512) COMMENT "Address of remote node",`bytes_sent` BIGINT UNSIGNED COMMENT "Bytes sent to remote node",`bytes_received` BIGINT UNSIGNED COMMENT "Bytes received from remote node",`connect_count` INT UNSIGNED COMMENT "Number of times connected",`overloaded` INT UNSIGNED COMMENT "Is link reporting overload",`overload_count` INT UNSIGNED COMMENT "Number of overload onsets since connect",`slowdown` INT UNSIGNED COMMENT "Is link requesting slowdown",`slowdown_count` INT UNSIGNED COMMENT "Number of slowdown onsets since connect") COMMENT="transporter status" ENGINE=NDBINFO','SET @dummy = 0');
2829PREPARE stmt FROM @str;
2830EXECUTE stmt;
2831DROP PREPARE stmt;
2832
2833# ndbinfo.ndb$logspaces
2834SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$logspaces`','SET @dummy = 0');
2835PREPARE stmt FROM @str;
2836EXECUTE stmt;
2837DROP PREPARE stmt;
2838
2839SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$logspaces` (`node_id` INT UNSIGNED,`log_type` INT UNSIGNED COMMENT "0 = REDO, 1 = DD-UNDO",`log_id` INT UNSIGNED,`log_part` INT UNSIGNED,`total` BIGINT UNSIGNED COMMENT "total allocated",`used` BIGINT UNSIGNED COMMENT "currently in use",`high` BIGINT UNSIGNED COMMENT "in use high water mark") COMMENT="logspace usage" ENGINE=NDBINFO','SET @dummy = 0');
2840PREPARE stmt FROM @str;
2841EXECUTE stmt;
2842DROP PREPARE stmt;
2843
2844# ndbinfo.ndb$logbuffers
2845SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$logbuffers`','SET @dummy = 0');
2846PREPARE stmt FROM @str;
2847EXECUTE stmt;
2848DROP PREPARE stmt;
2849
2850SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$logbuffers` (`node_id` INT UNSIGNED,`log_type` INT UNSIGNED COMMENT "0 = REDO, 1 = DD-UNDO",`log_id` INT UNSIGNED,`log_part` INT UNSIGNED,`total` BIGINT UNSIGNED COMMENT "total allocated",`used` BIGINT UNSIGNED COMMENT "currently in use",`high` BIGINT UNSIGNED COMMENT "in use high water mark") COMMENT="logbuffer usage" ENGINE=NDBINFO','SET @dummy = 0');
2851PREPARE stmt FROM @str;
2852EXECUTE stmt;
2853DROP PREPARE stmt;
2854
2855# ndbinfo.ndb$resources
2856SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$resources`','SET @dummy = 0');
2857PREPARE stmt FROM @str;
2858EXECUTE stmt;
2859DROP PREPARE stmt;
2860
2861SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$resources` (`node_id` INT UNSIGNED,`resource_id` INT UNSIGNED,`reserved` INT UNSIGNED COMMENT "reserved for this resource",`used` INT UNSIGNED COMMENT "currently in use",`max` INT UNSIGNED COMMENT "max available",`high` INT UNSIGNED COMMENT "in use high water mark") COMMENT="resources usage (a.k.a superpool)" ENGINE=NDBINFO','SET @dummy = 0');
2862PREPARE stmt FROM @str;
2863EXECUTE stmt;
2864DROP PREPARE stmt;
2865
2866# ndbinfo.ndb$counters
2867SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$counters`','SET @dummy = 0');
2868PREPARE stmt FROM @str;
2869EXECUTE stmt;
2870DROP PREPARE stmt;
2871
2872SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$counters` (`node_id` INT UNSIGNED,`block_number` INT UNSIGNED,`block_instance` INT UNSIGNED,`counter_id` INT UNSIGNED,`val` BIGINT UNSIGNED COMMENT "monotonically increasing since process start") COMMENT="monotonic counters" ENGINE=NDBINFO','SET @dummy = 0');
2873PREPARE stmt FROM @str;
2874EXECUTE stmt;
2875DROP PREPARE stmt;
2876
2877# ndbinfo.ndb$nodes
2878SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$nodes`','SET @dummy = 0');
2879PREPARE stmt FROM @str;
2880EXECUTE stmt;
2881DROP PREPARE stmt;
2882
2883SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$nodes` (`node_id` INT UNSIGNED,`uptime` BIGINT UNSIGNED COMMENT "time in seconds that node has been running",`status` INT UNSIGNED COMMENT "starting/started/stopped etc.",`start_phase` INT UNSIGNED COMMENT "start phase if node is starting",`config_generation` INT UNSIGNED COMMENT "configuration generation number") COMMENT="node status" ENGINE=NDBINFO','SET @dummy = 0');
2884PREPARE stmt FROM @str;
2885EXECUTE stmt;
2886DROP PREPARE stmt;
2887
2888# ndbinfo.ndb$diskpagebuffer
2889SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$diskpagebuffer`','SET @dummy = 0');
2890PREPARE stmt FROM @str;
2891EXECUTE stmt;
2892DROP PREPARE stmt;
2893
2894SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$diskpagebuffer` (`node_id` INT UNSIGNED,`block_instance` INT UNSIGNED,`pages_written` BIGINT UNSIGNED COMMENT "Pages written to disk",`pages_written_lcp` BIGINT UNSIGNED COMMENT "Pages written by local checkpoint",`pages_read` BIGINT UNSIGNED COMMENT "Pages read from disk",`log_waits` BIGINT UNSIGNED COMMENT "Page writes waiting for log to be written to disk",`page_requests_direct_return` BIGINT UNSIGNED COMMENT "Page in buffer and no requests waiting for it",`page_requests_wait_queue` BIGINT UNSIGNED COMMENT "Page in buffer, but some requests are already waiting for it",`page_requests_wait_io` BIGINT UNSIGNED COMMENT "Page not in buffer, waiting to be read from disk") COMMENT="disk page buffer info" ENGINE=NDBINFO','SET @dummy = 0');
2895PREPARE stmt FROM @str;
2896EXECUTE stmt;
2897DROP PREPARE stmt;
2898
2899# ndbinfo.ndb$threadblocks
2900SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$threadblocks`','SET @dummy = 0');
2901PREPARE stmt FROM @str;
2902EXECUTE stmt;
2903DROP PREPARE stmt;
2904
2905SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$threadblocks` (`node_id` INT UNSIGNED COMMENT "node id",`thr_no` INT UNSIGNED COMMENT "thread number",`block_number` INT UNSIGNED COMMENT "block number",`block_instance` INT UNSIGNED COMMENT "block instance") COMMENT="which blocks are run in which threads" ENGINE=NDBINFO','SET @dummy = 0');
2906PREPARE stmt FROM @str;
2907EXECUTE stmt;
2908DROP PREPARE stmt;
2909
2910# ndbinfo.ndb$threadstat
2911SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$threadstat`','SET @dummy = 0');
2912PREPARE stmt FROM @str;
2913EXECUTE stmt;
2914DROP PREPARE stmt;
2915
2916SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$threadstat` (`node_id` INT UNSIGNED COMMENT "node id",`thr_no` INT UNSIGNED COMMENT "thread number",`thr_nm` VARCHAR(512) COMMENT "thread name",`c_loop` BIGINT UNSIGNED COMMENT "No of loops in main loop",`c_exec` BIGINT UNSIGNED COMMENT "No of signals executed",`c_wait` BIGINT UNSIGNED COMMENT "No of times waited for more input",`c_l_sent_prioa` BIGINT UNSIGNED COMMENT "No of prio A signals sent to own node",`c_l_sent_priob` BIGINT UNSIGNED COMMENT "No of prio B signals sent to own node",`c_r_sent_prioa` BIGINT UNSIGNED COMMENT "No of prio A signals sent to remote node",`c_r_sent_priob` BIGINT UNSIGNED COMMENT "No of prio B signals sent to remote node",`os_tid` BIGINT UNSIGNED COMMENT "OS thread id",`os_now` BIGINT UNSIGNED COMMENT "OS gettimeofday (millis)",`os_ru_utime` BIGINT UNSIGNED COMMENT "OS user CPU time (micros)",`os_ru_stime` BIGINT UNSIGNED COMMENT "OS system CPU time (micros)",`os_ru_minflt` BIGINT UNSIGNED COMMENT "OS page reclaims (soft page faults",`os_ru_majflt` BIGINT UNSIGNED COMMENT "OS page faults (hard page faults)",`os_ru_nvcsw` BIGINT UNSIGNED COMMENT "OS voluntary context switches",`os_ru_nivcsw` BIGINT UNSIGNED COMMENT "OS involuntary context switches") COMMENT="Statistics on execution threads" ENGINE=NDBINFO','SET @dummy = 0');
2917PREPARE stmt FROM @str;
2918EXECUTE stmt;
2919DROP PREPARE stmt;
2920
2921# ndbinfo.ndb$disk_write_speed_base
2922SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$disk_write_speed_base`','SET @dummy = 0');
2923PREPARE stmt FROM @str;
2924EXECUTE stmt;
2925DROP PREPARE stmt;
2926
2927SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$disk_write_speed_base` (`node_id` INT UNSIGNED COMMENT "node id",`thr_no` INT UNSIGNED COMMENT "LDM thread instance",`millis_ago` BIGINT UNSIGNED COMMENT "Milliseconds ago since this period finished",`millis_passed` BIGINT UNSIGNED COMMENT "Milliseconds passed in the period reported", `backup_lcp_bytes_written` BIGINT UNSIGNED COMMENT "Bytes written by backup and LCP in the period",`redo_bytes_written` BIGINT UNSIGNED COMMENT "Bytes written to REDO log in the period",`target_disk_write_speed` BIGINT UNSIGNED COMMENT "Target disk write speed in bytes per second at the measurement point") COMMENT="Actual speed of disk writes per LDM thread, base data" ENGINE=NDBINFO','SET @dummy = 0');
2928PREPARE stmt FROM @str;
2929EXECUTE stmt;
2930DROP PREPARE stmt;
2931
2932# ndbinfo.ndb$disk_write_speed_aggregate
2933SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$disk_write_speed_aggregate`','SET @dummy = 0');
2934PREPARE stmt FROM @str;
2935EXECUTE stmt;
2936DROP PREPARE stmt;
2937
2938SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$disk_write_speed_aggregate` (`node_id` INT UNSIGNED COMMENT "node id",`thr_no` INT UNSIGNED COMMENT "LDM thread instance",`backup_lcp_speed_last_sec` BIGINT UNSIGNED COMMENT "Number of bytes written by backup and LCP last second",`redo_speed_last_sec` BIGINT UNSIGNED COMMENT "Number of bytes written to REDO log last second",`backup_lcp_speed_last_10sec` BIGINT UNSIGNED COMMENT "Number of bytes written by backup and LCP per second last 10 seconds",`redo_speed_last_10sec` BIGINT UNSIGNED COMMENT "Number of bytes written to REDO log per second last 10 seconds",`std_dev_backup_lcp_speed_last_10sec` BIGINT UNSIGNED COMMENT "Standard deviation of Number of bytes written by backup and LCP per second last 10 seconds",`std_dev_redo_speed_last_10sec` BIGINT UNSIGNED COMMENT "Standard deviation of Number of bytes written to REDO log per second last 10 seconds",`backup_lcp_speed_last_60sec` BIGINT UNSIGNED COMMENT "Number of bytes written by backup and LCP per second last 60 seconds",`redo_speed_last_60sec` BIGINT UNSIGNED COMMENT "Number of bytes written to REDO log per second last 60 seconds",`std_dev_backup_lcp_speed_last_60sec` BIGINT UNSIGNED COMMENT "Standard deviation of Number of bytes written by backup and LCP per second last 60 seconds",`std_dev_redo_speed_last_60sec` BIGINT UNSIGNED COMMENT "Standard deviation of Number of bytes written to REDO log per second last 60 seconds",`slowdowns_due_to_io_lag` BIGINT UNSIGNED COMMENT "Number of seconds that we slowed down disk writes due to REDO log IO lagging",`slowdowns_due_to_high_cpu` BIGINT UNSIGNED COMMENT "Number of seconds we slowed down disk writes due to high CPU usage of LDM thread",`disk_write_speed_set_to_min` BIGINT UNSIGNED COMMENT "Number of seconds we set disk write speed to a minimum",`current_target_disk_write_speed` BIGINT UNSIGNED COMMENT "Current target of disk write speed in bytes per second") COMMENT="Actual speed of disk writes per LDM thread, aggregate data" ENGINE=NDBINFO','SET @dummy = 0');
2939PREPARE stmt FROM @str;
2940EXECUTE stmt;
2941DROP PREPARE stmt;
2942
2943# ndbinfo.ndb$restart_info
2944SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$restart_info`','SET @dummy = 0');
2945PREPARE stmt FROM @str;
2946EXECUTE stmt;
2947DROP PREPARE stmt;
2948
2949SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$restart_info` (`node_id` INT UNSIGNED COMMENT "node id",`node_restart_status` VARCHAR(256) COMMENT "Current state of node recovery",`node_restart_status_int` INT UNSIGNED COMMENT "Current state of node recovery as number",`secs_to_complete_node_failure` INT UNSIGNED COMMENT "Seconds to complete node failure handling",`secs_to_allocate_node_id` INT UNSIGNED COMMENT "Seconds from node failure completion to allocation of node id", `secs_to_include_in_heartbeat_protocol` INT UNSIGNED COMMENT "Seonds from allocation of node id to inclusion in HB protocol",`secs_until_wait_for_ndbcntr_master` INT UNSIGNED COMMENT "Seconds from included in HB protocol until we wait for ndbcntr master",`secs_wait_for_ndbcntr_master` INT UNSIGNED COMMENT "Seconds we waited for being accepted by NDBCNTR master to start",`secs_to_get_start_permitted` INT UNSIGNED COMMENT "Seconds from permit by master until all nodes accepted our start",`secs_to_wait_for_lcp_for_copy_meta_data` INT UNSIGNED COMMENT "Seconds waiting for LCP completion before copying meta data",`secs_to_copy_meta_data` INT UNSIGNED COMMENT "Seconds to copy meta data to starting node from master",`secs_to_include_node` INT UNSIGNED COMMENT "Seconds to wait for GCP and inclusion of all nodes into protocols",`secs_starting_node_to_request_local_recovery` INT UNSIGNED COMMENT "Seconds for starting node to request local recovery",`secs_for_local_recovery` INT UNSIGNED COMMENT "Seconds for local recovery in starting node",`secs_restore_fragments` INT UNSIGNED COMMENT "Seconds to restore fragments from LCP files",`secs_undo_disk_data` INT UNSIGNED COMMENT "Seconds to execute UNDO log on disk data part of records",`secs_exec_redo_log` INT UNSIGNED COMMENT "Seconds to execute REDO log on all restored fragments",`secs_index_rebuild` INT UNSIGNED COMMENT "Seconds to rebuild indexes on restored fragments",`secs_to_synchronize_starting_node` INT UNSIGNED COMMENT "Seconds to synchronize starting node from live nodes",`secs_wait_lcp_for_restart` INT UNSIGNED COMMENT "Seconds to wait for LCP start and completion before restart is completed",`secs_wait_subscription_handover` INT UNSIGNED COMMENT "Seconds waiting for handover of replication subscriptions",`total_restart_secs` INT UNSIGNED COMMENT "Total number of seconds from node failure until node is started again") COMMENT="Times of restart phases in seconds and current state" ENGINE=NDBINFO','SET @dummy = 0');
2950PREPARE stmt FROM @str;
2951EXECUTE stmt;
2952DROP PREPARE stmt;
2953
2954# ndbinfo.ndb$transactions
2955SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$transactions`','SET @dummy = 0');
2956PREPARE stmt FROM @str;
2957EXECUTE stmt;
2958DROP PREPARE stmt;
2959
2960SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$transactions` (`node_id` INT UNSIGNED COMMENT "node id",`block_instance` INT UNSIGNED COMMENT "TC instance no",`objid` INT UNSIGNED COMMENT "Object id of transaction object",`apiref` INT UNSIGNED COMMENT "API reference",`transid0` INT UNSIGNED COMMENT "Transaction id",`transid1` INT UNSIGNED COMMENT "Transaction id",`state` INT UNSIGNED COMMENT "Transaction state",`flags` INT UNSIGNED COMMENT "Transaction flags",`c_ops` INT UNSIGNED COMMENT "No of operations in transaction",`outstanding` INT UNSIGNED COMMENT "Currently outstanding request",`timer` INT UNSIGNED COMMENT "Timer (seconds)") COMMENT="transactions" ENGINE=NDBINFO','SET @dummy = 0');
2961PREPARE stmt FROM @str;
2962EXECUTE stmt;
2963DROP PREPARE stmt;
2964
2965# ndbinfo.ndb$operations
2966SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$operations`','SET @dummy = 0');
2967PREPARE stmt FROM @str;
2968EXECUTE stmt;
2969DROP PREPARE stmt;
2970
2971SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$operations` (`node_id` INT UNSIGNED COMMENT "node id",`block_instance` INT UNSIGNED COMMENT "LQH instance no",`objid` INT UNSIGNED COMMENT "Object id of operation object",`tcref` INT UNSIGNED COMMENT "TC reference",`apiref` INT UNSIGNED COMMENT "API reference",`transid0` INT UNSIGNED COMMENT "Transaction id",`transid1` INT UNSIGNED COMMENT "Transaction id",`tableid` INT UNSIGNED COMMENT "Table id",`fragmentid` INT UNSIGNED COMMENT "Fragment id",`op` INT UNSIGNED COMMENT "Operation type",`state` INT UNSIGNED COMMENT "Operation state",`flags` INT UNSIGNED COMMENT "Operation flags") COMMENT="operations" ENGINE=NDBINFO','SET @dummy = 0');
2972PREPARE stmt FROM @str;
2973EXECUTE stmt;
2974DROP PREPARE stmt;
2975
2976# ndbinfo.ndb$membership
2977SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$membership`','SET @dummy = 0');
2978PREPARE stmt FROM @str;
2979EXECUTE stmt;
2980DROP PREPARE stmt;
2981
2982SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$membership` (`node_id` INT UNSIGNED COMMENT "node id",`group_id` INT UNSIGNED COMMENT "node group id",`left_node` INT UNSIGNED COMMENT "Left node in heart beat chain",`right_node` INT UNSIGNED COMMENT "Right node in heart beat chain",`president` INT UNSIGNED COMMENT "President nodeid",`successor` INT UNSIGNED COMMENT "President successor",`dynamic_id` INT UNSIGNED COMMENT "President, Configured_heartbeat order",`arbitrator` INT UNSIGNED COMMENT "Arbitrator nodeid",`arb_ticket` VARCHAR(512) COMMENT "Arbitrator ticket",`arb_state` INT UNSIGNED COMMENT "Arbitrator state",`arb_connected` INT UNSIGNED COMMENT "Arbitrator connected",`conn_rank1_arbs` VARCHAR(512) COMMENT "Connected rank 1 arbitrators",`conn_rank2_arbs` VARCHAR(512) COMMENT "Connected rank 2 arbitrators") COMMENT="membership" ENGINE=NDBINFO','SET @dummy = 0');
2983PREPARE stmt FROM @str;
2984EXECUTE stmt;
2985DROP PREPARE stmt;
2986
2987# ndbinfo.ndb$frag_mem_use
2988SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$frag_mem_use`','SET @dummy = 0');
2989PREPARE stmt FROM @str;
2990EXECUTE stmt;
2991DROP PREPARE stmt;
2992
2993SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$frag_mem_use` (`node_id` INT UNSIGNED COMMENT "node id",`block_instance` INT UNSIGNED COMMENT "LDM instance number",`table_id` INT UNSIGNED COMMENT "Table identity",`fragment_num` INT UNSIGNED COMMENT "Fragment number",`rows` BIGINT UNSIGNED COMMENT "Number of rows in table",`fixed_elem_alloc_bytes` BIGINT UNSIGNED COMMENT "Number of bytes allocated for fixed-sized elements",`fixed_elem_free_bytes` BIGINT UNSIGNED COMMENT "Free bytes in fixed-size element pages",`fixed_elem_count` BIGINT UNSIGNED COMMENT "Number of fixed size elements in use",`fixed_elem_size_bytes` INT UNSIGNED COMMENT "Length of each fixed sized element in bytes",`var_elem_alloc_bytes` BIGINT UNSIGNED COMMENT "Number of bytes allocated for var-size elements",`var_elem_free_bytes` BIGINT UNSIGNED COMMENT "Free bytes in var-size element pages",`var_elem_count` BIGINT UNSIGNED COMMENT "Number of var size elements in use",`tuple_l2pmap_alloc_bytes` BIGINT UNSIGNED COMMENT "Bytes in logical to physical page map for tuple store",`hash_index_l2pmap_alloc_bytes` BIGINT UNSIGNED COMMENT "Bytes in logical to physical page map for the hash index",`hash_index_alloc_bytes` BIGINT UNSIGNED COMMENT "Bytes in linear hash map") COMMENT="Per fragment space information" ENGINE=NDBINFO','SET @dummy = 0');
2994PREPARE stmt FROM @str;
2995EXECUTE stmt;
2996DROP PREPARE stmt;
2997
2998# ndbinfo.ndb$frag_operations
2999# This table contains per-fragment usage statistics. Most values in this table
3000# reflects only user operations, meaning that they do not include the
3001# activities of LCPs and COPY_FRAG scans.. The exceptions are the counters
3002# that concern scan queueing and concurrency: tot_qd_frag_scans,
3003# conc_frag_scans, conc_qd_plain_frag_scans and conc_qd_tup_frag_scans (though
3004# LCPs currently does not use TUP scans).
3005# The values starting with 'tot_' are accumulated values, meaning that they
3006# give the totalt count of some event or sum of some attribute attibute since
3007# the node was last restarted.
3008# Also observe that this table does *not* reflect 'early aborts' in any way.
3009# By 'early aborts' we mean operations that are rejected by LQH before
3010# beginning execution due to resource issues such as overloaded transporters
3011# or lack of free space in internal structures.
3012SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$frag_operations`','SET @dummy = 0');
3013PREPARE stmt FROM @str;
3014EXECUTE stmt;
3015DROP PREPARE stmt;
3016
3017SET @cmd='CREATE TABLE ndbinfo.ndb$frag_operations (
3018  node_id INT UNSIGNED COMMENT "node id",
3019  block_instance INT UNSIGNED COMMENT "LQH instance no",
3020  table_id INT UNSIGNED COMMENT "Table identity",
3021  fragment_num INT UNSIGNED COMMENT "Fragment number",
3022  tot_key_reads BIGINT UNSIGNED COMMENT "Total number of key reads received",
3023  tot_key_inserts BIGINT UNSIGNED COMMENT
3024    "Total number of key inserts received",
3025  tot_key_updates BIGINT UNSIGNED COMMENT
3026    "Total number of key updates received",
3027# 'write' operations, meaning update if key exists, insert otherwise are used
3028# by e.g. restore and sql REPLACE.
3029  tot_key_writes BIGINT UNSIGNED COMMENT
3030    "Total number of key writes received",
3031  tot_key_deletes BIGINT UNSIGNED COMMENT
3032    "Total number of key deletes received",
3033# Number of key operations refused by the LDM due to either:
3034# - no matching key for update/delete.
3035# - key exists already for insert.
3036# - operation rejected by interpreted program.
3037# - internal errors such as checksum errors.
3038  tot_key_refs BIGINT UNSIGNED COMMENT
3039    "Total number of key operations refused by LDM",
3040  tot_key_attrinfo_bytes BIGINT UNSIGNED COMMENT
3041    "Total attrinfo bytes received for key operations",
3042  tot_key_keyinfo_bytes BIGINT UNSIGNED COMMENT
3043    "Total keyinfo bytes received for key operations",
3044  tot_key_prog_bytes BIGINT UNSIGNED COMMENT
3045    "Total bytes of filter programs for key operations",
3046  tot_key_inst_exec BIGINT UNSIGNED COMMENT
3047    "Total number of interpreter instructions executed for key operations",
3048  tot_key_bytes_returned BIGINT UNSIGNED COMMENT
3049    "Total number of bytes returned to client for key operations",
3050  tot_frag_scans BIGINT UNSIGNED COMMENT
3051    "Total number of fragment scans received",
3052  tot_scan_rows_examined BIGINT UNSIGNED COMMENT
3053    "Total number of rows examined by scans",
3054  tot_scan_rows_returned BIGINT UNSIGNED COMMENT
3055    "Total number or rows returned to client",
3056  tot_scan_bytes_returned BIGINT UNSIGNED COMMENT
3057    "Total number of bytes returned to client by scans",
3058  tot_scan_prog_bytes BIGINT UNSIGNED COMMENT
3059    "Total bytes of scan filter programs",
3060  tot_scan_bound_bytes BIGINT UNSIGNED COMMENT "Total bytes of scan bounds",
3061  tot_scan_inst_exec BIGINT UNSIGNED COMMENT
3062    "Total number of interpreter instructions executed for scans",
3063  tot_qd_frag_scans BIGINT UNSIGNED COMMENT
3064    "Total number of fragment scans queued before exec",
3065  conc_frag_scans INT UNSIGNED COMMENT "Number of frag scans currently running",
3066  conc_qd_plain_frag_scans INT UNSIGNED COMMENT
3067    "Number of tux frag scans currently queued",
3068  conc_qd_tup_frag_scans INT UNSIGNED COMMENT
3069    "Number of tup frag scans currently queued",
3070  conc_qd_acc_frag_scans INT UNSIGNED COMMENT
3071    "Number of acc frag scans currently queued",
3072  tot_commits BIGINT UNSIGNED COMMENT "Total number of committed row changes")
3073COMMENT="Per fragment operational information" ENGINE=NDBINFO;';
3074
3075SET @str=IF(@have_ndbinfo <> 0, @cmd, 'SET @dummy = 0;');
3076PREPARE stmt FROM @str;
3077EXECUTE stmt;
3078DROP PREPARE stmt;
3079
3080# ndbinfo.ndb$blocks
3081SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$blocks`','SET @dummy = 0');
3082PREPARE stmt FROM @str;
3083EXECUTE stmt;
3084DROP PREPARE stmt;
3085
3086SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$blocks` (block_number INT UNSIGNED, block_name VARCHAR(512)) ENGINE=NDBINFO','SET @dummy = 0');
3087PREPARE stmt FROM @str;
3088EXECUTE stmt;
3089DROP PREPARE stmt;
3090
3091# ndbinfo.ndb$dict_obj_info
3092SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$dict_obj_info`','SET @dummy = 0');
3093PREPARE stmt FROM @str;
3094EXECUTE stmt;
3095DROP PREPARE stmt;
3096
3097SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$dict_obj_info` (`type` INT UNSIGNED COMMENT "Type of dict object",`id` INT UNSIGNED COMMENT "Object identity",`version` INT UNSIGNED COMMENT "Object version",`state` INT UNSIGNED COMMENT "Object state",`parent_obj_type` INT UNSIGNED COMMENT "Parent object type",`parent_obj_id` INT UNSIGNED COMMENT "Parent object id",`fq_name` VARCHAR(512) COMMENT "Fully qualified object name") COMMENT="Dictionary object info" ENGINE=NDBINFO','SET @dummy = 0');
3098PREPARE stmt FROM @str;
3099EXECUTE stmt;
3100DROP PREPARE stmt;
3101
3102# ndbinfo.ndb$dict_obj_types
3103SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$dict_obj_types`','SET @dummy = 0');
3104PREPARE stmt FROM @str;
3105EXECUTE stmt;
3106DROP PREPARE stmt;
3107
3108SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$dict_obj_types` (type_id INT UNSIGNED, type_name VARCHAR(512)) ENGINE=NDBINFO','SET @dummy = 0');
3109PREPARE stmt FROM @str;
3110EXECUTE stmt;
3111DROP PREPARE stmt;
3112
3113# ndbinfo.ndb$config_params
3114SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$config_params`','SET @dummy = 0');
3115PREPARE stmt FROM @str;
3116EXECUTE stmt;
3117DROP PREPARE stmt;
3118
3119SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$config_params` (param_number INT UNSIGNED, param_name VARCHAR(512)) ENGINE=NDBINFO','SET @dummy = 0');
3120PREPARE stmt FROM @str;
3121EXECUTE stmt;
3122DROP PREPARE stmt;
3123
3124# ndbinfo.ndb$dbtc_apiconnect_state
3125SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$dbtc_apiconnect_state`','SET @dummy = 0');
3126PREPARE stmt FROM @str;
3127EXECUTE stmt;
3128DROP PREPARE stmt;
3129
3130SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$dbtc_apiconnect_state` (state_int_value INT UNSIGNED, state_name VARCHAR(256), state_friendly_name VARCHAR(256), state_description VARCHAR(256)) ENGINE=NDBINFO','SET @dummy = 0');
3131PREPARE stmt FROM @str;
3132EXECUTE stmt;
3133DROP PREPARE stmt;
3134
3135# ndbinfo.ndb$dblqh_tcconnect_state
3136SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$dblqh_tcconnect_state`','SET @dummy = 0');
3137PREPARE stmt FROM @str;
3138EXECUTE stmt;
3139DROP PREPARE stmt;
3140
3141SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$dblqh_tcconnect_state` (state_int_value INT UNSIGNED, state_name VARCHAR(256), state_friendly_name VARCHAR(256), state_description VARCHAR(256)) ENGINE=NDBINFO','SET @dummy = 0');
3142PREPARE stmt FROM @str;
3143EXECUTE stmt;
3144DROP PREPARE stmt;
3145
3146# ndbinfo.transporters
3147SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`transporters` AS SELECT node_id, remote_node_id,  CASE connection_status  WHEN 0 THEN "CONNECTED"  WHEN 1 THEN "CONNECTING"  WHEN 2 THEN "DISCONNECTED"  WHEN 3 THEN "DISCONNECTING"  ELSE NULL  END AS status,  remote_address, bytes_sent, bytes_received,  connect_count,  overloaded, overload_count, slowdown, slowdown_count FROM `ndbinfo`.`ndb$transporters`','SET @dummy = 0');
3148PREPARE stmt FROM @str;
3149EXECUTE stmt;
3150DROP PREPARE stmt;
3151
3152# ndbinfo.logspaces
3153SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`logspaces` AS SELECT node_id,  CASE log_type  WHEN 0 THEN "REDO"  WHEN 1 THEN "DD-UNDO"  ELSE NULL  END AS log_type, log_id, log_part, total, used FROM `ndbinfo`.`ndb$logspaces`','SET @dummy = 0');
3154PREPARE stmt FROM @str;
3155EXECUTE stmt;
3156DROP PREPARE stmt;
3157
3158# ndbinfo.logbuffers
3159SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`logbuffers` AS SELECT node_id,  CASE log_type  WHEN 0 THEN "REDO"  WHEN 1 THEN "DD-UNDO"  ELSE "<unknown>"  END AS log_type, log_id, log_part, total, used FROM `ndbinfo`.`ndb$logbuffers`','SET @dummy = 0');
3160PREPARE stmt FROM @str;
3161EXECUTE stmt;
3162DROP PREPARE stmt;
3163
3164# ndbinfo.resources
3165SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`resources` AS SELECT node_id,  CASE resource_id  WHEN 0 THEN "RESERVED"  WHEN 1 THEN "DISK_OPERATIONS"  WHEN 2 THEN "DISK_RECORDS"  WHEN 3 THEN "DATA_MEMORY"  WHEN 4 THEN "JOBBUFFER"  WHEN 5 THEN "FILE_BUFFERS"  WHEN 6 THEN "TRANSPORTER_BUFFERS"  WHEN 7 THEN "DISK_PAGE_BUFFER"  WHEN 8 THEN "QUERY_MEMORY"  WHEN 9 THEN "SCHEMA_TRANS_MEMORY"  ELSE "<unknown>"  END AS resource_name, reserved, used, max FROM `ndbinfo`.`ndb$resources`','SET @dummy = 0');
3166PREPARE stmt FROM @str;
3167EXECUTE stmt;
3168DROP PREPARE stmt;
3169
3170# ndbinfo.counters
3171SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`counters` AS SELECT node_id, b.block_name, block_instance, counter_id, CASE counter_id  WHEN 1 THEN "ATTRINFO"  WHEN 2 THEN "TRANSACTIONS"  WHEN 3 THEN "COMMITS"  WHEN 4 THEN "READS"  WHEN 5 THEN "SIMPLE_READS"  WHEN 6 THEN "WRITES"  WHEN 7 THEN "ABORTS"  WHEN 8 THEN "TABLE_SCANS"  WHEN 9 THEN "RANGE_SCANS"  WHEN 10 THEN "OPERATIONS"  WHEN 11 THEN "READS_RECEIVED"  WHEN 12 THEN "LOCAL_READS_SENT"  WHEN 13 THEN "REMOTE_READS_SENT"  WHEN 14 THEN "READS_NOT_FOUND"  WHEN 15 THEN "TABLE_SCANS_RECEIVED"  WHEN 16 THEN "LOCAL_TABLE_SCANS_SENT"  WHEN 17 THEN "RANGE_SCANS_RECEIVED"  WHEN 18 THEN "LOCAL_RANGE_SCANS_SENT"  WHEN 19 THEN "REMOTE_RANGE_SCANS_SENT"  WHEN 20 THEN "SCAN_BATCHES_RETURNED"  WHEN 21 THEN "SCAN_ROWS_RETURNED"  WHEN 22 THEN "PRUNED_RANGE_SCANS_RECEIVED"  WHEN 23 THEN "CONST_PRUNED_RANGE_SCANS_RECEIVED"  WHEN 24 THEN "LOCAL_READS"  WHEN 25 THEN "LOCAL_WRITES"  WHEN 26 THEN "LQHKEY_OVERLOAD"  WHEN 27 THEN "LQHKEY_OVERLOAD_TC"  WHEN 28 THEN "LQHKEY_OVERLOAD_READER"  WHEN 29 THEN "LQHKEY_OVERLOAD_NODE_PEER"  WHEN 30 THEN "LQHKEY_OVERLOAD_SUBSCRIBER"  WHEN 31 THEN "LQHSCAN_SLOWDOWNS"  ELSE "<unknown>"  END AS counter_name, val FROM `ndbinfo`.`ndb$counters` c LEFT JOIN `ndbinfo`.`ndb$blocks` b ON c.block_number = b.block_number','SET @dummy = 0');
3172PREPARE stmt FROM @str;
3173EXECUTE stmt;
3174DROP PREPARE stmt;
3175
3176# ndbinfo.nodes
3177SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`nodes` AS SELECT node_id, uptime, CASE status  WHEN 0 THEN "NOTHING"  WHEN 1 THEN "CMVMI"  WHEN 2 THEN "STARTING"  WHEN 3 THEN "STARTED"  WHEN 4 THEN "SINGLEUSER"  WHEN 5 THEN "STOPPING_1"  WHEN 6 THEN "STOPPING_2"  WHEN 7 THEN "STOPPING_3"  WHEN 8 THEN "STOPPING_4"  ELSE "<unknown>"  END AS status, start_phase, config_generation FROM `ndbinfo`.`ndb$nodes`','SET @dummy = 0');
3178PREPARE stmt FROM @str;
3179EXECUTE stmt;
3180DROP PREPARE stmt;
3181
3182# ndbinfo.memoryusage
3183SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`memoryusage` AS SELECT node_id,  pool_name AS memory_type,  SUM(used*entry_size) AS used,  SUM(used) AS used_pages,  SUM(total*entry_size) AS total,  SUM(total) AS total_pages FROM `ndbinfo`.`ndb$pools` WHERE (block_number IN (248, 254) AND   (pool_name = "Index memory" OR pool_name = "Data memory")) OR pool_name = "Long message buffer" GROUP BY node_id, memory_type','SET @dummy = 0');
3184PREPARE stmt FROM @str;
3185EXECUTE stmt;
3186DROP PREPARE stmt;
3187
3188# ndbinfo.diskpagebuffer
3189SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`diskpagebuffer` AS SELECT node_id, block_instance, pages_written, pages_written_lcp, pages_read, log_waits, page_requests_direct_return, page_requests_wait_queue, page_requests_wait_io FROM `ndbinfo`.`ndb$diskpagebuffer`','SET @dummy = 0');
3190PREPARE stmt FROM @str;
3191EXECUTE stmt;
3192DROP PREPARE stmt;
3193
3194# ndbinfo.diskpagebuffer
3195SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`diskpagebuffer` AS SELECT node_id, block_instance, pages_written, pages_written_lcp, pages_read, log_waits, page_requests_direct_return, page_requests_wait_queue, page_requests_wait_io FROM `ndbinfo`.`ndb$diskpagebuffer`','SET @dummy = 0');
3196PREPARE stmt FROM @str;
3197EXECUTE stmt;
3198DROP PREPARE stmt;
3199
3200# ndbinfo.threadblocks
3201SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`threadblocks` AS SELECT t.node_id, t.thr_no, b.block_name, t.block_instance FROM `ndbinfo`.`ndb$threadblocks` t LEFT JOIN `ndbinfo`.`ndb$blocks` b ON t.block_number = b.block_number','SET @dummy = 0');
3202PREPARE stmt FROM @str;
3203EXECUTE stmt;
3204DROP PREPARE stmt;
3205
3206# ndbinfo.threadstat
3207SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`threadstat` AS SELECT * from `ndbinfo`.`ndb$threadstat`','SET @dummy = 0');
3208PREPARE stmt FROM @str;
3209EXECUTE stmt;
3210DROP PREPARE stmt;
3211
3212# ndbinfo.disk_write_speed_base
3213SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`disk_write_speed_base` AS SELECT * from `ndbinfo`.`ndb$disk_write_speed_base`','SET @dummy = 0');
3214PREPARE stmt FROM @str;
3215EXECUTE stmt;
3216DROP PREPARE stmt;
3217
3218# ndbinfo.disk_write_speed_aggregate
3219SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`disk_write_speed_aggregate` AS SELECT * from `ndbinfo`.`ndb$disk_write_speed_aggregate`','SET @dummy = 0');
3220PREPARE stmt FROM @str;
3221EXECUTE stmt;
3222DROP PREPARE stmt;
3223
3224# ndbinfo.disk_write_speed_aggregate_node
3225SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`disk_write_speed_aggregate_node` AS SELECT node_id,SUM(backup_lcp_speed_last_sec) AS backup_lcp_speed_last_sec,SUM(redo_speed_last_sec) AS redo_speed_last_sec,SUM(backup_lcp_speed_last_10sec) AS backup_lcp_speed_last_10sec,SUM(redo_speed_last_10sec) AS redo_speed_last_10sec,SUM(backup_lcp_speed_last_60sec) AS backup_lcp_speed_last_60sec,SUM(redo_speed_last_60sec) AS redo_speed_last_60sec from `ndbinfo`.`ndb$disk_write_speed_aggregate` GROUP by node_id','SET @dummy = 0');
3226PREPARE stmt FROM @str;
3227EXECUTE stmt;
3228DROP PREPARE stmt;
3229
3230# ndbinfo.restart_info
3231SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`restart_info` AS SELECT * from `ndbinfo`.`ndb$restart_info`','SET @dummy = 0');
3232PREPARE stmt FROM @str;
3233EXECUTE stmt;
3234DROP PREPARE stmt;
3235
3236# ndbinfo.cluster_transactions
3237SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`cluster_transactions` AS SELECT t.node_id, t.block_instance, t.transid0 + (t.transid1 << 32) as transid, s.state_friendly_name as state,  t.c_ops as count_operations,  t.outstanding as outstanding_operations,  t.timer as inactive_seconds,  (t.apiref & 65535) as client_node_id,  (t.apiref >> 16) as client_block_ref FROM `ndbinfo`.`ndb$transactions` t LEFT JOIN `ndbinfo`.`ndb$dbtc_apiconnect_state` s        ON s.state_int_value = t.state','SET @dummy = 0');
3238PREPARE stmt FROM @str;
3239EXECUTE stmt;
3240DROP PREPARE stmt;
3241
3242# ndbinfo.server_transactions
3243SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`server_transactions` AS SELECT map.mysql_connection_id, t.*FROM information_schema.ndb_transid_mysql_connection_map map JOIN `ndbinfo`.cluster_transactions t   ON (map.ndb_transid >> 32) = (t.transid >> 32)','SET @dummy = 0');
3244PREPARE stmt FROM @str;
3245EXECUTE stmt;
3246DROP PREPARE stmt;
3247
3248# ndbinfo.cluster_operations
3249SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`cluster_operations` AS SELECT o.node_id, o.block_instance, o.transid0 + (o.transid1 << 32) as transid, case o.op  when 1 then "READ" when 2 then "READ-SH" when 3 then "READ-EX" when 4 then "INSERT" when 5 then "UPDATE" when 6 then "DELETE" when 7 then "WRITE" when 8 then "UNLOCK" when 9 then "REFRESH" when 257 then "SCAN" when 258 then "SCAN-SH" when 259 then "SCAN-EX" ELSE "<unknown>" END as operation_type,  s.state_friendly_name as state,  o.tableid,  o.fragmentid,  (o.apiref & 65535) as client_node_id,  (o.apiref >> 16) as client_block_ref,  (o.tcref & 65535) as tc_node_id,  ((o.tcref >> 16) & 511) as tc_block_no,  ((o.tcref >> (16 + 9)) & 127) as tc_block_instance FROM `ndbinfo`.`ndb$operations` o LEFT JOIN `ndbinfo`.`ndb$dblqh_tcconnect_state` s        ON s.state_int_value = o.state','SET @dummy = 0');
3250PREPARE stmt FROM @str;
3251EXECUTE stmt;
3252DROP PREPARE stmt;
3253
3254# ndbinfo.server_operations
3255SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`server_operations` AS SELECT map.mysql_connection_id, o.* FROM `ndbinfo`.cluster_operations o JOIN information_schema.ndb_transid_mysql_connection_map map  ON (map.ndb_transid >> 32) = (o.transid >> 32)','SET @dummy = 0');
3256PREPARE stmt FROM @str;
3257EXECUTE stmt;
3258DROP PREPARE stmt;
3259
3260# ndbinfo.membership
3261SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`membership` AS SELECT node_id, group_id, left_node, right_node, president, successor, dynamic_id & 0xFFFF AS succession_order, dynamic_id >> 16 AS Conf_HB_order, arbitrator, arb_ticket, CASE arb_state  WHEN 0 THEN "ARBIT_NULL"  WHEN 1 THEN "ARBIT_INIT"  WHEN 2 THEN "ARBIT_FIND"  WHEN 3 THEN "ARBIT_PREP1"  WHEN 4 THEN "ARBIT_PREP2"  WHEN 5 THEN "ARBIT_START"  WHEN 6 THEN "ARBIT_RUN"  WHEN 7 THEN "ARBIT_CHOOSE"  WHEN 8 THEN "ARBIT_CRASH"  ELSE "UNKNOWN" END AS arb_state, CASE arb_connected  WHEN 1 THEN "Yes"  ELSE "No" END AS arb_connected, conn_rank1_arbs AS connected_rank1_arbs, conn_rank2_arbs AS connected_rank2_arbs FROM `ndbinfo`.`ndb$membership`','SET @dummy = 0');
3262PREPARE stmt FROM @str;
3263EXECUTE stmt;
3264DROP PREPARE stmt;
3265
3266# ndbinfo.arbitrator_validity_detail
3267SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`arbitrator_validity_detail` AS SELECT node_id, arbitrator, arb_ticket, CASE arb_connected  WHEN 1 THEN "Yes"  ELSE "No" END AS arb_connected, CASE arb_state  WHEN 0 THEN "ARBIT_NULL"  WHEN 1 THEN "ARBIT_INIT"  WHEN 2 THEN "ARBIT_FIND"  WHEN 3 THEN "ARBIT_PREP1"  WHEN 4 THEN "ARBIT_PREP2"  WHEN 5 THEN "ARBIT_START"  WHEN 6 THEN "ARBIT_RUN"  WHEN 7 THEN "ARBIT_CHOOSE"  WHEN 8 THEN "ARBIT_CRASH"  ELSE "UNKNOWN" END AS arb_state FROM `ndbinfo`.`ndb$membership` ORDER BY arbitrator, arb_connected DESC','SET @dummy = 0');
3268PREPARE stmt FROM @str;
3269EXECUTE stmt;
3270DROP PREPARE stmt;
3271
3272# ndbinfo.arbitrator_validity_summary
3273SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`arbitrator_validity_summary` AS SELECT arbitrator, arb_ticket, CASE arb_connected  WHEN 1 THEN "Yes"  ELSE "No" END AS arb_connected, count(*) as consensus_count FROM `ndbinfo`.`ndb$membership` GROUP BY arbitrator, arb_ticket, arb_connected','SET @dummy = 0');
3274PREPARE stmt FROM @str;
3275EXECUTE stmt;
3276DROP PREPARE stmt;
3277
3278
3279# ndbinfo.memory_per_fragment
3280# The test for name.type<=6 is there to elimiate matching non-table objects
3281# (triggers, files etc.), since the 'id' of these may collide with table ids.
3282SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`memory_per_fragment` AS SELECT name.fq_name, parent_name.fq_name AS parent_fq_name, types.type_name AS type, table_id, node_id, block_instance, fragment_num, fixed_elem_alloc_bytes, fixed_elem_free_bytes, fixed_elem_size_bytes, fixed_elem_count, FLOOR(fixed_elem_free_bytes/fixed_elem_size_bytes) AS fixed_elem_free_count, var_elem_alloc_bytes, var_elem_free_bytes, var_elem_count, hash_index_alloc_bytes FROM ndbinfo.ndb$frag_mem_use AS space JOIN ndbinfo.ndb$dict_obj_info AS name ON name.id=space.table_id AND name.type<=6 JOIN ndbinfo.ndb$dict_obj_types AS types ON name.type=types.type_id LEFT JOIN ndbinfo.ndb$dict_obj_info AS parent_name ON name.parent_obj_id=parent_name.id AND name.parent_obj_type=parent_name.type','SET @dummy = 0');
3283PREPARE stmt FROM @str;
3284EXECUTE stmt;
3285DROP PREPARE stmt;
3286
3287# Finally turn off offline mode
3288SET @str=IF(@have_ndbinfo,'SET @@global.ndbinfo_offline=FALSE','SET @dummy = 0');
3289PREPARE stmt FROM @str;
3290EXECUTE stmt;
3291DROP PREPARE stmt;
3292
3293# ndbinfo.operations_per_fragment
3294# This is the end-user view of ndb$frag_operations. It adds some
3295# dictionary information such as the table name and type, and the name of the
3296# parent table, if there is any.
3297#
3298# The test for name.type<=6 is there to elimiate matching non-table objects
3299# (triggers, files etc.), since the 'id' of these may collide with table ids.
3300SET @cmd='CREATE OR REPLACE DEFINER=`root`@`localhost`
3301  SQL SECURITY INVOKER VIEW `ndbinfo`.`operations_per_fragment` AS
3302  SELECT name.fq_name, parent_name.fq_name AS parent_fq_name,
3303    types.type_name AS type, table_id, node_id, block_instance, fragment_num,
3304    tot_key_reads, tot_key_inserts, tot_key_updates, tot_key_writes,
3305    tot_key_deletes, tot_key_refs, tot_key_attrinfo_bytes,
3306    tot_key_keyinfo_bytes, tot_key_prog_bytes, tot_key_inst_exec,
3307    tot_key_bytes_returned, tot_frag_scans, tot_scan_rows_examined,
3308    tot_scan_rows_returned, tot_scan_bytes_returned, tot_scan_prog_bytes,
3309    tot_scan_bound_bytes, tot_scan_inst_exec, tot_qd_frag_scans,
3310    conc_frag_scans,
3311    conc_qd_plain_frag_scans+conc_qd_tup_frag_scans+conc_qd_acc_frag_scans
3312    AS conc_qd_frag_scans,
3313    tot_commits
3314    FROM ndbinfo.ndb$frag_operations AS ops
3315    JOIN ndbinfo.ndb$dict_obj_info AS name
3316      ON name.id=ops.table_id AND name.type<=6
3317    JOIN ndbinfo.ndb$dict_obj_types AS types ON name.type=types.type_id
3318    LEFT JOIN ndbinfo.ndb$dict_obj_info AS parent_name
3319      ON name.parent_obj_id=parent_name.id AND
3320         name.parent_obj_type=parent_name.type';
3321SET @str=IF(@have_ndbinfo <> 0, @cmd, 'SET @dummy = 0;');
3322PREPARE stmt FROM @str;
3323EXECUTE stmt;
3324DROP PREPARE stmt;
3325
3326# ndbinfo.blocks
3327SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`blocks` AS SELECT block_number, block_name FROM `ndbinfo`.`ndb$blocks`','SET @dummy = 0');
3328PREPARE stmt FROM @str;
3329EXECUTE stmt;
3330DROP PREPARE stmt;
3331
3332# ndbinfo.dict_obj_types
3333SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`dict_obj_types` AS SELECT type_id, type_name FROM `ndbinfo`.`ndb$dict_obj_types`','SET @dummy = 0');
3334PREPARE stmt FROM @str;
3335EXECUTE stmt;
3336DROP PREPARE stmt;
3337
3338# ndbinfo.config_params
3339SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`config_params` AS SELECT param_number, param_name FROM `ndbinfo`.`ndb$config_params`','SET @dummy = 0');
3340PREPARE stmt FROM @str;
3341EXECUTE stmt;
3342DROP PREPARE stmt;
3343
3344# Finally turn off offline mode
3345SET @str=IF(@have_ndbinfo,'SET @@global.ndbinfo_offline=FALSE','SET @dummy = 0');
3346PREPARE stmt FROM @str;
3347EXECUTE stmt;
3348DROP PREPARE stmt;
3349