vitess.io/vitess@v0.16.2/go/vt/servenv/mysql.go (about)

     1  /*
     2  Copyright 2022 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  package servenv
    18  
    19  import (
    20  	"github.com/spf13/pflag"
    21  )
    22  
    23  // mySQLServerVersion is what Vitess will present as it's version during the connection handshake,
    24  // and as the value to the @@version system variable. If nothing is provided, Vitess will report itself as
    25  // a specific MySQL version with the vitess version appended to it
    26  var mySQLServerVersion = "8.0.30-Vitess"
    27  
    28  // RegisterMySQLServerFlags installs the flags needed to specify or expose a
    29  // particular MySQL server version from Vitess.
    30  func RegisterMySQLServerFlags(fs *pflag.FlagSet) {
    31  	fs.StringVar(&mySQLServerVersion, "mysql_server_version", mySQLServerVersion, "MySQL server version to advertise.")
    32  }
    33  
    34  // MySQLServerVersion returns the value of the `--mysql_server_version` flag.
    35  func MySQLServerVersion() string {
    36  	return mySQLServerVersion
    37  }
    38  
    39  // SetMySQLServerVersionForTest sets the value of the `--mysql_server_version`
    40  // flag. It is intended for use in tests that require a specific MySQL server
    41  // version (for example, collations) that cannot specify that via the command
    42  // line.
    43  func SetMySQLServerVersionForTest(version string) {
    44  	mySQLServerVersion = version
    45  }
    46  
    47  func init() {
    48  	for _, cmd := range []string{
    49  		"mysqlctl",
    50  		"mysqlctld",
    51  		"vtbackup",
    52  		"vtcombo",
    53  		"vtctl",
    54  		"vtctldclient",
    55  		"vtexplain",
    56  		"vtgate",
    57  		"vtgateclienttest",
    58  		"vttablet",
    59  		"vttestserver",
    60  	} {
    61  		OnParseFor(cmd, RegisterMySQLServerFlags)
    62  	}
    63  }