Skip to content

Commit

Permalink
config: add configuration entry make TiDB version string configurable (
Browse files Browse the repository at this point in the history
  • Loading branch information
reafans authored and sre-bot committed Dec 5, 2019
1 parent 251574b commit b6a30b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/BurntSushi/toml"
"github.com/pingcap/errors"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/util/logutil"
tracing "github.com/uber/jaeger-client-go/config"
"go.uber.org/atomic"
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -352,6 +353,7 @@ var defaultConf = Config{
Capacity: 2048000,
},
LowerCaseTableNames: 2,
ServerVersion: "",
Log: Log{
Level: "info",
Format: "text",
Expand Down Expand Up @@ -542,6 +544,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.
Expand Down
6 changes: 6 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,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 = ""

[log]
# Log level: debug, info, warn, error, fatal.
level = "info"
Expand Down
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/util/logutil"
tracing "github.com/uber/jaeger-client-go/config"
)
Expand Down Expand Up @@ -65,6 +66,7 @@ unrecognized-option-test = true
token-limit = 0
alter-primary-key = true
split-region-max-num=10000
server-version = "test_version"
[performance]
txn-entry-count-limit=2000
txn-total-size-limit=2000
Expand All @@ -83,6 +85,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")
Expand Down

0 comments on commit b6a30b8

Please sign in to comment.