diff --git a/pkg/session/session.go b/pkg/session/session.go index f8cefa8866273..d3de4ad6a1588 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -1186,10 +1186,6 @@ func createSessionFunc(store kv.Storage) pools.Factory { if err != nil { return nil, errors.Trace(err) } - err = se.sessionVars.SetSystemVar(variable.TiDBEnableWindowFunction, variable.BoolToOnOff(variable.DefEnableWindowFunction)) - if err != nil { - return nil, errors.Trace(err) - } err = se.sessionVars.SetSystemVar(variable.TiDBConstraintCheckInPlacePessimistic, variable.On) if err != nil { return nil, errors.Trace(err) diff --git a/pkg/sessionctx/variable/session.go b/pkg/sessionctx/variable/session.go index a3d0b7f8dd556..7c66d9797f3ef 100644 --- a/pkg/sessionctx/variable/session.go +++ b/pkg/sessionctx/variable/session.go @@ -2213,6 +2213,7 @@ func NewSessionVars(hctx HookContext) *SessionVars { DefaultCollationForUTF8MB4: mysql.DefaultCollationName, GroupConcatMaxLen: DefGroupConcatMaxLen, EnableRedactLog: DefTiDBRedactLog, + EnableWindowFunction: DefEnableWindowFunction, } vars.status.Store(uint32(mysql.ServerStatusAutocommit)) vars.StmtCtx.ResourceGroupName = resourcegroup.DefaultResourceGroupName diff --git a/pkg/sessionctx/variable/sysvar_test.go b/pkg/sessionctx/variable/sysvar_test.go index be32ef1d2933e..b2739f8d9d92a 100644 --- a/pkg/sessionctx/variable/sysvar_test.go +++ b/pkg/sessionctx/variable/sysvar_test.go @@ -1742,6 +1742,17 @@ func TestTiDBSchemaCacheSize(t *testing.T) { require.Error(t, err) } +func TestEnableWindowFunction(t *testing.T) { + vars := NewSessionVars(nil) + require.Equal(t, vars.EnableWindowFunction, DefEnableWindowFunction) + require.NoError(t, vars.SetSystemVar(TiDBEnableWindowFunction, "on")) + require.Equal(t, vars.EnableWindowFunction, true) + require.NoError(t, vars.SetSystemVar(TiDBEnableWindowFunction, "0")) + require.Equal(t, vars.EnableWindowFunction, false) + require.NoError(t, vars.SetSystemVar(TiDBEnableWindowFunction, "1")) + require.Equal(t, vars.EnableWindowFunction, true) +} + func TestTiDBAutoAnalyzeConcurrencyValidation(t *testing.T) { vars := NewSessionVars(nil)