sessionctx: set skipInit false for TiDBOptProjectionPushDown and TiDBOptAggPushDown (#35491)
close pingcap/tidb#35083
This commit is contained in:
@ -6696,3 +6696,24 @@ func TestDecimalOverflow(t *testing.T) {
|
||||
tk.MustExec("insert into deci values (1234567890.123456789012345678901234567890,987654321098765432109876543210987654321098765432109876543210)")
|
||||
tk.MustQuery("select a from deci union ALL select b from deci;").Sort().Check(testkit.Rows("1234567890.123456789012345678901234567890", "99999999999999999999999999999999999.999999999999999999999999999999"))
|
||||
}
|
||||
|
||||
func TestIssue35083(t *testing.T) {
|
||||
defer func() {
|
||||
variable.SetSysVar(variable.TiDBOptProjectionPushDown, variable.BoolToOnOff(config.GetGlobalConfig().Performance.ProjectionPushDown))
|
||||
}()
|
||||
defer config.RestoreFunc()()
|
||||
config.UpdateGlobal(func(conf *config.Config) {
|
||||
conf.Performance.ProjectionPushDown = true
|
||||
})
|
||||
variable.SetSysVar(variable.TiDBOptProjectionPushDown, variable.BoolToOnOff(config.GetGlobalConfig().Performance.ProjectionPushDown))
|
||||
store, clean := testkit.CreateMockStore(t)
|
||||
defer clean()
|
||||
tk := testkit.NewTestKit(t, store)
|
||||
tk.MustExec("use test")
|
||||
tk.MustExec("create table t1 (a varchar(100), b int)")
|
||||
tk.MustQuery("select @@tidb_opt_projection_push_down").Check(testkit.Rows("1"))
|
||||
tk.MustQuery("explain format = 'brief' select cast(a as datetime) from t1").Check(testkit.Rows(
|
||||
"TableReader 10000.00 root data:Projection",
|
||||
"└─Projection 10000.00 cop[tikv] cast(test.t1.a, datetime BINARY)->Column#4",
|
||||
" └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"))
|
||||
}
|
||||
|
||||
@ -140,11 +140,11 @@ var defaultSysVars = []*SysVar{
|
||||
}
|
||||
return nil
|
||||
}},
|
||||
{Scope: ScopeSession, Name: TiDBOptProjectionPushDown, Value: BoolToOnOff(config.GetGlobalConfig().Performance.ProjectionPushDown), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
|
||||
{Scope: ScopeSession, Name: TiDBOptProjectionPushDown, Value: BoolToOnOff(config.GetGlobalConfig().Performance.ProjectionPushDown), Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
|
||||
s.AllowProjectionPushDown = TiDBOptOn(val)
|
||||
return nil
|
||||
}},
|
||||
{Scope: ScopeSession, Name: TiDBOptAggPushDown, Value: BoolToOnOff(DefOptAggPushDown), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error {
|
||||
{Scope: ScopeSession, Name: TiDBOptAggPushDown, Value: BoolToOnOff(DefOptAggPushDown), Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
|
||||
s.AllowAggPushDown = TiDBOptOn(val)
|
||||
return nil
|
||||
}},
|
||||
|
||||
Reference in New Issue
Block a user