diff --git a/sessionctx/variable/noop.go b/sessionctx/variable/noop.go index 8eb9a9c7670e6..79c7a63fe3abb 100644 --- a/sessionctx/variable/noop.go +++ b/sessionctx/variable/noop.go @@ -482,7 +482,7 @@ var noopSysVars = []*SysVar{ {Scope: ScopeNone, Name: "tmpdir", Value: "/var/tmp/"}, {Scope: ScopeGlobal, Name: "innodb_thread_concurrency", Value: "0"}, {Scope: ScopeGlobal, Name: "innodb_buffer_pool_dump_pct", Value: ""}, - {Scope: ScopeGlobal | ScopeSession, Name: "lc_time_names", Value: "en_US"}, + {Scope: ScopeGlobal | ScopeSession, Name: "lc_time_names", Value: "en_US", ReadOnly: true}, {Scope: ScopeGlobal | ScopeSession, Name: "max_statement_time", Value: ""}, {Scope: ScopeGlobal | ScopeSession, Name: EndMarkersInJSON, Value: Off, Type: TypeBool, IsHintUpdatable: true}, {Scope: ScopeGlobal, Name: AvoidTemporalUpgrade, Value: Off, Type: TypeBool}, diff --git a/sessionctx/variable/sysvar_test.go b/sessionctx/variable/sysvar_test.go index 8ae408eee6d67..de53b352fd391 100644 --- a/sessionctx/variable/sysvar_test.go +++ b/sessionctx/variable/sysvar_test.go @@ -525,7 +525,7 @@ func TestSkipInit(t *testing.T) { require.True(t, sv.SkipInit()) } -// IsNoop is used by the documentation to auto-generate docs for real sysvars. +// TestIsNoop is used by the documentation to auto-generate docs for real sysvars. func TestIsNoop(t *testing.T) { sv := GetSysVar(TiDBMultiStatementMode) require.False(t, sv.IsNoop) @@ -639,7 +639,7 @@ func TestInstanceScopedVars(t *testing.T) { require.Equal(t, vars.TxnScope.GetVarValue(), val) } -// Test that sysvars defaults are logically valid. i.e. +// TestDefaultValuesAreSettable that sysvars defaults are logically valid. i.e. // the default itself must validate without error provided the scope and read-only is correct. // The default values should also be normalized for consistency. func TestDefaultValuesAreSettable(t *testing.T) { @@ -660,7 +660,7 @@ func TestDefaultValuesAreSettable(t *testing.T) { } } -// This tests that sysvars are logically correct with getter and setter functions. +// TestSettersandGetters tests that sysvars are logically correct with getter and setter functions. // i.e. it doesn't make sense to have a SetSession function on a variable that is only globally scoped. func TestSettersandGetters(t *testing.T) { for _, sv := range GetSysVars() { @@ -782,6 +782,14 @@ func TestIdentity(t *testing.T) { require.Equal(t, val, "21") } +func TestLcTimeNamesReadOnly(t *testing.T) { + sv := GetSysVar("lc_time_names") + 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()