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