From 6d210360914b82ad20c0e5b2d16d6b11075cb481 Mon Sep 17 00:00:00 2001 From: fanrenhoo Date: Wed, 6 Apr 2022 15:59:12 +0800 Subject: [PATCH] make the lc_messages read only except set to en_US for issue#33707 Signed-off-by: fanrenhoo --- sessionctx/variable/noop.go | 2 +- sessionctx/variable/sysvar_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sessionctx/variable/noop.go b/sessionctx/variable/noop.go index 449a9aef63f39..4f2cdac1aa690 100644 --- a/sessionctx/variable/noop.go +++ b/sessionctx/variable/noop.go @@ -296,7 +296,7 @@ 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"}, + {Scope: ScopeGlobal | ScopeSession, Name: "lc_messages", Value: "en_US", ReadOnly: true}, {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 0d694d8b9af88..ec1bed29acfbd 100644 --- a/sessionctx/variable/sysvar_test.go +++ b/sessionctx/variable/sysvar_test.go @@ -819,6 +819,14 @@ func TestLcTimeNamesReadOnly(t *testing.T) { require.Error(t, err) } +func TestLcMessagesReadOnly(t *testing.T) { + sv := GetSysVar("lc_messages") + vars := NewSessionVars() + vars.GlobalVarsAccessor = NewMockGlobalAccessor4Tests() + _, err := sv.Validate(vars, "newvalue", ScopeGlobal) + require.Error(t, err) +} + func TestDDLWorkers(t *testing.T) { svWorkerCount, svBatchSize := GetSysVar(TiDBDDLReorgWorkerCount), GetSysVar(TiDBDDLReorgBatchSize) vars := NewSessionVars()