From 8a1847e8ae6c22961f531cbb33ccecdd06d18c05 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Wed, 19 Sep 2018 22:24:34 -0600 Subject: [PATCH] Added hostname sysvar, fixes #7740 (#7750) --- sessionctx/variable/sysvar.go | 2 +- sessionctx/variable/tidb_vars.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 248fbaa8a273d..220f901a9c5ce 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -287,7 +287,7 @@ var defaultSysVars = []*SysVar{ {ScopeGlobal, "thread_cache_size", "9"}, {ScopeGlobal, "log_slow_admin_statements", "OFF"}, {ScopeNone, "innodb_checksums", "ON"}, - {ScopeNone, "hostname", "localhost"}, + {ScopeNone, "hostname", ServerHostname}, {ScopeGlobal | ScopeSession, "auto_increment_offset", "1"}, {ScopeNone, "ft_stopword_file", "(built-in)"}, {ScopeGlobal, "innodb_max_dirty_pages_pct_lwm", "0"}, diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go index e05149e13e052..3c96828778b17 100644 --- a/sessionctx/variable/tidb_vars.go +++ b/sessionctx/variable/tidb_vars.go @@ -13,6 +13,10 @@ package variable +import ( + "os" +) + /* Steps to add a new TiDB specific system variable: @@ -229,4 +233,5 @@ var ( maxDDLReorgWorkerCount int32 = 128 // DDLSlowOprThreshold is the threshold for ddl slow operations, uint is millisecond. DDLSlowOprThreshold uint32 = 300 + ServerHostname, _ = os.Hostname() )