diff --git a/doc/releasenotes/16_0_0_summary.md b/doc/releasenotes/16_0_0_summary.md index 45a53eccf3d..3e3413b228e 100644 --- a/doc/releasenotes/16_0_0_summary.md +++ b/doc/releasenotes/16_0_0_summary.md @@ -61,6 +61,11 @@ The flag `disable-replication-manager` is deprecated and will be removed in a la ### Breaking Changes +#### VTGate Advertised MySQL Version + +VTGate now advertises MySQL version 8.0.31. This is a breaking change for clients that rely on the VTGate advertised MySQL version and still use MySQL 5.7. +The users can set the `mysql_server_version` flag to advertise the correct version. + #### Default MySQL version on Docker The default major MySQL version used by our `vitess/lite:latest` image is going from `5.7` to `8.0`. Additionally, the default patch version of the `vitess/lite:mysql80` image goes from `8.0.23` to `8.0.31`. diff --git a/go/flags/endtoend/mysqlctl.txt b/go/flags/endtoend/mysqlctl.txt index f7e3c3fac8c..87b59800237 100644 --- a/go/flags/endtoend/mysqlctl.txt +++ b/go/flags/endtoend/mysqlctl.txt @@ -57,7 +57,7 @@ Global flags: --logtostderr log to standard error instead of files --max-stack-size int configure the maximum stack size in bytes (default 67108864) --mysql_port int MySQL port (default 3306) - --mysql_server_version string MySQL server version to advertise. + --mysql_server_version string MySQL server version to advertise. (default "8.0.31-Vitess") --mysql_socket string Path to the mysqld socket file --mysqlctl_client_protocol string the protocol to use to talk to the mysqlctl server (default "grpc") --mysqlctl_mycnf_template string template file to use for generating the my.cnf file during server init diff --git a/go/flags/endtoend/mysqlctld.txt b/go/flags/endtoend/mysqlctld.txt index 0061456b836..86853500a78 100644 --- a/go/flags/endtoend/mysqlctld.txt +++ b/go/flags/endtoend/mysqlctld.txt @@ -68,7 +68,7 @@ Usage of mysqlctld: --logtostderr log to standard error instead of files --max-stack-size int configure the maximum stack size in bytes (default 67108864) --mysql_port int MySQL port (default 3306) - --mysql_server_version string MySQL server version to advertise. + --mysql_server_version string MySQL server version to advertise. (default "8.0.31-Vitess") --mysql_socket string Path to the mysqld socket file --mysqlctl_mycnf_template string template file to use for generating the my.cnf file during server init --mysqlctl_socket string socket file to use for remote mysqlctl actions (empty for local actions) diff --git a/go/flags/endtoend/vtbackup.txt b/go/flags/endtoend/vtbackup.txt index 9323702020e..451e2489ab7 100644 --- a/go/flags/endtoend/vtbackup.txt +++ b/go/flags/endtoend/vtbackup.txt @@ -119,7 +119,7 @@ Usage of vtbackup: --mycnf_socket_file string mysql socket file --mycnf_tmp_dir string mysql tmp directory --mysql_port int mysql port (default 3306) - --mysql_server_version string MySQL server version to advertise. + --mysql_server_version string MySQL server version to advertise. (default "8.0.31-Vitess") --mysql_socket string path to the mysql socket --mysql_timeout duration how long to wait for mysqld startup (default 5m0s) --port int port for the server diff --git a/go/flags/endtoend/vtctldclient.txt b/go/flags/endtoend/vtctldclient.txt index 08930d5e924..b77cef271db 100644 --- a/go/flags/endtoend/vtctldclient.txt +++ b/go/flags/endtoend/vtctldclient.txt @@ -108,7 +108,7 @@ Flags: --log_dir string If non-empty, write log files in this directory --log_rotate_max_size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) --logtostderr log to standard error instead of files - --mysql_server_version string MySQL server version to advertise. + --mysql_server_version string MySQL server version to advertise. (default "8.0.31-Vitess") --purge_logs_interval duration how often try to remove old logs (default 1h0m0s) --security_policy string the name of a registered security policy to use for controlling access to URLs - empty means allow all for anyone (built-in policies: deny-all, read-only) --server string server to use for connection (required) diff --git a/go/flags/endtoend/vtexplain.txt b/go/flags/endtoend/vtexplain.txt index 9ca491bf691..02fddc86988 100644 --- a/go/flags/endtoend/vtexplain.txt +++ b/go/flags/endtoend/vtexplain.txt @@ -14,7 +14,7 @@ Usage of vtexplain: --log_err_stacks log stack traces for errors --log_rotate_max_size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) --logtostderr log to standard error instead of files - --mysql_server_version string MySQL server version to advertise. + --mysql_server_version string MySQL server version to advertise. (default "8.0.31-Vitess") --normalize Whether to enable vtgate normalization --output-mode string Output in human-friendly text or json (default "text") --planner-version string Sets the query planner version to use when generating the explain output. Valid values are V3 and Gen4. An empty value will use VTGate's default planner diff --git a/go/flags/endtoend/vtgate.txt b/go/flags/endtoend/vtgate.txt index 43435c35085..f764657fc5a 100644 --- a/go/flags/endtoend/vtgate.txt +++ b/go/flags/endtoend/vtgate.txt @@ -115,7 +115,7 @@ Usage of vtgate: --mysql_server_ssl_key string Path to ssl key for mysql server plugin SSL --mysql_server_ssl_server_ca string path to server CA in PEM format, which will be combine with server cert, return full certificate chain to clients --mysql_server_tls_min_version string Configures the minimal TLS version negotiated when SSL is enabled. Defaults to TLSv1.2. Options: TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3. - --mysql_server_version string MySQL server version to advertise. + --mysql_server_version string MySQL server version to advertise. (default "8.0.31-Vitess") --mysql_server_write_timeout duration connection write timeout --mysql_slow_connect_warn_threshold duration Warn if it takes more than the given threshold for a mysql connection to establish --mysql_tcp_version string Select tcp, tcp4, or tcp6 to control the socket type. (default "tcp") diff --git a/go/flags/endtoend/vttablet.txt b/go/flags/endtoend/vttablet.txt index 16022f250f1..4309df4dbb6 100644 --- a/go/flags/endtoend/vttablet.txt +++ b/go/flags/endtoend/vttablet.txt @@ -188,7 +188,7 @@ Usage of vttablet: --mycnf_slow_log_path string mysql slow query log path --mycnf_socket_file string mysql socket file --mycnf_tmp_dir string mysql tmp directory - --mysql_server_version string MySQL server version to advertise. + --mysql_server_version string MySQL server version to advertise. (default "8.0.31-Vitess") --mysqlctl_mycnf_template string template file to use for generating the my.cnf file during server init --mysqlctl_socket string socket file to use for remote mysqlctl actions (empty for local actions) --onclose_timeout duration wait no more than this for OnClose handlers before stopping (default 10s) diff --git a/go/flags/endtoend/vttestserver.txt b/go/flags/endtoend/vttestserver.txt index b0eb6bde0ed..baa75caf0bc 100644 --- a/go/flags/endtoend/vttestserver.txt +++ b/go/flags/endtoend/vttestserver.txt @@ -71,7 +71,7 @@ Usage of vttestserver: --min_table_shard_size int The minimum number of initial rows in a table shard. Ignored if--initialize_with_random_data is false. The actual number is chosen randomly. (default 1000) --mysql_bind_host string which host to bind vtgate mysql listener to (default "localhost") --mysql_only If this flag is set only mysql is initialized. The rest of the vitess components are not started. Also, the output specifies the mysql unix socket instead of the vtgate port. - --mysql_server_version string MySQL server version to advertise. + --mysql_server_version string MySQL server version to advertise. (default "8.0.31-Vitess") --mysqlctl_mycnf_template string template file to use for generating the my.cnf file during server init --mysqlctl_socket string socket file to use for remote mysqlctl actions (empty for local actions) --null_probability float The probability to initialize a field with 'NULL' if --initialize_with_random_data is true. Only applies to fields that can contain NULL values. (default 0.1) diff --git a/go/mysql/collations/local.go b/go/mysql/collations/local.go index 988de156973..c0d3c10da09 100644 --- a/go/mysql/collations/local.go +++ b/go/mysql/collations/local.go @@ -35,14 +35,7 @@ func Local() *Environment { if !flag.Parsed() { panic("collations.Local() called too early") } - if mySQLVersion := servenv.MySQLServerVersion(); mySQLVersion == "" { - // The default server version used by vtgate is 5.7.9 - // NOTE: this should be changed along with the effective default - // for the vtgate mysql_server_version flag. - defaultEnv = fetchCacheEnvironment(collverMySQL57) - } else { - defaultEnv = NewEnvironment(mySQLVersion) - } + defaultEnv = NewEnvironment(servenv.MySQLServerVersion()) }) return defaultEnv } diff --git a/go/vt/servenv/buildinfo.go b/go/vt/servenv/buildinfo.go index d00b4f063ff..15e34217dae 100644 --- a/go/vt/servenv/buildinfo.go +++ b/go/vt/servenv/buildinfo.go @@ -91,10 +91,7 @@ func (v *versionInfo) String() string { } func (v *versionInfo) MySQLVersion() string { - if mySQLServerVersion != "" { - return mySQLServerVersion - } - return "5.7.9-vitess-" + v.version + return mySQLServerVersion } func init() { diff --git a/go/vt/servenv/buildinfo_test.go b/go/vt/servenv/buildinfo_test.go index b8262562d09..5ad208f0fb0 100644 --- a/go/vt/servenv/buildinfo_test.go +++ b/go/vt/servenv/buildinfo_test.go @@ -45,5 +45,5 @@ func TestVersionString(t *testing.T) { assert.Equal(t, "Version: v1.2.3-SNAPSHOT (Jenkins build 422) (Git revision d54b87ca0be09b678bb4490060e8f23f890ddb92 branch 'gitBranch') built on time is now by user@host using 1.19.3 amiga/amd64", v.String()) - assert.Equal(t, "5.7.9-vitess-v1.2.3-SNAPSHOT", v.MySQLVersion()) + assert.Equal(t, "8.0.31-Vitess", v.MySQLVersion()) } diff --git a/go/vt/servenv/mysql.go b/go/vt/servenv/mysql.go index e5d37bd5391..c3f62718124 100644 --- a/go/vt/servenv/mysql.go +++ b/go/vt/servenv/mysql.go @@ -23,7 +23,7 @@ import ( // mySQLServerVersion is what Vitess will present as it's version during the connection handshake, // and as the value to the @@version system variable. If nothing is provided, Vitess will report itself as // a specific MySQL version with the vitess version appended to it -var mySQLServerVersion string +var mySQLServerVersion = "8.0.31-Vitess" // RegisterMySQLServerFlags installs the flags needed to specify or expose a // particular MySQL server version from Vitess. diff --git a/go/vt/sqlparser/parse_test.go b/go/vt/sqlparser/parse_test.go index 5d30d516465..c83cb35a32b 100644 --- a/go/vt/sqlparser/parse_test.go +++ b/go/vt/sqlparser/parse_test.go @@ -5684,9 +5684,9 @@ partition by range (id) for _, testcase := range testcases { t.Run(testcase.input+":"+testcase.mysqlVersion, func(t *testing.T) { - oldMySQLVersion := MySQLVersion - defer func() { MySQLVersion = oldMySQLVersion }() - MySQLVersion = testcase.mysqlVersion + oldMySQLVersion := mySQLParserVersion + defer func() { mySQLParserVersion = oldMySQLVersion }() + mySQLParserVersion = testcase.mysqlVersion tree, err := Parse(testcase.input) require.NoError(t, err, testcase.input) out := String(tree) diff --git a/go/vt/sqlparser/parser.go b/go/vt/sqlparser/parser.go index a1033ef7c58..ae630ce3dea 100644 --- a/go/vt/sqlparser/parser.go +++ b/go/vt/sqlparser/parser.go @@ -43,8 +43,8 @@ var parserPool = sync.Pool{ // zeroParser is a zero-initialized parser to help reinitialize the parser for pooling. var zeroParser yyParserImpl -// MySQLVersion is the version of MySQL that the parser would emulate -var MySQLVersion = "50709" // default version if nothing else is stated +// mySQLParserVersion is the version of MySQL that the parser would emulate +var mySQLParserVersion string // yyParsePooled is a wrapper around yyParse that pools the parser objects. There isn't a // particularly good reason to use yyParse directly, since it immediately discards its parser. @@ -108,18 +108,25 @@ func Parse2(sql string) (Statement, BindVars, error) { func checkParserVersionFlag() { if flag.Parsed() { versionFlagSync.Do(func() { - if mySQLVersion := servenv.MySQLServerVersion(); mySQLVersion != "" { - convVersion, err := convertMySQLVersionToCommentVersion(mySQLVersion) - if err != nil { - log.Error(err) - } else { - MySQLVersion = convVersion - } + convVersion, err := convertMySQLVersionToCommentVersion(servenv.MySQLServerVersion()) + if err != nil { + log.Fatalf("unable to parse mysql version: %v", err) } + mySQLParserVersion = convVersion }) } } +// SetParserVersion sets the mysql parser version +func SetParserVersion(version string) { + mySQLParserVersion = version +} + +// GetParserVersion returns the version of the mysql parser +func GetParserVersion() string { + return mySQLParserVersion +} + // convertMySQLVersionToCommentVersion converts the MySQL version into comment version format. func convertMySQLVersionToCommentVersion(version string) (string, error) { var res = make([]int, 3) @@ -307,5 +314,5 @@ loop: } func IsMySQL80AndAbove() bool { - return MySQLVersion >= "80000" + return mySQLParserVersion >= "80000" } diff --git a/go/vt/sqlparser/token.go b/go/vt/sqlparser/token.go index 7a4c95adec7..16cda39dd46 100644 --- a/go/vt/sqlparser/token.go +++ b/go/vt/sqlparser/token.go @@ -674,7 +674,7 @@ func (tkn *Tokenizer) scanMySQLSpecificComment() (int, string) { commentVersion, sql := ExtractMysqlComment(tkn.buf[start:tkn.Pos]) - if MySQLVersion >= commentVersion { + if mySQLParserVersion >= commentVersion { // Only add the special comment to the tokenizer if the version of MySQL is higher or equal to the comment version tkn.specialComment = NewStringTokenizer(sql) } diff --git a/go/vt/sqlparser/token_test.go b/go/vt/sqlparser/token_test.go index 36229c55e7b..0fd43b8f86c 100644 --- a/go/vt/sqlparser/token_test.go +++ b/go/vt/sqlparser/token_test.go @@ -237,7 +237,7 @@ func TestVersion(t *testing.T) { for _, tcase := range testcases { t.Run(tcase.version+"_"+tcase.in, func(t *testing.T) { - MySQLVersion = tcase.version + mySQLParserVersion = tcase.version tok := NewStringTokenizer(tcase.in) for _, expectedID := range tcase.id { id, _ := tok.Scan() diff --git a/go/vt/vtexplain/vtexplain_vttablet.go b/go/vt/vtexplain/vtexplain_vttablet.go index 6784efe4cbd..761b71cb572 100644 --- a/go/vt/vtexplain/vtexplain_vttablet.go +++ b/go/vt/vtexplain/vtexplain_vttablet.go @@ -408,6 +408,10 @@ func newTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options) (*tablet Fields: mysql.BaseShowTablesFields, Rows: showTableRows, }) + tEnv.addResult(mysql.TablesWithSize80, &sqltypes.Result{ + Fields: mysql.BaseShowTablesFields, + Rows: showTableRows, + }) indexRows := make([][]sqltypes.Value, 0, 4) for _, ddl := range ddls { diff --git a/go/vt/vtgate/engine/set_test.go b/go/vt/vtgate/engine/set_test.go index 877aadf6502..0f7e0fd1641 100644 --- a/go/vt/vtgate/engine/set_test.go +++ b/go/vt/vtgate/engine/set_test.go @@ -563,10 +563,10 @@ func TestSetTable(t *testing.T) { tc.input = &SingleRow{} } - oldMySQLVersion := sqlparser.MySQLVersion - defer func() { sqlparser.MySQLVersion = oldMySQLVersion }() + oldMySQLVersion := sqlparser.GetParserVersion() + defer func() { sqlparser.SetParserVersion(oldMySQLVersion) }() if tc.mysqlVersion != "" { - sqlparser.MySQLVersion = tc.mysqlVersion + sqlparser.SetParserVersion(tc.mysqlVersion) } set := &Set{ diff --git a/go/vt/vtgate/executor_select_test.go b/go/vt/vtgate/executor_select_test.go index 3eb44b060e4..ff028bd892c 100644 --- a/go/vt/vtgate/executor_select_test.go +++ b/go/vt/vtgate/executor_select_test.go @@ -161,7 +161,7 @@ func TestSystemVariablesMySQLBelow80(t *testing.T) { executor, sbc1, _, _ := createExecutorEnv() executor.normalize = true - sqlparser.MySQLVersion = "57000" + sqlparser.SetParserVersion("57000") setVarEnabled = true session := NewAutocommitSession(&vtgatepb.Session{EnableSystemSettings: true, TargetString: "TestExecutor"}) @@ -197,7 +197,7 @@ func TestSystemVariablesWithSetVarDisabled(t *testing.T) { executor, sbc1, _, _ := createExecutorEnv() executor.normalize = true - sqlparser.MySQLVersion = "80000" + sqlparser.SetParserVersion("80000") setVarEnabled = false defer func() { setVarEnabled = true @@ -235,7 +235,7 @@ func TestSetSystemVariablesTx(t *testing.T) { executor, sbc1, _, _ := createExecutorEnv() executor.normalize = true - sqlparser.MySQLVersion = "80001" + sqlparser.SetParserVersion("80001") session := NewAutocommitSession(&vtgatepb.Session{EnableSystemSettings: true, TargetString: "TestExecutor"}) @@ -283,7 +283,7 @@ func TestSetSystemVariables(t *testing.T) { executor, _, _, lookup := createExecutorEnv() executor.normalize = true - sqlparser.MySQLVersion = "80001" + sqlparser.SetParserVersion("80001") session := NewAutocommitSession(&vtgatepb.Session{EnableSystemSettings: true, TargetString: KsTestUnsharded, SystemVariables: map[string]string{}}) diff --git a/go/vt/vtgate/executor_set_test.go b/go/vt/vtgate/executor_set_test.go index f35629b489e..36cfc9d9140 100644 --- a/go/vt/vtgate/executor_set_test.go +++ b/go/vt/vtgate/executor_set_test.go @@ -508,10 +508,10 @@ func TestSetVar(t *testing.T) { executor, _, _, sbc := createExecutorEnv() executor.normalize = true - oldVersion := sqlparser.MySQLVersion - sqlparser.MySQLVersion = "80000" + oldVersion := sqlparser.GetParserVersion() + sqlparser.SetParserVersion("80000") defer func() { - sqlparser.MySQLVersion = oldVersion + sqlparser.SetParserVersion(oldVersion) }() session := NewAutocommitSession(&vtgatepb.Session{EnableSystemSettings: true, TargetString: KsTestUnsharded}) @@ -552,10 +552,10 @@ func TestSetVarShowVariables(t *testing.T) { executor, _, _, sbc := createExecutorEnv() executor.normalize = true - oldVersion := sqlparser.MySQLVersion - sqlparser.MySQLVersion = "80000" + oldVersion := sqlparser.GetParserVersion() + sqlparser.SetParserVersion("80000") defer func() { - sqlparser.MySQLVersion = oldVersion + sqlparser.SetParserVersion(oldVersion) }() session := NewAutocommitSession(&vtgatepb.Session{EnableSystemSettings: true, TargetString: KsTestUnsharded}) diff --git a/go/vt/vtgate/plugin_mysql_server.go b/go/vt/vtgate/plugin_mysql_server.go index 280156ccc32..4a6f45ce629 100644 --- a/go/vt/vtgate/plugin_mysql_server.go +++ b/go/vt/vtgate/plugin_mysql_server.go @@ -475,9 +475,7 @@ func initMySQLProtocol() { if err != nil { log.Exitf("mysql.NewListener failed: %v", err) } - if mySQLVersion := servenv.MySQLServerVersion(); mySQLVersion != "" { - mysqlListener.ServerVersion = mySQLVersion - } + mysqlListener.ServerVersion = servenv.MySQLServerVersion() if mysqlSslCert != "" && mysqlSslKey != "" { tlsVersion, err := vttls.TLSVersionToNumber(mysqlTLSMinVersion) if err != nil { diff --git a/go/vt/vttablet/tabletmanager/tm_init_test.go b/go/vt/vttablet/tabletmanager/tm_init_test.go index 596ba1884fb..e1225abd464 100644 --- a/go/vt/vttablet/tabletmanager/tm_init_test.go +++ b/go/vt/vttablet/tabletmanager/tm_init_test.go @@ -45,7 +45,7 @@ import ( ) var ( - dbServerVersion = "5.7.0" + dbServerVersion = "8.0.0" charsetName = "utf8mb4" dbsvCollID = collations.NewEnvironment(dbServerVersion).DefaultCollationForCharset(charsetName).ID() ) diff --git a/go/vt/vttest/vtprocess.go b/go/vt/vttest/vtprocess.go index ed43915c2ff..11761cfa2a2 100644 --- a/go/vt/vttest/vtprocess.go +++ b/go/vt/vttest/vtprocess.go @@ -258,10 +258,7 @@ func VtcomboProcess(environment Environment, args *Config, mysql MySQLManager) ( if args.VSchemaDDLAuthorizedUsers != "" { vt.ExtraArgs = append(vt.ExtraArgs, []string{"--vschema_ddl_authorized_users", args.VSchemaDDLAuthorizedUsers}...) } - if mySQLVersion := servenv.MySQLServerVersion(); mySQLVersion != "" { - vt.ExtraArgs = append(vt.ExtraArgs, "--mysql_server_version", mySQLVersion) - } - + vt.ExtraArgs = append(vt.ExtraArgs, "--mysql_server_version", servenv.MySQLServerVersion()) if socket != "" { vt.ExtraArgs = append(vt.ExtraArgs, []string{ "--db_socket", socket,