From e5468b7d7df1daf4a37082b3faefa8d7d79f89e1 Mon Sep 17 00:00:00 2001 From: djshow832 <873581766@qq.com> Date: Thu, 29 Sep 2022 16:45:57 +0800 Subject: [PATCH] revert lc_messages --- sessionctx/variable/noop.go | 3 ++- sessionctx/variable/sysvar_test.go | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sessionctx/variable/noop.go b/sessionctx/variable/noop.go index b720490d03423..398ea09f3ec92 100644 --- a/sessionctx/variable/noop.go +++ b/sessionctx/variable/noop.go @@ -295,7 +295,8 @@ var noopSysVars = []*SysVar{ {Scope: ScopeGlobal, Name: SlowQueryLog, Value: "0"}, {Scope: ScopeSession, Name: "debug_sync", Value: ""}, {Scope: ScopeGlobal, Name: InnodbStatsAutoRecalc, Value: "1"}, - {Scope: ScopeGlobal | ScopeSession, Name: "lc_messages", Value: "en_US", ReadOnly: true}, + // lc_messages cannot be read_only, see https://github.com/pingcap/tidb/issues/38231. + {Scope: ScopeGlobal | ScopeSession, Name: "lc_messages", Value: "en_US"}, {Scope: ScopeGlobal | ScopeSession, Name: "bulk_insert_buffer_size", Value: "8388608", IsHintUpdatable: true}, {Scope: ScopeGlobal | ScopeSession, Name: BinlogDirectNonTransactionalUpdates, Value: Off, Type: TypeBool}, {Scope: ScopeGlobal, Name: "innodb_change_buffering", Value: "all"}, diff --git a/sessionctx/variable/sysvar_test.go b/sessionctx/variable/sysvar_test.go index a3aadde315370..a9e97ec5338ca 100644 --- a/sessionctx/variable/sysvar_test.go +++ b/sessionctx/variable/sysvar_test.go @@ -468,12 +468,17 @@ func TestLcTimeNamesReadOnly(t *testing.T) { require.Error(t, err) } -func TestLcMessagesReadOnly(t *testing.T) { +func TestLcMessages(t *testing.T) { sv := GetSysVar("lc_messages") vars := NewSessionVars() vars.GlobalVarsAccessor = NewMockGlobalAccessor4Tests() - _, err := sv.Validate(vars, "newvalue", ScopeGlobal) - require.Error(t, err) + _, err := sv.Validate(vars, "zh_CN", ScopeGlobal) + require.NoError(t, err) + err = sv.SetSessionFromHook(vars, "zh_CN") + require.NoError(t, err) + val, err := vars.GetSessionOrGlobalSystemVar("lc_messages") + require.NoError(t, err) + require.Equal(t, val, "zh_CN") } func TestDDLWorkers(t *testing.T) {