forked from forgejo/forgejo
Integrate public as bindata optionally (#293)
* Dropped unused codekit config * Integrated dynamic and static bindata for public * Ignore public bindata * Add a general generate make task * Integrated flexible public assets into web command * Updated vendoring, added all missiong govendor deps * Made the linter happy with the bindata and dynamic code * Moved public bindata definition to modules directory * Ignoring the new bindata path now * Updated to the new public modules import path * Updated public bindata command and drop the new prefix
This commit is contained in:
parent
4680c349dd
commit
b6a95a8cb3
691 changed files with 305318 additions and 1272 deletions
692
vendor/github.com/pingcap/tidb/perfschema/const.go
generated
vendored
Normal file
692
vendor/github.com/pingcap/tidb/perfschema/const.go
generated
vendored
Normal file
|
@ -0,0 +1,692 @@
|
|||
// Copyright 2016 PingCAP, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package perfschema
|
||||
|
||||
// Performance Schema Name.
|
||||
const (
|
||||
Name = "PERFORMANCE_SCHEMA"
|
||||
)
|
||||
|
||||
// Definition order same as MySQL's reference manual, so don't bother to
|
||||
// adjust according to alphabetical order.
|
||||
const (
|
||||
TableSetupActors = "SETUP_ACTORS"
|
||||
TableSetupObjects = "SETUP_OBJECTS"
|
||||
TableSetupInstruments = "SETUP_INSTRUMENTS"
|
||||
TableSetupConsumers = "SETUP_CONSUMERS"
|
||||
TableSetupTimers = "SETUP_TIMERS"
|
||||
TableStmtsCurrent = "EVENTS_STATEMENTS_CURRENT"
|
||||
TableStmtsHistory = "EVENTS_STATEMENTS_HISTORY"
|
||||
TableStmtsHistoryLong = "EVENTS_STATEMENTS_HISTORY_LONG"
|
||||
TablePreparedStmtsInstances = "PREPARED_STATEMENTS_INSTANCES"
|
||||
TableTransCurrent = "EVENTS_TRANSACTIONS_CURRENT"
|
||||
TableTransHistory = "EVENTS_TRANSACTIONS_HISTORY"
|
||||
TableTransHistoryLong = "EVENTS_TRANSACTIONS_HISTORY_LONG"
|
||||
TableStagesCurrent = "EVENTS_STAGES_CURRENT"
|
||||
TableStagesHistory = "EVENTS_STAGES_HISTORY"
|
||||
TableStagesHistoryLong = "EVENTS_STAGES_HISTORY_LONG"
|
||||
)
|
||||
|
||||
// PerfSchemaTables is a shortcut to involve all table names.
|
||||
var PerfSchemaTables = []string{
|
||||
TableSetupActors,
|
||||
TableSetupObjects,
|
||||
TableSetupInstruments,
|
||||
TableSetupConsumers,
|
||||
TableSetupTimers,
|
||||
TableStmtsCurrent,
|
||||
TableStmtsHistory,
|
||||
TableStmtsHistoryLong,
|
||||
TablePreparedStmtsInstances,
|
||||
TableTransCurrent,
|
||||
TableTransHistory,
|
||||
TableTransHistoryLong,
|
||||
TableStagesCurrent,
|
||||
TableStagesHistory,
|
||||
TableStagesHistoryLong,
|
||||
}
|
||||
|
||||
// ColumnSetupActors contains the column name definitions for table setup_actors, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.setup_actors (
|
||||
// HOST CHAR(60) NOT NULL DEFAULT '%',
|
||||
// USER CHAR(32) NOT NULL DEFAULT '%',
|
||||
// ROLE CHAR(16) NOT NULL DEFAULT '%',
|
||||
// ENABLED ENUM('YES','NO') NOT NULL DEFAULT 'YES',
|
||||
// HISTORY ENUM('YES','NO') NOT NULL DEFAULT 'YES');
|
||||
var ColumnSetupActors = []string{"HOST", "USER", "ROLE", "ENABLED", "HISTORY"}
|
||||
|
||||
// ColumnSetupObjects contains the column name definitions for table setup_objects, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.setup_objects (
|
||||
// OBJECT_TYPE ENUM('EVENT','FUNCTION','TABLE') NOT NULL DEFAULT 'TABLE',
|
||||
// OBJECT_SCHEMA VARCHAR(64) DEFAULT '%',
|
||||
// OBJECT_NAME VARCHAR(64) NOT NULL DEFAULT '%',
|
||||
// ENABLED ENUM('YES','NO') NOT NULL DEFAULT 'YES',
|
||||
// TIMED ENUM('YES','NO') NOT NULL DEFAULT 'YES');
|
||||
var ColumnSetupObjects = []string{"OBJECT_TYPE", "OBJECT_SCHEMA", "OBJECT_NAME", "ENABLED", "TIMED"}
|
||||
|
||||
// ColumnSetupInstruments contains the column name definitions for table setup_instruments, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.setup_instruments (
|
||||
// NAME VARCHAR(128) NOT NULL,
|
||||
// ENABLED ENUM('YES','NO') NOT NULL,
|
||||
// TIMED ENUM('YES','NO') NOT NULL);
|
||||
var ColumnSetupInstruments = []string{"NAMED", "ENABLED", "TIMED"}
|
||||
|
||||
// ColumnSetupConsumers contains the column name definitions for table setup_consumers, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.setup_consumers (
|
||||
// NAME VARCHAR(64) NOT NULL,
|
||||
// ENABLED ENUM('YES','NO') NOT NULL);
|
||||
var ColumnSetupConsumers = []string{"NAMED", "ENABLED"}
|
||||
|
||||
// ColumnSetupTimers contains the column name definitions for table setup_timers, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.setup_timers (
|
||||
// NAME VARCHAR(64) NOT NULL,
|
||||
// TIMER_NAME ENUM('NANOSECOND','MICROSECOND','MILLISECOND') NOT NULL);
|
||||
var ColumnSetupTimers = []string{"NAME", "TIMER_NAME"}
|
||||
|
||||
// ColumnStmtsCurrent contains the column name definitions for table events_statements_current, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.events_statements_current (
|
||||
// THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// END_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// EVENT_NAME VARCHAR(128) NOT NULL,
|
||||
// SOURCE VARCHAR(64),
|
||||
// TIMER_START BIGINT(20) UNSIGNED,
|
||||
// TIMER_END BIGINT(20) UNSIGNED,
|
||||
// TIMER_WAIT BIGINT(20) UNSIGNED,
|
||||
// LOCK_TIME BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SQL_TEXT LONGTEXT,
|
||||
// DIGEST VARCHAR(32),
|
||||
// DIGEST_TEXT LONGTEXT,
|
||||
// CURRENT_SCHEMA VARCHAR(64),
|
||||
// OBJECT_TYPE VARCHAR(64),
|
||||
// OBJECT_SCHEMA VARCHAR(64),
|
||||
// OBJECT_NAME VARCHAR(64),
|
||||
// OBJECT_INSTANCE_BEGIN BIGINT(20) UNSIGNED,
|
||||
// MYSQL_ERRNO INT(11),
|
||||
// RETURNED_SQLSTATE VARCHAR(5),
|
||||
// MESSAGE_TEXT VARCHAR(128),
|
||||
// ERRORS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// WARNINGS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// ROWS_AFFECTED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// ROWS_SENT BIGINT(20) UNSIGNED NOT NULL,
|
||||
// ROWS_EXAMINED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// CREATED_TMP_DISK_TABLES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// CREATED_TMP_TABLES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_FULL_JOIN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_FULL_RANGE_JOIN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_RANGE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_RANGE_CHECK BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_SCAN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_MERGE_PASSES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_RANGE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_ROWS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_SCAN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// NO_INDEX_USED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// NO_GOOD_INDEX_USED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// NESTING_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_TYPE ENUM('TRANSACTION','STATEMENT','STAGE'),
|
||||
// NESTING_EVENT_LEVEL INT(11));
|
||||
var ColumnStmtsCurrent = []string{
|
||||
"THREAD_ID",
|
||||
"EVENT_ID",
|
||||
"END_EVENT_ID",
|
||||
"EVENT_NAME",
|
||||
"SOURCE",
|
||||
"TIMER_START",
|
||||
"TIMER_END",
|
||||
"TIMER_WAIT",
|
||||
"LOCK_TIME",
|
||||
"SQL_TEXT",
|
||||
"DIGEST",
|
||||
"DIGEST_TEXT",
|
||||
"CURRENT_SCHEMA",
|
||||
"OBJECT_TYPE",
|
||||
"OBJECT_SCHEMA",
|
||||
"OBJECT_NAME",
|
||||
"OBJECT_INSTANCE_BEGIN",
|
||||
"MYSQL_ERRNO",
|
||||
"RETURNED_SQLSTATE",
|
||||
"MESSAGE_TEXT",
|
||||
"ERRORS",
|
||||
"WARNINGS",
|
||||
"ROWS_AFFECTED",
|
||||
"ROWS_SENT",
|
||||
"ROWS_EXAMINED",
|
||||
"CREATED_TMP_DISK_TABLES",
|
||||
"CREATED_TMP_TABLES",
|
||||
"SELECT_FULL_JOIN",
|
||||
"SELECT_FULL_RANGE_JOIN",
|
||||
"SELECT_RANGE",
|
||||
"SELECT_RANGE_CHECK",
|
||||
"SELECT_SCAN",
|
||||
"SORT_MERGE_PASSES",
|
||||
"SORT_RANGE",
|
||||
"SORT_ROWS",
|
||||
"SORT_SCAN",
|
||||
"NO_INDEX_USED",
|
||||
"NO_GOOD_INDEX_USED",
|
||||
"NESTING_EVENT_ID",
|
||||
"NESTING_EVENT_TYPE",
|
||||
"NESTING_EVENT_LEVEL",
|
||||
}
|
||||
|
||||
// ColumnStmtsHistory contains the column name definitions for table events_statements_history, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.events_statements_history (
|
||||
// THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// END_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// EVENT_NAME VARCHAR(128) NOT NULL,
|
||||
// SOURCE VARCHAR(64),
|
||||
// TIMER_START BIGINT(20) UNSIGNED,
|
||||
// TIMER_END BIGINT(20) UNSIGNED,
|
||||
// TIMER_WAIT BIGINT(20) UNSIGNED,
|
||||
// LOCK_TIME BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SQL_TEXT LONGTEXT,
|
||||
// DIGEST VARCHAR(32),
|
||||
// DIGEST_TEXT LONGTEXT,
|
||||
// CURRENT_SCHEMA VARCHAR(64),
|
||||
// OBJECT_TYPE VARCHAR(64),
|
||||
// OBJECT_SCHEMA VARCHAR(64),
|
||||
// OBJECT_NAME VARCHAR(64),
|
||||
// OBJECT_INSTANCE_BEGIN BIGINT(20) UNSIGNED,
|
||||
// MYSQL_ERRNO INT(11),
|
||||
// RETURNED_SQLSTATE VARCHAR(5),
|
||||
// MESSAGE_TEXT VARCHAR(128),
|
||||
// ERRORS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// WARNINGS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// ROWS_AFFECTED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// ROWS_SENT BIGINT(20) UNSIGNED NOT NULL,
|
||||
// ROWS_EXAMINED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// CREATED_TMP_DISK_TABLES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// CREATED_TMP_TABLES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_FULL_JOIN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_FULL_RANGE_JOIN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_RANGE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_RANGE_CHECK BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_SCAN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_MERGE_PASSES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_RANGE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_ROWS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_SCAN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// NO_INDEX_USED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// NO_GOOD_INDEX_USED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// NESTING_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_TYPE ENUM('TRANSACTION','STATEMENT','STAGE'),
|
||||
// NESTING_EVENT_LEVEL INT(11));
|
||||
var ColumnStmtsHistory = []string{
|
||||
"THREAD_ID",
|
||||
"EVENT_ID",
|
||||
"END_EVENT_ID",
|
||||
"EVENT_NAME",
|
||||
"SOURCE",
|
||||
"TIMER_START",
|
||||
"TIMER_END",
|
||||
"TIMER_WAIT",
|
||||
"LOCK_TIME",
|
||||
"SQL_TEXT",
|
||||
"DIGEST",
|
||||
"DIGEST_TEXT",
|
||||
"CURRENT_SCHEMA",
|
||||
"OBJECT_TYPE",
|
||||
"OBJECT_SCHEMA",
|
||||
"OBJECT_NAME",
|
||||
"OBJECT_INSTANCE_BEGIN",
|
||||
"MYSQL_ERRNO",
|
||||
"RETURNED_SQLSTATE",
|
||||
"MESSAGE_TEXT",
|
||||
"ERRORS",
|
||||
"WARNINGS",
|
||||
"ROWS_AFFECTED",
|
||||
"ROWS_SENT",
|
||||
"ROWS_EXAMINED",
|
||||
"CREATED_TMP_DISK_TABLES",
|
||||
"CREATED_TMP_TABLES",
|
||||
"SELECT_FULL_JOIN",
|
||||
"SELECT_FULL_RANGE_JOIN",
|
||||
"SELECT_RANGE",
|
||||
"SELECT_RANGE_CHECK",
|
||||
"SELECT_SCAN",
|
||||
"SORT_MERGE_PASSES",
|
||||
"SORT_RANGE",
|
||||
"SORT_ROWS",
|
||||
"SORT_SCAN",
|
||||
"NO_INDEX_USED",
|
||||
"NO_GOOD_INDEX_USED",
|
||||
"NESTING_EVENT_ID",
|
||||
"NESTING_EVENT_TYPE",
|
||||
"NESTING_EVENT_LEVEL",
|
||||
}
|
||||
|
||||
// ColumnStmtsHistoryLong contains the column name definitions for table events_statements_history_long, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.events_statements_history_long (
|
||||
// THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// END_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// EVENT_NAME VARCHAR(128) NOT NULL,
|
||||
// SOURCE VARCHAR(64),
|
||||
// TIMER_START BIGINT(20) UNSIGNED,
|
||||
// TIMER_END BIGINT(20) UNSIGNED,
|
||||
// TIMER_WAIT BIGINT(20) UNSIGNED,
|
||||
// LOCK_TIME BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SQL_TEXT LONGTEXT,
|
||||
// DIGEST VARCHAR(32),
|
||||
// DIGEST_TEXT LONGTEXT,
|
||||
// CURRENT_SCHEMA VARCHAR(64),
|
||||
// OBJECT_TYPE VARCHAR(64),
|
||||
// OBJECT_SCHEMA VARCHAR(64),
|
||||
// OBJECT_NAME VARCHAR(64),
|
||||
// OBJECT_INSTANCE_BEGIN BIGINT(20) UNSIGNED,
|
||||
// MYSQL_ERRNO INT(11),
|
||||
// RETURNED_SQLSTATE VARCHAR(5),
|
||||
// MESSAGE_TEXT VARCHAR(128),
|
||||
// ERRORS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// WARNINGS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// ROWS_AFFECTED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// ROWS_SENT BIGINT(20) UNSIGNED NOT NULL,
|
||||
// ROWS_EXAMINED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// CREATED_TMP_DISK_TABLES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// CREATED_TMP_TABLES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_FULL_JOIN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_FULL_RANGE_JOIN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_RANGE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_RANGE_CHECK BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SELECT_SCAN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_MERGE_PASSES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_RANGE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_ROWS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SORT_SCAN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// NO_INDEX_USED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// NO_GOOD_INDEX_USED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// NESTING_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_TYPE ENUM('TRANSACTION','STATEMENT','STAGE'),
|
||||
// NESTING_EVENT_LEVEL INT(11));
|
||||
var ColumnStmtsHistoryLong = []string{
|
||||
"THREAD_ID",
|
||||
"EVENT_ID",
|
||||
"END_EVENT_ID",
|
||||
"EVENT_NAME",
|
||||
"SOURCE",
|
||||
"TIMER_START",
|
||||
"TIMER_END",
|
||||
"TIMER_WAIT",
|
||||
"LOCK_TIME",
|
||||
"SQL_TEXT",
|
||||
"DIGEST",
|
||||
"DIGEST_TEXT",
|
||||
"CURRENT_SCHEMA",
|
||||
"OBJECT_TYPE",
|
||||
"OBJECT_SCHEMA",
|
||||
"OBJECT_NAME",
|
||||
"OBJECT_INSTANCE_BEGIN",
|
||||
"MYSQL_ERRNO",
|
||||
"RETURNED_SQLSTATE",
|
||||
"MESSAGE_TEXT",
|
||||
"ERRORS",
|
||||
"WARNINGS",
|
||||
"ROWS_AFFECTED",
|
||||
"ROWS_SENT",
|
||||
"ROWS_EXAMINED",
|
||||
"CREATED_TMP_DISK_TABLES",
|
||||
"CREATED_TMP_TABLES",
|
||||
"SELECT_FULL_JOIN",
|
||||
"SELECT_FULL_RANGE_JOIN",
|
||||
"SELECT_RANGE",
|
||||
"SELECT_RANGE_CHECK",
|
||||
"SELECT_SCAN",
|
||||
"SORT_MERGE_PASSES",
|
||||
"SORT_RANGE",
|
||||
"SORT_ROWS",
|
||||
"SORT_SCAN",
|
||||
"NO_INDEX_USED",
|
||||
"NO_GOOD_INDEX_USED",
|
||||
"NESTING_EVENT_ID",
|
||||
"NESTING_EVENT_TYPE",
|
||||
"NESTING_EVENT_LEVEL",
|
||||
}
|
||||
|
||||
// ColumnPreparedStmtsInstances contains the column name definitions for table prepared_statements_instances, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.prepared_statements_instances (
|
||||
// OBJECT_INSTANCE_BEGIN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// STATEMENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// STATEMENT_NAME VARCHAR(64),
|
||||
// SQL_TEXT LONGTEXT NOT NULL,
|
||||
// OWNER_THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// OWNER_EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// OWNER_OBJECT_TYPE ENUM('EVENT','FUNCTION','TABLE'),
|
||||
// OWNER_OBJECT_SCHEMA VARCHAR(64),
|
||||
// OWNER_OBJECT_NAME VARCHAR(64),
|
||||
// TIMER_PREPARE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// COUNT_REPREPARE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// COUNT_EXECUTE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_TIMER_EXECUTE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// MIN_TIMER_EXECUTE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// AVG_TIMER_EXECUTE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// MAX_TIMER_EXECUTE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_LOCK_TIME BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_ERRORS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_WARNINGS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_ROWS_AFFECTED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_ROWS_SENT BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_ROWS_EXAMINED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_CREATED_TMP_DISK_TABLES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_CREATED_TMP_TABLES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_SELECT_FULL_JOIN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_SELECT_FULL_RANGE_JOIN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_SELECT_RANGE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_SELECT_RANGE_CHECK BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_SELECT_SCAN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_SORT_MERGE_PASSES BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_SORT_RANGE BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_SORT_ROWS BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_SORT_SCAN BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_NO_INDEX_USED BIGINT(20) UNSIGNED NOT NULL,
|
||||
// SUM_NO_GOOD_INDEX_USED BIGINT(20) UNSIGNED NOT NULL);
|
||||
var ColumnPreparedStmtsInstances = []string{
|
||||
"OBJECT_INSTANCE_BEGIN",
|
||||
"STATEMENT_ID",
|
||||
"STATEMENT_NAME",
|
||||
"SQL_TEXT",
|
||||
"OWNER_THREAD_ID",
|
||||
"OWNER_EVENT_ID",
|
||||
"OWNER_OBJECT_TYPE",
|
||||
"OWNER_OBJECT_SCHEMA",
|
||||
"OWNER_OBJECT_NAME",
|
||||
"TIMER_PREPARE",
|
||||
"COUNT_REPREPARE",
|
||||
"COUNT_EXECUTE",
|
||||
"SUM_TIMER_EXECUTE",
|
||||
"MIN_TIMER_EXECUTE",
|
||||
"AVG_TIMER_EXECUTE",
|
||||
"MAX_TIMER_EXECUTE",
|
||||
"SUM_LOCK_TIME",
|
||||
"SUM_ERRORS",
|
||||
"SUM_WARNINGS",
|
||||
"SUM_ROWS_AFFECTED",
|
||||
"SUM_ROWS_SENT",
|
||||
"SUM_ROWS_EXAMINED",
|
||||
"SUM_CREATED_TMP_DISK_TABLES",
|
||||
"SUM_CREATED_TMP_TABLES",
|
||||
"SUM_SELECT_FULL_JOIN",
|
||||
"SUM_SELECT_FULL_RANGE_JOIN",
|
||||
"SUM_SELECT_RANGE",
|
||||
"SUM_SELECT_RANGE_CHECK",
|
||||
"SUM_SELECT_SCAN",
|
||||
"SUM_SORT_MERGE_PASSES",
|
||||
"SUM_SORT_RANGE",
|
||||
"SUM_SORT_ROWS",
|
||||
"SUM_SORT_SCAN",
|
||||
"SUM_NO_INDEX_USED",
|
||||
"SUM_NO_GOOD_INDEX_USED",
|
||||
}
|
||||
|
||||
// ColumnTransCurrent contains the column name definitions for table events_transactions_current, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.events_transactions_current (
|
||||
// THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// END_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// EVENT_NAME VARCHAR(128) NOT NULL,
|
||||
// STATE ENUM('ACTIVE','COMMITTED',"ROLLED BACK"),
|
||||
// TRX_ID BIGINT(20) UNSIGNED,
|
||||
// GTID VARCHAR(64),
|
||||
// XID_FORMAT_ID INT(11),
|
||||
// XID_GTRID VARCHAR(130),
|
||||
// XID_BQUAL VARCHAR(130),
|
||||
// XA_STATE VARCHAR(64),
|
||||
// SOURCE VARCHAR(64),
|
||||
// TIMER_START BIGINT(20) UNSIGNED,
|
||||
// TIMER_END BIGINT(20) UNSIGNED,
|
||||
// TIMER_WAIT BIGINT(20) UNSIGNED,
|
||||
// ACCESS_MODE ENUM('READ ONLY','READ WRITE'),
|
||||
// ISOLATION_LEVEL VARCHAR(64),
|
||||
// AUTOCOMMIT ENUM('YES','NO') NOT NULL,
|
||||
// NUMBER_OF_SAVEPOINTS BIGINT(20) UNSIGNED,
|
||||
// NUMBER_OF_ROLLBACK_TO_SAVEPOINT BIGINT(20) UNSIGNED,
|
||||
// NUMBER_OF_RELEASE_SAVEPOINT BIGINT(20) UNSIGNED,
|
||||
// OBJECT_INSTANCE_BEGIN BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_TYPE ENUM('TRANSACTION','STATEMENT','STAGE'));
|
||||
var ColumnTransCurrent = []string{
|
||||
"THREAD_ID",
|
||||
"EVENT_ID",
|
||||
"END_EVENT_ID",
|
||||
"EVENT_NAME",
|
||||
"STATE",
|
||||
"TRX_ID",
|
||||
"GTID",
|
||||
"XID_FORMAT_ID",
|
||||
"XID_GTRID",
|
||||
"XID_BQUAL",
|
||||
"XA_STATE",
|
||||
"SOURCE",
|
||||
"TIMER_START",
|
||||
"TIMER_END",
|
||||
"TIMER_WAIT",
|
||||
"ACCESS_MODE",
|
||||
"ISOLATION_LEVEL",
|
||||
"AUTOCOMMIT",
|
||||
"NUMBER_OF_SAVEPOINTS",
|
||||
"NUMBER_OF_ROLLBACK_TO_SAVEPOINT",
|
||||
"NUMBER_OF_RELEASE_SAVEPOINT",
|
||||
"OBJECT_INSTANCE_BEGIN",
|
||||
"NESTING_EVENT_ID",
|
||||
"NESTING_EVENT_TYPE",
|
||||
}
|
||||
|
||||
// ColumnTransHistory contains the column name definitions for table events_transactions_history, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.events_transactions_history (
|
||||
// THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// END_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// EVENT_NAME VARCHAR(128) NOT NULL,
|
||||
// STATE ENUM('ACTIVE','COMMITTED',"ROLLED BACK"),
|
||||
// TRX_ID BIGINT(20) UNSIGNED,
|
||||
// GTID VARCHAR(64),
|
||||
// XID_FORMAT_ID INT(11),
|
||||
// XID_GTRID VARCHAR(130),
|
||||
// XID_BQUAL VARCHAR(130),
|
||||
// XA_STATE VARCHAR(64),
|
||||
// SOURCE VARCHAR(64),
|
||||
// TIMER_START BIGINT(20) UNSIGNED,
|
||||
// TIMER_END BIGINT(20) UNSIGNED,
|
||||
// TIMER_WAIT BIGINT(20) UNSIGNED,
|
||||
// ACCESS_MODE ENUM('READ ONLY','READ WRITE'),
|
||||
// ISOLATION_LEVEL VARCHAR(64),
|
||||
// AUTOCOMMIT ENUM('YES','NO') NOT NULL,
|
||||
// NUMBER_OF_SAVEPOINTS BIGINT(20) UNSIGNED,
|
||||
// NUMBER_OF_ROLLBACK_TO_SAVEPOINT BIGINT(20) UNSIGNED,
|
||||
// NUMBER_OF_RELEASE_SAVEPOINT BIGINT(20) UNSIGNED,
|
||||
// OBJECT_INSTANCE_BEGIN BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_TYPE ENUM('TRANSACTION','STATEMENT','STAGE'));
|
||||
var ColumnTransHistory = []string{
|
||||
"THREAD_ID",
|
||||
"EVENT_ID",
|
||||
"END_EVENT_ID",
|
||||
"EVENT_NAME",
|
||||
"STATE",
|
||||
"TRX_ID",
|
||||
"GTID",
|
||||
"XID_FORMAT_ID",
|
||||
"XID_GTRID",
|
||||
"XID_BQUAL",
|
||||
"XA_STATE",
|
||||
"SOURCE",
|
||||
"TIMER_START",
|
||||
"TIMER_END",
|
||||
"TIMER_WAIT",
|
||||
"ACCESS_MODE",
|
||||
"ISOLATION_LEVEL",
|
||||
"AUTOCOMMIT",
|
||||
"NUMBER_OF_SAVEPOINTS",
|
||||
"NUMBER_OF_ROLLBACK_TO_SAVEPOINT",
|
||||
"NUMBER_OF_RELEASE_SAVEPOINT",
|
||||
"OBJECT_INSTANCE_BEGIN",
|
||||
"NESTING_EVENT_ID",
|
||||
"NESTING_EVENT_TYPE",
|
||||
}
|
||||
|
||||
// ColumnTransHistoryLong contains the column name definitions for table events_transactions_history_long, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.events_transactions_history_long (
|
||||
// THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// END_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// EVENT_NAME VARCHAR(128) NOT NULL,
|
||||
// STATE ENUM('ACTIVE','COMMITTED',"ROLLED BACK"),
|
||||
// TRX_ID BIGINT(20) UNSIGNED,
|
||||
// GTID VARCHAR(64),
|
||||
// XID_FORMAT_ID INT(11),
|
||||
// XID_GTRID VARCHAR(130),
|
||||
// XID_BQUAL VARCHAR(130),
|
||||
// XA_STATE VARCHAR(64),
|
||||
// SOURCE VARCHAR(64),
|
||||
// TIMER_START BIGINT(20) UNSIGNED,
|
||||
// TIMER_END BIGINT(20) UNSIGNED,
|
||||
// TIMER_WAIT BIGINT(20) UNSIGNED,
|
||||
// ACCESS_MODE ENUM('READ ONLY','READ WRITE'),
|
||||
// ISOLATION_LEVEL VARCHAR(64),
|
||||
// AUTOCOMMIT ENUM('YES','NO') NOT NULL,
|
||||
// NUMBER_OF_SAVEPOINTS BIGINT(20) UNSIGNED,
|
||||
// NUMBER_OF_ROLLBACK_TO_SAVEPOINT BIGINT(20) UNSIGNED,
|
||||
// NUMBER_OF_RELEASE_SAVEPOINT BIGINT(20) UNSIGNED,
|
||||
// OBJECT_INSTANCE_BEGIN BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_TYPE ENUM('TRANSACTION','STATEMENT','STAGE'));
|
||||
var ColumnTransHistoryLong = []string{
|
||||
"THREAD_ID",
|
||||
"EVENT_ID",
|
||||
"END_EVENT_ID",
|
||||
"EVENT_NAME",
|
||||
"STATE",
|
||||
"TRX_ID",
|
||||
"GTID",
|
||||
"XID_FORMAT_ID",
|
||||
"XID_GTRID",
|
||||
"XID_BQUAL",
|
||||
"XA_STATE",
|
||||
"SOURCE",
|
||||
"TIMER_START",
|
||||
"TIMER_END",
|
||||
"TIMER_WAIT",
|
||||
"ACCESS_MODE",
|
||||
"ISOLATION_LEVEL",
|
||||
"AUTOCOMMIT",
|
||||
"NUMBER_OF_SAVEPOINTS",
|
||||
"NUMBER_OF_ROLLBACK_TO_SAVEPOINT",
|
||||
"NUMBER_OF_RELEASE_SAVEPOINT",
|
||||
"OBJECT_INSTANCE_BEGIN",
|
||||
"NESTING_EVENT_ID",
|
||||
"NESTING_EVENT_TYPE",
|
||||
}
|
||||
|
||||
// ColumnStagesCurrent contains the column name definitions for table events_stages_current, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.events_stages_current (
|
||||
// THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// END_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// EVENT_NAME VARCHAR(128) NOT NULL,
|
||||
// SOURCE VARCHAR(64),
|
||||
// TIMER_START BIGINT(20) UNSIGNED,
|
||||
// TIMER_END BIGINT(20) UNSIGNED,
|
||||
// TIMER_WAIT BIGINT(20) UNSIGNED,
|
||||
// WORK_COMPLETED BIGINT(20) UNSIGNED,
|
||||
// WORK_ESTIMATED BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_TYPE ENUM('TRANSACTION','STATEMENT','STAGE'));
|
||||
var ColumnStagesCurrent = []string{
|
||||
"THREAD_ID",
|
||||
"EVENT_ID",
|
||||
"END_EVENT_ID",
|
||||
"EVENT_NAME",
|
||||
"SOURCE",
|
||||
"TIMER_START",
|
||||
"TIMER_END",
|
||||
"TIMER_WAIT",
|
||||
"WORK_COMPLETED",
|
||||
"WORK_ESTIMATED",
|
||||
"NESTING_EVENT_ID",
|
||||
"NESTING_EVENT_TYPE",
|
||||
}
|
||||
|
||||
// ColumnStagesHistory contains the column name definitions for table events_stages_history, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.events_stages_history (
|
||||
// THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// END_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// EVENT_NAME VARCHAR(128) NOT NULL,
|
||||
// SOURCE VARCHAR(64),
|
||||
// TIMER_START BIGINT(20) UNSIGNED,
|
||||
// TIMER_END BIGINT(20) UNSIGNED,
|
||||
// TIMER_WAIT BIGINT(20) UNSIGNED,
|
||||
// WORK_COMPLETED BIGINT(20) UNSIGNED,
|
||||
// WORK_ESTIMATED BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_TYPE ENUM('TRANSACTION','STATEMENT','STAGE'));
|
||||
var ColumnStagesHistory = []string{
|
||||
"THREAD_ID",
|
||||
"EVENT_ID",
|
||||
"END_EVENT_ID",
|
||||
"EVENT_NAME",
|
||||
"SOURCE",
|
||||
"TIMER_START",
|
||||
"TIMER_END",
|
||||
"TIMER_WAIT",
|
||||
"WORK_COMPLETED",
|
||||
"WORK_ESTIMATED",
|
||||
"NESTING_EVENT_ID",
|
||||
"NESTING_EVENT_TYPE",
|
||||
}
|
||||
|
||||
// ColumnStagesHistoryLong contains the column name definitions for table events_stages_history_long, same as MySQL.
|
||||
//
|
||||
// CREATE TABLE if not exists performance_schema.events_stages_history_long (
|
||||
// THREAD_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// EVENT_ID BIGINT(20) UNSIGNED NOT NULL,
|
||||
// END_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// EVENT_NAME VARCHAR(128) NOT NULL,
|
||||
// SOURCE VARCHAR(64),
|
||||
// TIMER_START BIGINT(20) UNSIGNED,
|
||||
// TIMER_END BIGINT(20) UNSIGNED,
|
||||
// TIMER_WAIT BIGINT(20) UNSIGNED,
|
||||
// WORK_COMPLETED BIGINT(20) UNSIGNED,
|
||||
// WORK_ESTIMATED BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_ID BIGINT(20) UNSIGNED,
|
||||
// NESTING_EVENT_TYPE ENUM('TRANSACTION','STATEMENT','STAGE'));
|
||||
var ColumnStagesHistoryLong = []string{
|
||||
"THREAD_ID",
|
||||
"EVENT_ID",
|
||||
"END_EVENT_ID",
|
||||
"EVENT_NAME",
|
||||
"SOURCE",
|
||||
"TIMER_START",
|
||||
"TIMER_END",
|
||||
"TIMER_WAIT",
|
||||
"WORK_COMPLETED",
|
||||
"WORK_ESTIMATED",
|
||||
"NESTING_EVENT_ID",
|
||||
"NESTING_EVENT_TYPE",
|
||||
}
|
461
vendor/github.com/pingcap/tidb/perfschema/init.go
generated
vendored
Normal file
461
vendor/github.com/pingcap/tidb/perfschema/init.go
generated
vendored
Normal file
|
@ -0,0 +1,461 @@
|
|||
// Copyright 2016 PingCAP, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package perfschema
|
||||
|
||||
import (
|
||||
"github.com/juju/errors"
|
||||
"github.com/pingcap/tidb/kv"
|
||||
"github.com/pingcap/tidb/meta"
|
||||
"github.com/pingcap/tidb/meta/autoid"
|
||||
"github.com/pingcap/tidb/model"
|
||||
"github.com/pingcap/tidb/mysql"
|
||||
"github.com/pingcap/tidb/table"
|
||||
"github.com/pingcap/tidb/table/tables"
|
||||
"github.com/pingcap/tidb/util/charset"
|
||||
"github.com/pingcap/tidb/util/types"
|
||||
)
|
||||
|
||||
type columnInfo struct {
|
||||
tp byte
|
||||
size int
|
||||
flag uint
|
||||
deflt interface{}
|
||||
elems []string
|
||||
}
|
||||
|
||||
var setupActorsCols = []columnInfo{
|
||||
{mysql.TypeString, 60, mysql.NotNullFlag, `%`, nil},
|
||||
{mysql.TypeString, 32, mysql.NotNullFlag, `%`, nil},
|
||||
{mysql.TypeString, 16, mysql.NotNullFlag, `%`, nil},
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, "YES", []string{"YES", "NO"}},
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, "YES", []string{"YES", "NO"}},
|
||||
}
|
||||
|
||||
var setupObjectsCols = []columnInfo{
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, "TABLE", []string{"EVENT", "FUNCTION", "TABLE"}},
|
||||
{mysql.TypeVarchar, 64, 0, `%`, nil},
|
||||
{mysql.TypeVarchar, 64, mysql.NotNullFlag, `%`, nil},
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, "YES", []string{"YES", "NO"}},
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, "YES", []string{"YES", "NO"}},
|
||||
}
|
||||
|
||||
var setupInstrumentsCols = []columnInfo{
|
||||
{mysql.TypeVarchar, 128, mysql.NotNullFlag, nil, nil},
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, nil, []string{"YES", "NO"}},
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, nil, []string{"YES", "NO"}},
|
||||
}
|
||||
|
||||
var setupConsumersCols = []columnInfo{
|
||||
{mysql.TypeVarchar, 64, mysql.NotNullFlag, nil, nil},
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, nil, []string{"YES", "NO"}},
|
||||
}
|
||||
|
||||
var setupTimersCols = []columnInfo{
|
||||
{mysql.TypeVarchar, 64, mysql.NotNullFlag, nil, nil},
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, nil, []string{"NANOSECOND", "MICROSECOND", "MILLISECOND"}},
|
||||
}
|
||||
|
||||
var stmtsCurrentCols = []columnInfo{
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeVarchar, 128, mysql.NotNullFlag, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLongBlob, -1, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 32, 0, nil, nil},
|
||||
{mysql.TypeLongBlob, -1, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLong, 11, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 5, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 128, 0, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeEnum, -1, 0, nil, []string{"TRANSACTION", "STATEMENT", "STAGE"}},
|
||||
{mysql.TypeLong, 11, 0, nil, nil},
|
||||
}
|
||||
|
||||
var preparedStmtsInstancesCols = []columnInfo{
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeLongBlob, -1, mysql.NotNullFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeEnum, -1, 0, nil, []string{"EVENT", "FUNCTION", "TABLE"}},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
}
|
||||
|
||||
var transCurrentCols = []columnInfo{
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeVarchar, 128, mysql.NotNullFlag, nil, nil},
|
||||
{mysql.TypeEnum, -1, 0, nil, []string{"ACTIVE", "COMMITTED", "ROLLED BACK"}},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeLong, 11, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 130, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 130, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeEnum, -1, 0, nil, []string{"READ ONLY", "READ WRITE"}},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeEnum, -1, mysql.NotNullFlag, nil, []string{"YES", "NO"}},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeEnum, -1, 0, nil, []string{"TRANSACTION", "STATEMENT", "STAGE"}},
|
||||
}
|
||||
|
||||
var stagesCurrentCols = []columnInfo{
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.NotNullFlag | mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeVarchar, 128, mysql.NotNullFlag, nil, nil},
|
||||
{mysql.TypeVarchar, 64, 0, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeLonglong, 20, mysql.UnsignedFlag, nil, nil},
|
||||
{mysql.TypeEnum, -1, 0, nil, []string{"TRANSACTION", "STATEMENT", "STAGE"}},
|
||||
}
|
||||
|
||||
func setColumnID(meta *model.TableInfo, store kv.Storage) error {
|
||||
var err error
|
||||
for _, c := range meta.Columns {
|
||||
c.ID, err = genGlobalID(store)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func genGlobalID(store kv.Storage) (int64, error) {
|
||||
var globalID int64
|
||||
err := kv.RunInNewTxn(store, true, func(txn kv.Transaction) error {
|
||||
var err error
|
||||
globalID, err = meta.NewMeta(txn).GenGlobalID()
|
||||
return errors.Trace(err)
|
||||
})
|
||||
return globalID, errors.Trace(err)
|
||||
}
|
||||
|
||||
func createMemoryTable(meta *model.TableInfo, alloc autoid.Allocator) (table.Table, error) {
|
||||
tbl, _ := tables.MemoryTableFromMeta(alloc, meta)
|
||||
return tbl, nil
|
||||
}
|
||||
|
||||
func (ps *perfSchema) buildTables() error {
|
||||
tbls := make([]*model.TableInfo, 0, len(ps.tables))
|
||||
ps.mTables = make(map[string]table.Table, len(ps.tables))
|
||||
dbID, err := genGlobalID(ps.store)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
// Set PKIsHandle
|
||||
// TableStmtsCurrent use THREAD_ID as PK and handle
|
||||
tb := ps.tables[TableStmtsHistory]
|
||||
tb.PKIsHandle = true
|
||||
tb.Columns[0].Flag = tb.Columns[0].Flag | mysql.PriKeyFlag
|
||||
|
||||
var tbl table.Table
|
||||
for name, meta := range ps.tables {
|
||||
tbls = append(tbls, meta)
|
||||
meta.ID, err = genGlobalID(ps.store)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
err = setColumnID(meta, ps.store)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
alloc := autoid.NewMemoryAllocator(dbID)
|
||||
tbl, err = createMemoryTable(meta, alloc)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
ps.mTables[name] = tbl
|
||||
}
|
||||
ps.dbInfo = &model.DBInfo{
|
||||
ID: dbID,
|
||||
Name: model.NewCIStr(Name),
|
||||
Charset: mysql.DefaultCharset,
|
||||
Collate: mysql.DefaultCollationName,
|
||||
Tables: tbls,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps *perfSchema) buildModel(tbName string, colNames []string, cols []columnInfo) {
|
||||
rcols := make([]*model.ColumnInfo, len(cols))
|
||||
for i, col := range cols {
|
||||
var ci *model.ColumnInfo
|
||||
if col.elems == nil {
|
||||
ci = buildUsualColumnInfo(i, colNames[i], col.tp, col.size, col.flag, col.deflt)
|
||||
} else {
|
||||
ci = buildEnumColumnInfo(i, colNames[i], col.elems, col.flag, col.deflt)
|
||||
}
|
||||
rcols[i] = ci
|
||||
}
|
||||
|
||||
ps.tables[tbName] = &model.TableInfo{
|
||||
Name: model.NewCIStr(tbName),
|
||||
Charset: "utf8",
|
||||
Collate: "utf8",
|
||||
Columns: rcols,
|
||||
}
|
||||
}
|
||||
|
||||
func buildUsualColumnInfo(offset int, name string, tp byte, size int, flag uint, def interface{}) *model.ColumnInfo {
|
||||
mCharset := charset.CharsetBin
|
||||
mCollation := charset.CharsetBin
|
||||
if tp == mysql.TypeString || tp == mysql.TypeVarchar || tp == mysql.TypeBlob || tp == mysql.TypeLongBlob {
|
||||
mCharset = mysql.DefaultCharset
|
||||
mCollation = mysql.DefaultCollationName
|
||||
}
|
||||
if def == nil {
|
||||
flag |= mysql.NoDefaultValueFlag
|
||||
}
|
||||
// TODO: does TypeLongBlob need size?
|
||||
fieldType := types.FieldType{
|
||||
Charset: mCharset,
|
||||
Collate: mCollation,
|
||||
Tp: tp,
|
||||
Flen: size,
|
||||
Flag: uint(flag),
|
||||
}
|
||||
colInfo := &model.ColumnInfo{
|
||||
Name: model.NewCIStr(name),
|
||||
Offset: offset,
|
||||
FieldType: fieldType,
|
||||
DefaultValue: def,
|
||||
State: model.StatePublic,
|
||||
}
|
||||
return colInfo
|
||||
}
|
||||
|
||||
func buildEnumColumnInfo(offset int, name string, elems []string, flag uint, def interface{}) *model.ColumnInfo {
|
||||
mCharset := charset.CharsetBin
|
||||
mCollation := charset.CharsetBin
|
||||
if def == nil {
|
||||
flag |= mysql.NoDefaultValueFlag
|
||||
}
|
||||
fieldType := types.FieldType{
|
||||
Charset: mCharset,
|
||||
Collate: mCollation,
|
||||
Tp: mysql.TypeEnum,
|
||||
Flag: uint(flag),
|
||||
Elems: elems,
|
||||
}
|
||||
colInfo := &model.ColumnInfo{
|
||||
Name: model.NewCIStr(name),
|
||||
Offset: offset,
|
||||
FieldType: fieldType,
|
||||
DefaultValue: def,
|
||||
State: model.StatePublic,
|
||||
}
|
||||
return colInfo
|
||||
}
|
||||
|
||||
func (ps *perfSchema) initRecords(tbName string, records [][]types.Datum) error {
|
||||
tbl, ok := ps.mTables[tbName]
|
||||
if !ok {
|
||||
return errors.Errorf("Unknown PerformanceSchema table: %s", tbName)
|
||||
}
|
||||
for _, rec := range records {
|
||||
_, err := tbl.AddRecord(nil, rec)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var setupTimersRecords [][]types.Datum
|
||||
|
||||
func (ps *perfSchema) initialize() (err error) {
|
||||
ps.tables = make(map[string]*model.TableInfo)
|
||||
|
||||
allColDefs := [][]columnInfo{
|
||||
setupActorsCols,
|
||||
setupObjectsCols,
|
||||
setupInstrumentsCols,
|
||||
setupConsumersCols,
|
||||
setupTimersCols,
|
||||
stmtsCurrentCols,
|
||||
stmtsCurrentCols, // same as above
|
||||
stmtsCurrentCols, // same as above
|
||||
preparedStmtsInstancesCols,
|
||||
transCurrentCols,
|
||||
transCurrentCols, // same as above
|
||||
transCurrentCols, // same as above
|
||||
stagesCurrentCols,
|
||||
stagesCurrentCols, // same as above
|
||||
stagesCurrentCols, // same as above
|
||||
}
|
||||
|
||||
allColNames := [][]string{
|
||||
ColumnSetupActors,
|
||||
ColumnSetupObjects,
|
||||
ColumnSetupInstruments,
|
||||
ColumnSetupConsumers,
|
||||
ColumnSetupTimers,
|
||||
ColumnStmtsCurrent,
|
||||
ColumnStmtsHistory,
|
||||
ColumnStmtsHistoryLong,
|
||||
ColumnPreparedStmtsInstances,
|
||||
ColumnStmtsCurrent,
|
||||
ColumnStmtsHistory,
|
||||
ColumnStmtsHistoryLong,
|
||||
ColumnStagesCurrent,
|
||||
ColumnStagesHistory,
|
||||
ColumnStagesHistoryLong,
|
||||
}
|
||||
|
||||
// initialize all table, column and result field definitions
|
||||
for i, def := range allColDefs {
|
||||
ps.buildModel(PerfSchemaTables[i], allColNames[i], def)
|
||||
}
|
||||
err = ps.buildTables()
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
setupActorsRecords := [][]types.Datum{
|
||||
types.MakeDatums(`%`, `%`, `%`, mysql.Enum{Name: "YES", Value: 1}, mysql.Enum{Name: "YES", Value: 1}),
|
||||
}
|
||||
err = ps.initRecords(TableSetupActors, setupActorsRecords)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
setupObjectsRecords := [][]types.Datum{
|
||||
types.MakeDatums(mysql.Enum{Name: "EVENT", Value: 1}, "mysql", `%`, mysql.Enum{Name: "NO", Value: 2}, mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums(mysql.Enum{Name: "EVENT", Value: 1}, "performance_schema", `%`, mysql.Enum{Name: "NO", Value: 2}, mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums(mysql.Enum{Name: "EVENT", Value: 1}, "information_schema", `%`, mysql.Enum{Name: "NO", Value: 2}, mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums(mysql.Enum{Name: "EVENT", Value: 1}, `%`, `%`, mysql.Enum{Name: "YES", Value: 1}, mysql.Enum{Name: "YES", Value: 1}),
|
||||
types.MakeDatums(mysql.Enum{Name: "FUNCTION", Value: 2}, "mysql", `%`, mysql.Enum{Name: "NO", Value: 2}, mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums(mysql.Enum{Name: "FUNCTION", Value: 2}, "performance_schema", `%`, mysql.Enum{Name: "NO", Value: 2}, mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums(mysql.Enum{Name: "FUNCTION", Value: 2}, "information_schema", `%`, mysql.Enum{Name: "NO", Value: 2}, mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums(mysql.Enum{Name: "FUNCTION", Value: 2}, `%`, `%`, mysql.Enum{Name: "YES", Value: 1}, mysql.Enum{Name: "YES", Value: 1}),
|
||||
types.MakeDatums(mysql.Enum{Name: "TABLE", Value: 3}, "mysql", `%`, mysql.Enum{Name: "NO", Value: 2}, mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums(mysql.Enum{Name: "TABLE", Value: 3}, "performance_schema", `%`, mysql.Enum{Name: "NO", Value: 2}, mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums(mysql.Enum{Name: "TABLE", Value: 3}, "information_schema", `%`, mysql.Enum{Name: "NO", Value: 2}, mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums(mysql.Enum{Name: "TABLE", Value: 3}, `%`, `%`, mysql.Enum{Name: "YES", Value: 1}, mysql.Enum{Name: "YES", Value: 1}),
|
||||
}
|
||||
err = ps.initRecords(TableSetupObjects, setupObjectsRecords)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
setupConsumersRecords := [][]types.Datum{
|
||||
types.MakeDatums("events_stages_current", mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums("events_stages_history", mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums("events_stages_history_long", mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums("events_statements_current", mysql.Enum{Name: "YES", Value: 1}),
|
||||
types.MakeDatums("events_statements_history", mysql.Enum{Name: "YES", Value: 1}),
|
||||
types.MakeDatums("events_statements_history_long", mysql.Enum{Name: "NO", Value: 2}),
|
||||
types.MakeDatums("events_transactions_current", mysql.Enum{Name: "YES", Value: 1}),
|
||||
types.MakeDatums("events_transactions_history", mysql.Enum{Name: "YES", Value: 1}),
|
||||
types.MakeDatums("events_transactions_history_long", mysql.Enum{Name: "YES", Value: 1}),
|
||||
types.MakeDatums("global_instrumentation", mysql.Enum{Name: "YES", Value: 1}),
|
||||
types.MakeDatums("thread_instrumentation", mysql.Enum{Name: "YES", Value: 1}),
|
||||
types.MakeDatums("statements_digest", mysql.Enum{Name: "YES", Value: 1}),
|
||||
}
|
||||
err = ps.initRecords(TableSetupConsumers, setupConsumersRecords)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
setupTimersRecords = [][]types.Datum{
|
||||
types.MakeDatums("stage", mysql.Enum{Name: "NANOSECOND", Value: 1}),
|
||||
types.MakeDatums("statement", mysql.Enum{Name: "NANOSECOND", Value: 1}),
|
||||
types.MakeDatums("transaction", mysql.Enum{Name: "NANOSECOND", Value: 1}),
|
||||
}
|
||||
err = ps.initRecords(TableSetupTimers, setupTimersRecords)
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps *perfSchema) GetDBMeta() *model.DBInfo {
|
||||
return ps.dbInfo
|
||||
}
|
||||
|
||||
func (ps *perfSchema) GetTable(name string) (table.Table, bool) {
|
||||
tbl, ok := ps.mTables[name]
|
||||
return tbl, ok
|
||||
}
|
85
vendor/github.com/pingcap/tidb/perfschema/instrument.go
generated
vendored
Normal file
85
vendor/github.com/pingcap/tidb/perfschema/instrument.go
generated
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
// Copyright 2016 PingCAP, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package perfschema
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/juju/errors"
|
||||
"github.com/pingcap/tidb/mysql"
|
||||
"github.com/pingcap/tidb/util/types"
|
||||
)
|
||||
|
||||
// EnumCallerName is used as a parameter to avoid calling runtime.Caller(1) since
|
||||
// it is too expensive (500ns+ per call), we don't want to invoke it repeatedly for
|
||||
// each instrument.
|
||||
type EnumCallerName int
|
||||
|
||||
const (
|
||||
// CallerNameSessionExecute is for session.go:Execute() method.
|
||||
CallerNameSessionExecute EnumCallerName = iota + 1
|
||||
)
|
||||
|
||||
const (
|
||||
stageInstrumentPrefix = "stage/"
|
||||
statementInstrumentPrefix = "statement/"
|
||||
transactionInstrumentPrefix = "transaction"
|
||||
)
|
||||
|
||||
// Flag indicators for table setup_timers.
|
||||
const (
|
||||
flagStage = iota + 1
|
||||
flagStatement
|
||||
flagTransaction
|
||||
)
|
||||
|
||||
type enumTimerName int
|
||||
|
||||
// Enum values for the TIMER_NAME columns.
|
||||
// This enum is found in the following tables:
|
||||
// - performance_schema.setup_timer (TIMER_NAME)
|
||||
const (
|
||||
timerNameNone enumTimerName = iota
|
||||
timerNameNanosec
|
||||
timerNameMicrosec
|
||||
timerNameMillisec
|
||||
)
|
||||
|
||||
var (
|
||||
callerNames = make(map[EnumCallerName]string)
|
||||
)
|
||||
|
||||
// addInstrument is used to add an item to setup_instruments table.
|
||||
func (ps *perfSchema) addInstrument(name string) (uint64, error) {
|
||||
record := types.MakeDatums(name, mysql.Enum{Name: "YES", Value: 1}, mysql.Enum{Name: "YES", Value: 1})
|
||||
tbl := ps.mTables[TableSetupInstruments]
|
||||
handle, err := tbl.AddRecord(nil, record)
|
||||
return uint64(handle), errors.Trace(err)
|
||||
}
|
||||
|
||||
func (ps *perfSchema) getTimerName(flag int) (enumTimerName, error) {
|
||||
if flag < 0 || flag >= len(setupTimersRecords) {
|
||||
return timerNameNone, errors.Errorf("Unknown timerName flag %d", flag)
|
||||
}
|
||||
timerName := fmt.Sprintf("%s", setupTimersRecords[flag][1].GetString())
|
||||
switch timerName {
|
||||
case "NANOSECOND":
|
||||
return timerNameNanosec, nil
|
||||
case "MICROSECOND":
|
||||
return timerNameMicrosec, nil
|
||||
case "MILLISECOND":
|
||||
return timerNameMillisec, nil
|
||||
}
|
||||
return timerNameNone, nil
|
||||
}
|
74
vendor/github.com/pingcap/tidb/perfschema/perfschema.go
generated
vendored
Normal file
74
vendor/github.com/pingcap/tidb/perfschema/perfschema.go
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
// Copyright 2016 PingCAP, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package perfschema
|
||||
|
||||
import (
|
||||
"github.com/pingcap/tidb/kv"
|
||||
"github.com/pingcap/tidb/model"
|
||||
"github.com/pingcap/tidb/table"
|
||||
)
|
||||
|
||||
// StatementInstrument defines the methods for statement instrumentation points
|
||||
type StatementInstrument interface {
|
||||
RegisterStatement(category, name string, elem interface{})
|
||||
|
||||
StartStatement(sql string, connID uint64, callerName EnumCallerName, elem interface{}) *StatementState
|
||||
|
||||
EndStatement(state *StatementState)
|
||||
}
|
||||
|
||||
// PerfSchema defines the methods to be invoked by the executor
|
||||
type PerfSchema interface {
|
||||
|
||||
// For statement instrumentation only.
|
||||
StatementInstrument
|
||||
|
||||
// GetDBMeta returns db info for PerformanceSchema.
|
||||
GetDBMeta() *model.DBInfo
|
||||
// GetTable returns table instance for name.
|
||||
GetTable(name string) (table.Table, bool)
|
||||
}
|
||||
|
||||
type perfSchema struct {
|
||||
store kv.Storage
|
||||
dbInfo *model.DBInfo
|
||||
tables map[string]*model.TableInfo
|
||||
mTables map[string]table.Table // MemoryTables for perfSchema
|
||||
|
||||
// Used for TableStmtsHistory
|
||||
historyHandles []int64
|
||||
historyCursor int
|
||||
}
|
||||
|
||||
var _ PerfSchema = (*perfSchema)(nil)
|
||||
|
||||
// PerfHandle is the only access point for the in-memory performance schema information
|
||||
var (
|
||||
PerfHandle PerfSchema
|
||||
)
|
||||
|
||||
// NewPerfHandle creates a new perfSchema on store.
|
||||
func NewPerfHandle(store kv.Storage) PerfSchema {
|
||||
schema := PerfHandle.(*perfSchema)
|
||||
schema.store = store
|
||||
schema.historyHandles = make([]int64, 0, stmtsHistoryElemMax)
|
||||
_ = schema.initialize()
|
||||
registerStatements()
|
||||
return PerfHandle
|
||||
}
|
||||
|
||||
func init() {
|
||||
schema := &perfSchema{}
|
||||
PerfHandle = schema
|
||||
}
|
328
vendor/github.com/pingcap/tidb/perfschema/statement.go
generated
vendored
Normal file
328
vendor/github.com/pingcap/tidb/perfschema/statement.go
generated
vendored
Normal file
|
@ -0,0 +1,328 @@
|
|||
// Copyright 2016 PingCAP, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package perfschema
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/juju/errors"
|
||||
"github.com/ngaut/log"
|
||||
"github.com/pingcap/tidb/ast"
|
||||
"github.com/pingcap/tidb/kv"
|
||||
"github.com/pingcap/tidb/terror"
|
||||
"github.com/pingcap/tidb/util/types"
|
||||
)
|
||||
|
||||
// statementInfo defines statement instrument information.
|
||||
type statementInfo struct {
|
||||
// The registered statement key
|
||||
key uint64
|
||||
// The name of the statement instrument to register
|
||||
name string
|
||||
}
|
||||
|
||||
// StatementState provides temporary storage to a statement runtime statistics.
|
||||
// TODO:
|
||||
// 1. support statement digest.
|
||||
// 2. support prepared statement.
|
||||
type StatementState struct {
|
||||
// Connection identifier
|
||||
connID uint64
|
||||
// Statement information
|
||||
info *statementInfo
|
||||
// Statement type
|
||||
stmtType reflect.Type
|
||||
// Source file and line number
|
||||
source string
|
||||
// Timer name
|
||||
timerName enumTimerName
|
||||
// Timer start
|
||||
timerStart int64
|
||||
// Timer end
|
||||
timerEnd int64
|
||||
// Locked time
|
||||
lockTime int64
|
||||
// SQL statement string
|
||||
sqlText string
|
||||
// Current schema name
|
||||
schemaName string
|
||||
// Number of errors
|
||||
errNum uint32
|
||||
// Number of warnings
|
||||
warnNum uint32
|
||||
// Rows affected
|
||||
rowsAffected uint64
|
||||
// Rows sent
|
||||
rowsSent uint64
|
||||
// Rows examined
|
||||
rowsExamined uint64
|
||||
// Metric, temporary tables created on disk
|
||||
createdTmpDiskTables uint32
|
||||
// Metric, temproray tables created
|
||||
createdTmpTables uint32
|
||||
// Metric, number of select full join
|
||||
selectFullJoin uint32
|
||||
// Metric, number of select full range join
|
||||
selectFullRangeJoin uint32
|
||||
// Metric, number of select range
|
||||
selectRange uint32
|
||||
// Metric, number of select range check
|
||||
selectRangeCheck uint32
|
||||
// Metric, number of select scan
|
||||
selectScan uint32
|
||||
// Metric, number of sort merge passes
|
||||
sortMergePasses uint32
|
||||
// Metric, number of sort merge
|
||||
sortRange uint32
|
||||
// Metric, number of sort rows
|
||||
sortRows uint32
|
||||
// Metric, number of sort scans
|
||||
sortScan uint32
|
||||
// Metric, no index used flag
|
||||
noIndexUsed uint8
|
||||
// Metric, no good index used flag
|
||||
noGoodIndexUsed uint8
|
||||
}
|
||||
|
||||
const (
|
||||
// Maximum allowed number of elements in table events_statements_history.
|
||||
// TODO: make it configurable?
|
||||
stmtsHistoryElemMax int = 1024
|
||||
)
|
||||
|
||||
var (
|
||||
stmtInfos = make(map[reflect.Type]*statementInfo)
|
||||
)
|
||||
|
||||
func (ps *perfSchema) RegisterStatement(category, name string, elem interface{}) {
|
||||
instrumentName := fmt.Sprintf("%s%s/%s", statementInstrumentPrefix, category, name)
|
||||
key, err := ps.addInstrument(instrumentName)
|
||||
if err != nil {
|
||||
// just ignore, do nothing else.
|
||||
log.Errorf("Unable to register instrument %s", instrumentName)
|
||||
return
|
||||
}
|
||||
|
||||
stmtInfos[reflect.TypeOf(elem)] = &statementInfo{
|
||||
key: key,
|
||||
name: instrumentName,
|
||||
}
|
||||
}
|
||||
|
||||
func (ps *perfSchema) StartStatement(sql string, connID uint64, callerName EnumCallerName, elem interface{}) *StatementState {
|
||||
stmtType := reflect.TypeOf(elem)
|
||||
info, ok := stmtInfos[stmtType]
|
||||
if !ok {
|
||||
// just ignore, do nothing else.
|
||||
log.Errorf("No instrument registered for statement %s", stmtType)
|
||||
return nil
|
||||
}
|
||||
|
||||
// check and apply the configuration parameter in table setup_timers.
|
||||
timerName, err := ps.getTimerName(flagStatement)
|
||||
if err != nil {
|
||||
// just ignore, do nothing else.
|
||||
log.Error("Unable to check setup_timers table")
|
||||
return nil
|
||||
}
|
||||
var timerStart int64
|
||||
switch timerName {
|
||||
case timerNameNanosec:
|
||||
timerStart = time.Now().UnixNano()
|
||||
case timerNameMicrosec:
|
||||
timerStart = time.Now().UnixNano() / int64(time.Microsecond)
|
||||
case timerNameMillisec:
|
||||
timerStart = time.Now().UnixNano() / int64(time.Millisecond)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: check and apply the additional configuration parameters in:
|
||||
// - table setup_actors
|
||||
// - table setup_setup_consumers
|
||||
// - table setup_instruments
|
||||
// - table setup_objects
|
||||
|
||||
var source string
|
||||
source, ok = callerNames[callerName]
|
||||
if !ok {
|
||||
_, fileName, fileLine, ok := runtime.Caller(1)
|
||||
if !ok {
|
||||
// just ignore, do nothing else.
|
||||
log.Error("Unable to get runtime.Caller(1)")
|
||||
return nil
|
||||
}
|
||||
source = fmt.Sprintf("%s:%d", fileName, fileLine)
|
||||
callerNames[callerName] = source
|
||||
}
|
||||
|
||||
return &StatementState{
|
||||
connID: connID,
|
||||
info: info,
|
||||
stmtType: stmtType,
|
||||
source: source,
|
||||
timerName: timerName,
|
||||
timerStart: timerStart,
|
||||
sqlText: sql,
|
||||
}
|
||||
}
|
||||
|
||||
func (ps *perfSchema) EndStatement(state *StatementState) {
|
||||
if state == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch state.timerName {
|
||||
case timerNameNanosec:
|
||||
state.timerEnd = time.Now().UnixNano()
|
||||
case timerNameMicrosec:
|
||||
state.timerEnd = time.Now().UnixNano() / int64(time.Microsecond)
|
||||
case timerNameMillisec:
|
||||
state.timerEnd = time.Now().UnixNano() / int64(time.Millisecond)
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("EndStatement: sql %s, connection id %d, type %s", state.sqlText, state.connID, state.stmtType)
|
||||
|
||||
record := state2Record(state)
|
||||
err := ps.updateEventsStmtsCurrent(state.connID, record)
|
||||
if err != nil {
|
||||
log.Error("Unable to update events_statements_current table")
|
||||
}
|
||||
err = ps.appendEventsStmtsHistory(record)
|
||||
if err != nil {
|
||||
log.Errorf("Unable to append to events_statements_history table %v", errors.ErrorStack(err))
|
||||
}
|
||||
}
|
||||
|
||||
func state2Record(state *StatementState) []types.Datum {
|
||||
return types.MakeDatums(
|
||||
state.connID, // THREAD_ID
|
||||
state.info.key, // EVENT_ID
|
||||
nil, // END_EVENT_ID
|
||||
state.info.name, // EVENT_NAME
|
||||
state.source, // SOURCE
|
||||
uint64(state.timerStart), // TIMER_START
|
||||
uint64(state.timerEnd), // TIMER_END
|
||||
nil, // TIMER_WAIT
|
||||
uint64(state.lockTime), // LOCK_TIME
|
||||
state.sqlText, // SQL_TEXT
|
||||
nil, // DIGEST
|
||||
nil, // DIGEST_TEXT
|
||||
state.schemaName, // CURRENT_SCHEMA
|
||||
nil, // OBJECT_TYPE
|
||||
nil, // OBJECT_SCHEMA
|
||||
nil, // OBJECT_NAME
|
||||
nil, // OBJECT_INSTANCE_BEGIN
|
||||
nil, // MYSQL_ERRNO,
|
||||
nil, // RETURNED_SQLSTATE
|
||||
nil, // MESSAGE_TEXT
|
||||
uint64(state.errNum), // ERRORS
|
||||
uint64(state.warnNum), // WARNINGS
|
||||
state.rowsAffected, // ROWS_AFFECTED
|
||||
state.rowsSent, // ROWS_SENT
|
||||
state.rowsExamined, // ROWS_EXAMINED
|
||||
uint64(state.createdTmpDiskTables), // CREATED_TMP_DISK_TABLES
|
||||
uint64(state.createdTmpTables), // CREATED_TMP_TABLES
|
||||
uint64(state.selectFullJoin), // SELECT_FULL_JOIN
|
||||
uint64(state.selectFullRangeJoin), // SELECT_FULL_RANGE_JOIN
|
||||
uint64(state.selectRange), // SELECT_RANGE
|
||||
uint64(state.selectRangeCheck), // SELECT_RANGE_CHECK
|
||||
uint64(state.selectScan), // SELECT_SCAN
|
||||
uint64(state.sortMergePasses), // SORT_MERGE_PASSES
|
||||
uint64(state.sortRange), // SORT_RANGE
|
||||
uint64(state.sortRows), // SORT_ROWS
|
||||
uint64(state.sortScan), // SORT_SCAN
|
||||
uint64(state.noIndexUsed), // NO_INDEX_USED
|
||||
uint64(state.noGoodIndexUsed), // NO_GOOD_INDEX_USED
|
||||
nil, // NESTING_EVENT_ID
|
||||
nil, // NESTING_EVENT_TYPE
|
||||
nil, // NESTING_EVENT_LEVEL
|
||||
)
|
||||
}
|
||||
|
||||
func (ps *perfSchema) updateEventsStmtsCurrent(connID uint64, record []types.Datum) error {
|
||||
// Try AddRecord
|
||||
tbl := ps.mTables[TableStmtsCurrent]
|
||||
_, err := tbl.AddRecord(nil, record)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if terror.ErrorNotEqual(err, kv.ErrKeyExists) {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
// Update it
|
||||
handle := int64(connID)
|
||||
err = tbl.UpdateRecord(nil, handle, nil, record, nil)
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
func (ps *perfSchema) appendEventsStmtsHistory(record []types.Datum) error {
|
||||
tbl := ps.mTables[TableStmtsHistory]
|
||||
if len(ps.historyHandles) < stmtsHistoryElemMax {
|
||||
h, err := tbl.AddRecord(nil, record)
|
||||
if err == nil {
|
||||
ps.historyHandles = append(ps.historyHandles, h)
|
||||
return nil
|
||||
}
|
||||
if terror.ErrorNotEqual(err, kv.ErrKeyExists) {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
// THREAD_ID is PK
|
||||
handle := int64(record[0].GetUint64())
|
||||
err = tbl.UpdateRecord(nil, handle, nil, record, nil)
|
||||
return errors.Trace(err)
|
||||
|
||||
}
|
||||
// If histroy is full, replace old data
|
||||
if ps.historyCursor >= len(ps.historyHandles) {
|
||||
ps.historyCursor = 0
|
||||
}
|
||||
h := ps.historyHandles[ps.historyCursor]
|
||||
ps.historyCursor++
|
||||
err := tbl.UpdateRecord(nil, h, nil, record, nil)
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
func registerStatements() {
|
||||
// Existing instrument names are the same as MySQL 5.7
|
||||
PerfHandle.RegisterStatement("sql", "alter_table", (*ast.AlterTableStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "begin", (*ast.BeginStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "commit", (*ast.CommitStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "create_db", (*ast.CreateDatabaseStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "create_index", (*ast.CreateIndexStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "create_table", (*ast.CreateTableStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "deallocate", (*ast.DeallocateStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "delete", (*ast.DeleteStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "do", (*ast.DoStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "drop_db", (*ast.DropDatabaseStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "drop_table", (*ast.DropTableStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "drop_index", (*ast.DropIndexStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "execute", (*ast.ExecuteStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "explain", (*ast.ExplainStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "insert", (*ast.InsertStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "prepare", (*ast.PrepareStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "rollback", (*ast.RollbackStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "select", (*ast.SelectStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "set", (*ast.SetStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "show", (*ast.ShowStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "truncate", (*ast.TruncateTableStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "union", (*ast.UnionStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "update", (*ast.UpdateStmt)(nil))
|
||||
PerfHandle.RegisterStatement("sql", "use", (*ast.UseStmt)(nil))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue