// Copyright 2013 The ql Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSES/QL-LICENSE file. // Copyright 2015 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 session import ( "github.com/hanchuanchuan/goInception/mysql" ) // 数据库类型 const ( DBTypeMysql = iota DBTypeMariaDB DBTypeTiDB ) // 审核阶段 const ( StageOK byte = iota StageCheck StageExec StageBackup ) // 审核状态 const ( StatusAuditOk byte = iota StatusExecFail StatusExecOK StatusBackupFail StatusBackupOK ) var ( StageList = [4]string{"RERUN", "CHECKED", "EXECUTED", "BACKUP"} StatusList = [5]string{"Audit Completed", "Execute failed", "Execute Successfully", "Execute Successfully\nBackup failed", "Execute Successfully\nBackup Successfully"} ) // int类型map(用以数值列类型变更审核) var IntegerOrderedMaps = map[string]int{ "bit": 1, "tinyint": 2, "smallint": 3, "mediumint": 4, "int": 5, "bigint": 6, } // int类型map(用以数值列类型变更审核) var IntegerOrderedMaps2 = map[byte]int{ mysql.TypeBit: 1, mysql.TypeTiny: 2, mysql.TypeShort: 3, mysql.TypeInt24: 4, mysql.TypeLong: 5, mysql.TypeLonglong: 6, } // Keywords 数据库关键字 var Keywords = map[string]bool{ "ACCESSIBLE": true, "ACCOUNT": true, "ACTION": true, "ACTIVE": true, "ADD": true, "ADDDATE": true, "ADMIN": true, "AFTER": true, "AGAINST": true, "AGGREGATE": true, "ALGORITHM": true, "ALL": true, "ALTER": true, "ALWAYS": true, "ANALYSE": true, "ANALYZE": true, "AND": true, "ANY": true, "ARRAY": true, "AS": true, "ASC": true, "ASCII": true, "ASENSITIVE": true, "AT": true, "ATTRIBUTE": true, "AUTO_INCREMENT": true, "AUTOEXTEND_SIZE": true, "AVG": true, "AVG_ROW_LENGTH": true, "BACKUP": true, "BEFORE": true, "BEGIN": true, "BETWEEN": true, "BIGINT": true, "BINARY": true, "BINLOG": true, "BIT": true, "BIT_AND": true, "BIT_OR": true, "BIT_XOR": true, "BLOB": true, "BLOCK": true, "BOOL": true, "BOOLEAN": true, "BOTH": true, "BTREE": true, "BUCKETS": true, "BY": true, "BYTE": true, "CACHE": true, "CALL": true, "CANCEL": true, "CASCADE": true, "CASCADED": true, "CASE": true, "CAST": true, "CATALOG_NAME": true, "CHAIN": true, "CHANGE": true, "CHANGED": true, "CHANNEL": true, "CHAR": true, "CHARACTER": true, "CHARSET": true, "CHECK": true, "CHECKSUM": true, "CIPHER": true, "CLASS_ORIGIN": true, "CLEANUP": true, "CLIENT": true, "CLONE": true, "CLOSE": true, "COALESCE": true, "CODE": true, "COLLATE": true, "COLLATION": true, "COLUMN": true, "COLUMN_FORMAT": true, "COLUMN_NAME": true, "COLUMNS": true, "COMMENT": true, "COMMIT": true, "COMMITTED": true, "COMPACT": true, "COMPLETION": true, "COMPONENT": true, "COMPRESSED": true, "COMPRESSION": true, "CONCURRENT": true, "CONDITION": true, "CONNECTION": true, "CONSISTENT": true, "CONSTRAINT": true, "CONSTRAINT_CATALOG": true, "CONSTRAINT_NAME": true, "CONSTRAINT_SCHEMA": true, "CONTAINS": true, "CONTEXT": true, "CONTINUE": true, "CONVERT": true, "COPY": true, "COUNT": true, "CPU": true, "CREATE": true, "CROSS": true, "CUBE": true, "CUME_DIST": true, "CURRENT": true, "CURRENT_DATE": true, "CURRENT_TIME": true, "CURRENT_TIMESTAMP": true, "CURRENT_USER": true, "CURSOR": true, "CURSOR_NAME": true, "CURTIME": true, "DATA": true, "DATABASE": true, "DATABASES": true, "DATAFILE": true, "DATE": true, "DATE_ADD": true, "DATE_SUB": true, "DATETIME": true, "DAY": true, "DAY_HOUR": true, "DAY_MICROSECOND": true, "DAY_MINUTE": true, "DAY_SECOND": true, "DDL": true, "DEALLOCATE": true, "DEC": true, "DECIMAL": true, "DECLARE": true, "DEFAULT": true, "DEFAULT_AUTH": true, "DEFINER": true, "DEFINITION": true, "DELAY_KEY_WRITE": true, "DELAYED": true, "DELETE": true, "DENSE_RANK": true, "DES_KEY_FILE": true, "DESC": true, "DESCRIBE": true, "DESCRIPTION": true, "DETERMINISTIC": true, "DIAGNOSTICS": true, "DIRECTORY": true, "DISABLE": true, "DISCARD": true, "DISK": true, "DISTINCT": true, "DISTINCTROW": true, "DIV": true, "DO": true, "DOUBLE": true, "DROP": true, "DUAL": true, "DUMPFILE": true, "DUPLICATE": true, "DYNAMIC": true, "EACH": true, "ELSE": true, "ELSEIF": true, "EMPTY": true, "ENABLE": true, "ENCLOSED": true, "ENCRYPTION": true, "END": true, "ENDS": true, "ENFORCED": true, "ENGINE": true, "ENGINE_ATTRIBUTE": true, "ENGINES": true, "ENUM": true, "ERROR": true, "ERRORS": true, "ESCAPE": true, "ESCAPED": true, "EVENT": true, "EVENTS": true, "EVERY": true, "EXCEPT": true, "EXCHANGE": true, "EXCLUDE": true, "EXCLUSIVE": true, "EXECUTE": true, "EXISTS": true, "EXIT": true, "EXPANSION": true, "EXPIRE": true, "EXPLAIN": true, "EXPORT": true, "EXTENDED": true, "EXTENT_SIZE": true, "EXTRACT": true, "FAILED_LOGIN_ATTEMPTS": true, "FALSE": true, "FAST": true, "FAULTS": true, "FETCH": true, "FIELDS": true, "FILE": true, "FILE_BLOCK_SIZE": true, "FILTER": true, "FIRST": true, "FIRST_VALUE": true, "FIXED": true, "FLOAT": true, "FLOAT4": true, "FLOAT8": true, "FLUSH": true, "FOLLOWING": true, "FOLLOWS": true, "FOR": true, "FORCE": true, "FOREIGN": true, "FORMAT": true, "FOUND": true, "FROM": true, "FULL": true, "FULLTEXT": true, "FUNCTION": true, "GENERAL": true, "GENERATED": true, "GEOMCOLLECTION": true, "GEOMETRY": true, "GEOMETRYCOLLECTION": true, "GET": true, "GET_FORMAT": true, "GET_MASTER_PUBLIC_KEY": true, "GLOBAL": true, "GRANT": true, "GRANTS": true, "GROUP": true, "GROUP_CONCAT": true, "GROUP_REPLICATION": true, "GROUPING": true, "GROUPS": true, "HANDLER": true, "HASH": true, "HAVING": true, "HELP": true, "HIGH_PRIORITY": true, "HISTOGRAM": true, "HISTORY": true, "HOST": true, "HOSTS": true, "HOUR": true, "HOUR_MICROSECOND": true, "HOUR_MINUTE": true, "HOUR_SECOND": true, "IDENTIFIED": true, "IF": true, "IGNORE": true, "IGNORE_SERVER_IDS": true, "IMPORT": true, "IN": true, "INACTIVE": true, "INC": true, "INCEPTION": true, "INCEPTION_MAGIC_COMMIT": true, "INCEPTION_MAGIC_START": true, "INDEX": true, "INDEXES": true, "INFILE": true, "INITIAL_SIZE": true, "INNER": true, "INOUT": true, "INPLACE": true, "INSENSITIVE": true, "INSERT": true, "INSERT_METHOD": true, "INSTALL": true, "INSTANCE": true, "INT": true, "INT1": true, "INT2": true, "INT3": true, "INT4": true, "INT8": true, "INTEGER": true, "INTERNAL": true, "INTERVAL": true, "INTO": true, "INVISIBLE": true, "INVOKER": true, "IO": true, "IO_AFTER_GTIDS": true, "IO_BEFORE_GTIDS": true, "IO_THREAD": true, "IPC": true, "IS": true, "ISOLATION": true, "ISSUER": true, "ITERATE": true, "JOB": true, "JOBS": true, "JOIN": true, "JSON": true, "JSON_TABLE": true, "JSON_VALUE": true, "KEY": true, "KEY_BLOCK_SIZE": true, "KEYS": true, "KILL": true, "LAG": true, "LANGUAGE": true, "LAST": true, "LAST_VALUE": true, "LATERAL": true, "LEAD": true, "LEADING": true, "LEAVE": true, "LEAVES": true, "LEFT": true, "LESS": true, "LEVEL": true, "LIKE": true, "LIMIT": true, "LINEAR": true, "LINES": true, "LINESTRING": true, "LIST": true, "LOAD": true, "LOCAL": true, "LOCALTIME": true, "LOCALTIMESTAMP": true, "LOCK": true, "LOCKED": true, "LOCKS": true, "LOGFILE": true, "LOGS": true, "LONG": true, "LONGBLOB": true, "LONGTEXT": true, "LOOP": true, "LOW_PRIORITY": true, "MASTER": true, "MASTER_AUTO_POSITION": true, "MASTER_BIND": true, "MASTER_COMPRESSION_ALGORITHMS": true, "MASTER_CONNECT_RETRY": true, "MASTER_DELAY": true, "MASTER_HEARTBEAT_PERIOD": true, "MASTER_HOST": true, "MASTER_LOG_FILE": true, "MASTER_LOG_POS": true, "MASTER_PASSWORD": true, "MASTER_PORT": true, "MASTER_PUBLIC_KEY_PATH": true, "MASTER_RETRY_COUNT": true, "MASTER_SERVER_ID": true, "MASTER_SSL": true, "MASTER_SSL_CA": true, "MASTER_SSL_CAPATH": true, "MASTER_SSL_CERT": true, "MASTER_SSL_CIPHER": true, "MASTER_SSL_CRL": true, "MASTER_SSL_CRLPATH": true, "MASTER_SSL_KEY": true, "MASTER_SSL_VERIFY_SERVER_CERT": true, "MASTER_TLS_CIPHERSUITES": true, "MASTER_TLS_VERSION": true, "MASTER_USER": true, "MASTER_ZSTD_COMPRESSION_LEVEL": true, "MATCH": true, "MAX": true, "MAX_CONNECTIONS_PER_HOUR": true, "MAX_EXECUTION_TIME": true, "MAX_QUERIES_PER_HOUR": true, "MAX_ROWS": true, "MAX_SIZE": true, "MAX_STATEMENT_TIME": true, "MAX_UPDATES_PER_HOUR": true, "MAX_USER_CONNECTIONS": true, "MAXVALUE": true, "MEDIUM": true, "MEDIUMBLOB": true, "MEDIUMINT": true, "MEDIUMTEXT": true, "MEMBER": true, "MEMORY": true, "MERGE": true, "MESSAGE_TEXT": true, "MICROSECOND": true, "MIDDLEINT": true, "MIGRATE": true, "MIN": true, "MIN_ROWS": true, "MINUTE": true, "MINUTE_MICROSECOND": true, "MINUTE_SECOND": true, "MOD": true, "MODE": true, "MODIFIES": true, "MODIFY": true, "MONTH": true, "MULTILINESTRING": true, "MULTIPOINT": true, "MULTIPOLYGON": true, "MUTEX": true, "MYSQL_ERRNO": true, "NAME": true, "NAMES": true, "NATIONAL": true, "NATURAL": true, "NCHAR": true, "NDB": true, "NDBCLUSTER": true, "NESTED": true, "NETWORK_NAMESPACE": true, "NEVER": true, "NEW": true, "NEXT": true, "NO": true, "NO_WAIT": true, "NO_WRITE_TO_BINLOG": true, "NODEGROUP": true, "NONBLOCKING": true, "NONE": true, "NOT": true, "NOW": true, "NOWAIT": true, "NTH_VALUE": true, "NTILE": true, "NULL": true, "NULLS": true, "NUMBER": true, "NUMERIC": true, "NVARCHAR": true, "OF": true, "OFF": true, "OFFSET": true, "OJ": true, "OLD": true, "OLD_PASSWORD": true, "ON": true, "ONE": true, "ONLY": true, "OPEN": true, "OPTIMIZE": true, "OPTIMIZER_COSTS": true, "OPTION": true, "OPTIONAL": true, "OPTIONALLY": true, "OPTIONS": true, "OR": true, "ORDER": true, "ORDINALITY": true, "ORGANIZATION": true, "OTHERS": true, "OUT": true, "OUTER": true, "OUTFILE": true, "OVER": true, "OWNER": true, "PACK_KEYS": true, "PAGE": true, "PARSE_GCOL_EXPR": true, "PARSER": true, "PARTIAL": true, "PARTITION": true, "PARTITIONING": true, "PARTITIONS": true, "PASSWORD": true, "PASSWORD_LOCK_TIME": true, "PATH": true, "PERCENT_RANK": true, "PERSIST": true, "PERSIST_ONLY": true, "PHASE": true, "PLUGIN": true, "PLUGIN_DIR": true, "PLUGINS": true, "POINT": true, "POLYGON": true, "PORT": true, "POSITION": true, "PRECEDES": true, "PRECEDING": true, "PRECISION": true, "PREPARE": true, "PRESERVE": true, "PREV": true, "PRIMARY": true, "PRIVILEGE_CHECKS_USER": true, "PRIVILEGES": true, "PROCEDURE": true, "PROCESS": true, "PROCESSLIST": true, "PROFILE": true, "PROFILES": true, "PROXY": true, "PURGE": true, "QUARTER": true, "QUERIES": true, "QUERY": true, "QUICK": true, "RANDOM": true, "RANGE": true, "RANK": true, "READ": true, "READ_ONLY": true, "READ_WRITE": true, "READS": true, "REAL": true, "REBUILD": true, "RECENT": true, "RECOVER": true, "RECURSIVE": true, "REDO_BUFFER_SIZE": true, "REDOFILE": true, "REDUNDANT": true, "REFERENCE": true, "REFERENCES": true, "REGEXP": true, "RELAY": true, "RELAY_LOG_FILE": true, "RELAY_LOG_POS": true, "RELAY_THREAD": true, "RELAYLOG": true, "RELEASE": true, "RELOAD": true, "REMOVE": true, "RENAME": true, "REORGANIZE": true, "REPAIR": true, "REPEAT": true, "REPEATABLE": true, "REPLACE": true, "REPLICA": true, "REPLICAS": true, "REPLICATE_DO_DB": true, "REPLICATE_DO_TABLE": true, "REPLICATE_IGNORE_DB": true, "REPLICATE_IGNORE_TABLE": true, "REPLICATE_REWRITE_DB": true, "REPLICATE_WILD_DO_TABLE": true, "REPLICATE_WILD_IGNORE_TABLE": true, "REPLICATION": true, "REQUIRE": true, "REQUIRE_ROW_FORMAT": true, "REQUIRE_TABLE_PRIMARY_KEY_CHECK": true, "RESET": true, "RESIGNAL": true, "RESOURCE": true, "RESPECT": true, "RESTART": true, "RESTORE": true, "RESTRICT": true, "RESUME": true, "RETAIN": true, "RETURN": true, "RETURNED_SQLSTATE": true, "RETURNING": true, "RETURNS": true, "REUSE": true, "REVERSE": true, "REVOKE": true, "RIGHT": true, "RLIKE": true, "ROLE": true, "ROLLBACK": true, "ROLLUP": true, "ROTATE": true, "ROUTINE": true, "ROW": true, "ROW_COUNT": true, "ROW_FORMAT": true, "ROW_NUMBER": true, "ROWS": true, "RTREE": true, "SAVEPOINT": true, "SCHEDULE": true, "SCHEMA": true, "SCHEMA_NAME": true, "SCHEMAS": true, "SECOND": true, "SECOND_MICROSECOND": true, "SECONDARY": true, "SECONDARY_ENGINE": true, "SECONDARY_ENGINE_ATTRIBUTE": true, "SECONDARY_LOAD": true, "SECONDARY_UNLOAD": true, "SECURITY": true, "SELECT": true, "SENSITIVE": true, "SEPARATOR": true, "SERIAL": true, "SERIALIZABLE": true, "SERVER": true, "SESSION": true, "SET": true, "SHARD_ROW_ID_BITS": true, "SHARE": true, "SHARED": true, "SHOW": true, "SHUTDOWN": true, "SIGNAL": true, "SIGNED": true, "SIMPLE": true, "SKIP": true, "SLAVE": true, "SLOW": true, "SMALLINT": true, "SNAPSHOT": true, "SOCKET": true, "SOME": true, "SONAME": true, "SOUNDS": true, "SOURCE": true, "SOURCE_CONNECTION_AUTO_FAILOVER": true, "SPATIAL": true, "SPECIFIC": true, "SQL": true, "SQL_AFTER_GTIDS": true, "SQL_AFTER_MTS_GAPS": true, "SQL_BEFORE_GTIDS": true, "SQL_BIG_RESULT": true, "SQL_BUFFER_RESULT": true, "SQL_CACHE": true, "SQL_CALC_FOUND_ROWS": true, "SQL_NO_CACHE": true, "SQL_SMALL_RESULT": true, "SQL_THREAD": true, "SQL_TSI_DAY": true, "SQL_TSI_HOUR": true, "SQL_TSI_MINUTE": true, "SQL_TSI_MONTH": true, "SQL_TSI_QUARTER": true, "SQL_TSI_SECOND": true, "SQL_TSI_WEEK": true, "SQL_TSI_YEAR": true, "SQLEXCEPTION": true, "SQLSTATE": true, "SQLWARNING": true, "SRID": true, "SSL": true, "STACKED": true, "START": true, "STARTING": true, "STARTS": true, "STATS": true, "STATS_AUTO_RECALC": true, "STATS_BUCKETS": true, "STATS_HEALTHY": true, "STATS_HISTOGRAMS": true, "STATS_META": true, "STATS_PERSISTENT": true, "STATS_SAMPLE_PAGES": true, "STATUS": true, "STOP": true, "STORAGE": true, "STORED": true, "STRAIGHT_JOIN": true, "STREAM": true, "STRING": true, "SUBCLASS_ORIGIN": true, "SUBDATE": true, "SUBJECT": true, "SUBPARTITION": true, "SUBPARTITIONS": true, "SUBSTR": true, "SUBSTRING": true, "SUM": true, "SUPER": true, "SUSPEND": true, "SWAPS": true, "SWITCHES": true, "SYSTEM": true, "TABLE": true, "TABLE_CHECKSUM": true, "TABLE_NAME": true, "TABLES": true, "TABLESPACE": true, "TEMPORARY": true, "TEMPTABLE": true, "TERMINATED": true, "TEXT": true, "THAN": true, "THEN": true, "THREAD_PRIORITY": true, "TIDB": true, "TIDB_HJ": true, "TIDB_INLJ": true, "TIDB_SMJ": true, "TIES": true, "TIME": true, "TIMESTAMP": true, "TIMESTAMPADD": true, "TIMESTAMPDIFF": true, "TINYBLOB": true, "TINYINT": true, "TINYTEXT": true, "TLS": true, "TO": true, "TOP": true, "TRACE": true, "TRAILING": true, "TRANSACTION": true, "TRIGGER": true, "TRIGGERS": true, "TRIM": true, "TRUE": true, "TRUNCATE": true, "TYPE": true, "TYPES": true, "UNBOUNDED": true, "UNCOMMITTED": true, "UNDEFINED": true, "UNDO": true, "UNDO_BUFFER_SIZE": true, "UNDOFILE": true, "UNICODE": true, "UNINSTALL": true, "UNION": true, "UNIQUE": true, "UNKNOWN": true, "UNLOCK": true, "UNSIGNED": true, "UNTIL": true, "UPDATE": true, "UPGRADE": true, "USAGE": true, "USE": true, "USE_FRM": true, "USER": true, "USER_RESOURCES": true, "USING": true, "UTC_DATE": true, "UTC_TIME": true, "UTC_TIMESTAMP": true, "VALIDATION": true, "VALUE": true, "VALUES": true, "VARBINARY": true, "VARCHAR": true, "VARCHARACTER": true, "VARIABLES": true, "VARYING": true, "VCPU": true, "VIEW": true, "VIRTUAL": true, "VISIBLE": true, "WAIT": true, "WARNINGS": true, "WEEK": true, "WEIGHT_STRING": true, "WHEN": true, "WHERE": true, "WHILE": true, "WINDOW": true, "WITH": true, "WITHOUT": true, "WORK": true, "WRAPPER": true, "WRITE": true, "X509": true, "XA": true, "XID": true, "XML": true, "XOR": true, "YEAR": true, "YEAR_MONTH": true, "ZEROFILL": true, "ZONE": true, }