vitess.io/vitess@v0.16.2/go/vt/mysqlctl/capabilityset.go (about) 1 /* 2 Copyright 2019 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 /* 18 Detect server flavors and capabilities 19 */ 20 21 package mysqlctl 22 23 type MySQLFlavor string 24 25 // Flavor constants define the type of mysql flavor being used 26 const ( 27 FlavorMySQL MySQLFlavor = "mysql" 28 FlavorPercona MySQLFlavor = "percona" 29 FlavorMariaDB MySQLFlavor = "mariadb" 30 ) 31 32 // Mysqld is the object that represents a mysqld daemon running on this server. 33 type capabilitySet struct { 34 flavor MySQLFlavor 35 version ServerVersion 36 } 37 38 func newCapabilitySet(f MySQLFlavor, v ServerVersion) (c capabilitySet) { 39 c.flavor = f 40 c.version = v 41 return 42 } 43 44 func (c *capabilitySet) hasMySQLUpgradeInServer() bool { 45 return c.isMySQLLike() && c.version.atLeast(ServerVersion{Major: 8, Minor: 0, Patch: 16}) 46 } 47 func (c *capabilitySet) hasInitializeInServer() bool { 48 return c.isMySQLLike() && c.version.atLeast(ServerVersion{Major: 5, Minor: 7, Patch: 0}) 49 } 50 func (c *capabilitySet) hasMaria104InstallDb() bool { 51 return c.isMariaDB() && c.version.atLeast(ServerVersion{Major: 10, Minor: 4, Patch: 0}) 52 } 53 54 // hasDisableRedoLog tells you if the version of MySQL in use can disable redo logging. 55 // 56 // As of MySQL 8.0.21, you can disable redo logging using the ALTER INSTANCE 57 // DISABLE INNODB REDO_LOG statement. This functionality is intended for 58 // loading data into a new MySQL instance. Disabling redo logging speeds up 59 // data loading by avoiding redo log writes and doublewrite buffering. 60 // 61 // https://dev.mysql.com/doc/refman/8.0/en/innodb-redo-log.html#innodb-disable-redo-logging 62 func (c *capabilitySet) hasDisableRedoLog() bool { 63 return c.isMySQLLike() && c.version.atLeast(ServerVersion{Major: 8, Minor: 0, Patch: 21}) 64 } 65 66 // IsMySQLLike tests if the server is either MySQL 67 // or Percona Server. At least currently, Vitess doesn't 68 // make use of any specific Percona Server features. 69 func (c *capabilitySet) isMySQLLike() bool { 70 return c.flavor == FlavorMySQL || c.flavor == FlavorPercona 71 } 72 func (c *capabilitySet) isMariaDB() bool { 73 return c.flavor == FlavorMariaDB 74 }