config: add configuration entry make TiDB version string configurable (#13775)
This commit is contained in:
@ -29,6 +29,7 @@ import (
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/pingcap/errors"
|
||||
zaplog "github.com/pingcap/log"
|
||||
"github.com/pingcap/parser/mysql"
|
||||
"github.com/pingcap/tidb/util/logutil"
|
||||
tracing "github.com/uber/jaeger-client-go/config"
|
||||
"go.uber.org/atomic"
|
||||
@ -74,8 +75,8 @@ type Config struct {
|
||||
TxnLocalLatches TxnLocalLatches `toml:"txn-local-latches" json:"txn-local-latches"`
|
||||
// Set sys variable lower-case-table-names, ref: https://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html.
|
||||
// TODO: We actually only support mode 2, which keeps the original case, but the comparison is case-insensitive.
|
||||
LowerCaseTableNames int `toml:"lower-case-table-names" json:"lower-case-table-names"`
|
||||
|
||||
LowerCaseTableNames int `toml:"lower-case-table-names" json:"lower-case-table-names"`
|
||||
ServerVersion string `toml:"server-version" json:"server-version"`
|
||||
Log Log `toml:"log" json:"log"`
|
||||
Security Security `toml:"security" json:"security"`
|
||||
Status Status `toml:"status" json:"status"`
|
||||
@ -450,6 +451,7 @@ var defaultConf = Config{
|
||||
Capacity: 2048000,
|
||||
},
|
||||
LowerCaseTableNames: 2,
|
||||
ServerVersion: "",
|
||||
Log: Log{
|
||||
Level: "info",
|
||||
Format: "text",
|
||||
@ -643,6 +645,9 @@ func (c *Config) Load(confFile string) error {
|
||||
if c.TokenLimit == 0 {
|
||||
c.TokenLimit = 1000
|
||||
}
|
||||
if len(c.ServerVersion) > 0 {
|
||||
mysql.ServerVersion = c.ServerVersion
|
||||
}
|
||||
// If any items in confFile file are not mapped into the Config struct, issue
|
||||
// an error and stop the server from starting.
|
||||
undecoded := metaData.Undecoded()
|
||||
|
||||
@ -74,6 +74,12 @@ split-region-max-num = 1000
|
||||
# In order to support "drop primary key" operation , this flag must be true and the table does not have the pkIsHandle flag.
|
||||
alter-primary-key = false
|
||||
|
||||
# server-version is used to change the version string of TiDB in the following scenarios:
|
||||
# 1. the server version returned by builtin-function `VERSION()`.
|
||||
# 2. the server version filled in handshake packets of MySQL Connection Protocol, see https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::Handshake for more details.
|
||||
# if server-version = "", the default value(original TiDB version string) is used.
|
||||
server-version = ""
|
||||
|
||||
# repair mode is used to repair the broken table meta in TiKV in extreme cases.
|
||||
repair-mode = false
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ import (
|
||||
"github.com/BurntSushi/toml"
|
||||
. "github.com/pingcap/check"
|
||||
zaplog "github.com/pingcap/log"
|
||||
"github.com/pingcap/parser/mysql"
|
||||
"github.com/pingcap/tidb/util/logutil"
|
||||
tracing "github.com/uber/jaeger-client-go/config"
|
||||
)
|
||||
@ -179,6 +180,7 @@ alter-primary-key = true
|
||||
delay-clean-table-lock = 5
|
||||
split-region-max-num=10000
|
||||
enable-batch-dml = true
|
||||
server-version = "test_version"
|
||||
repair-mode = true
|
||||
[performance]
|
||||
txn-total-size-limit=2000
|
||||
@ -197,6 +199,8 @@ max-sql-length=1024
|
||||
|
||||
c.Assert(conf.Load(configFile), IsNil)
|
||||
|
||||
c.Assert(conf.ServerVersion, Equals, "test_version")
|
||||
c.Assert(mysql.ServerVersion, Equals, conf.ServerVersion)
|
||||
// Test that the original value will not be clear by load the config file that does not contain the option.
|
||||
c.Assert(conf.Binlog.Enable, Equals, true)
|
||||
c.Assert(conf.Binlog.Strategy, Equals, "hash")
|
||||
|
||||
Reference in New Issue
Block a user