Skip to content

Commit

Permalink
planner: rename 'tidb_enable_general_plan_cache' and 'tidb_general_pl…
Browse files Browse the repository at this point in the history
…an_cache_size' to 'tidb_enable_non_prepared_plan_cache' and 'tidb_non_prepared_plan_cache_size'
  • Loading branch information
qw4990 authored Dec 13, 2022
1 parent aeceb22 commit 1ab88f2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
48 changes: 24 additions & 24 deletions executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,35 +766,35 @@ func TestSetVar(t *testing.T) {
tk.MustGetErrCode("set global init_connect = 'invalidstring'", mysql.ErrWrongTypeForVar)
tk.MustExec("set global init_connect = 'select now(); select timestamp()'")

// test variable 'tidb_enable_general_plan_cache'
// test variable 'tidb_enable_non_prepared_plan_cache'
// global scope
tk.MustQuery("select @@global.tidb_enable_general_plan_cache").Check(testkit.Rows("0")) // default value
tk.MustExec("set global tidb_enable_general_plan_cache = 1")
tk.MustQuery("select @@global.tidb_enable_general_plan_cache").Check(testkit.Rows("1"))
tk.MustExec("set global tidb_enable_general_plan_cache = 0")
tk.MustQuery("select @@global.tidb_enable_general_plan_cache").Check(testkit.Rows("0"))
tk.MustQuery("select @@global.tidb_enable_non_prepared_plan_cache").Check(testkit.Rows("0")) // default value
tk.MustExec("set global tidb_enable_non_prepared_plan_cache = 1")
tk.MustQuery("select @@global.tidb_enable_non_prepared_plan_cache").Check(testkit.Rows("1"))
tk.MustExec("set global tidb_enable_non_prepared_plan_cache = 0")
tk.MustQuery("select @@global.tidb_enable_non_prepared_plan_cache").Check(testkit.Rows("0"))
// session scope
tk.MustQuery("select @@session.tidb_enable_general_plan_cache").Check(testkit.Rows("0")) // default value
tk.MustExec("set session tidb_enable_general_plan_cache = 1")
tk.MustQuery("select @@session.tidb_enable_general_plan_cache").Check(testkit.Rows("1"))
tk.MustExec("set session tidb_enable_general_plan_cache = 0")
tk.MustQuery("select @@session.tidb_enable_general_plan_cache").Check(testkit.Rows("0"))
tk.MustQuery("select @@session.tidb_enable_non_prepared_plan_cache").Check(testkit.Rows("0")) // default value
tk.MustExec("set session tidb_enable_non_prepared_plan_cache = 1")
tk.MustQuery("select @@session.tidb_enable_non_prepared_plan_cache").Check(testkit.Rows("1"))
tk.MustExec("set session tidb_enable_non_prepared_plan_cache = 0")
tk.MustQuery("select @@session.tidb_enable_non_prepared_plan_cache").Check(testkit.Rows("0"))

// test variable 'tidb_general_plan_cache-size'
// test variable 'tidb_non_prepared_plan_cache-size'
// global scope
tk.MustQuery("select @@global.tidb_general_plan_cache_size").Check(testkit.Rows("100")) // default value
tk.MustExec("set global tidb_general_plan_cache_size = 200")
tk.MustQuery("select @@global.tidb_general_plan_cache_size").Check(testkit.Rows("200"))
tk.MustExec("set global tidb_general_plan_cache_size = 200000000") // overflow
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1292 Truncated incorrect tidb_general_plan_cache_size value: '200000000'"))
tk.MustQuery("select @@global.tidb_general_plan_cache_size").Check(testkit.Rows("100000"))
tk.MustQuery("select @@global.tidb_non_prepared_plan_cache_size").Check(testkit.Rows("100")) // default value
tk.MustExec("set global tidb_non_prepared_plan_cache_size = 200")
tk.MustQuery("select @@global.tidb_non_prepared_plan_cache_size").Check(testkit.Rows("200"))
tk.MustExec("set global tidb_non_prepared_plan_cache_size = 200000000") // overflow
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1292 Truncated incorrect tidb_non_prepared_plan_cache_size value: '200000000'"))
tk.MustQuery("select @@global.tidb_non_prepared_plan_cache_size").Check(testkit.Rows("100000"))
// session scope
tk.MustQuery("select @@session.tidb_general_plan_cache_size").Check(testkit.Rows("100")) // default value
tk.MustExec("set session tidb_general_plan_cache_size = 300")
tk.MustQuery("select @@session.tidb_general_plan_cache_size").Check(testkit.Rows("300"))
tk.MustExec("set session tidb_general_plan_cache_size = -1") // underflow
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1292 Truncated incorrect tidb_general_plan_cache_size value: '-1'"))
tk.MustQuery("select @@session.tidb_general_plan_cache_size").Check(testkit.Rows("1"))
tk.MustQuery("select @@session.tidb_non_prepared_plan_cache_size").Check(testkit.Rows("100")) // default value
tk.MustExec("set session tidb_non_prepared_plan_cache_size = 300")
tk.MustQuery("select @@session.tidb_non_prepared_plan_cache_size").Check(testkit.Rows("300"))
tk.MustExec("set session tidb_non_prepared_plan_cache_size = -1") // underflow
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1292 Truncated incorrect tidb_non_prepared_plan_cache_size value: '-1'"))
tk.MustQuery("select @@session.tidb_non_prepared_plan_cache_size").Check(testkit.Rows("1"))

// test variable 'foreign_key_checks'
// global scope
Expand Down
4 changes: 2 additions & 2 deletions planner/core/plan_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ func TestNonPreparedPlanCacheBasically(t *testing.T) {
}

for _, query := range queries {
tk.MustExec(`set tidb_enable_general_plan_cache=0`)
tk.MustExec(`set tidb_enable_non_prepared_plan_cache=0`)
resultNormal := tk.MustQuery(query).Sort()
tk.MustQuery(`select @@last_plan_from_cache`).Check(testkit.Rows("0"))

tk.MustExec(`set tidb_enable_general_plan_cache=1`)
tk.MustExec(`set tidb_enable_non_prepared_plan_cache=1`)
tk.MustQuery(query) // first process
tk.MustQuery(query).Sort().Check(resultNormal.Rows()) // equal to the result without plan-cache
tk.MustQuery(`select @@last_plan_from_cache`).Check(testkit.Rows("1")) // this plan is from plan-cache
Expand Down
4 changes: 2 additions & 2 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -1062,11 +1062,11 @@ var defaultSysVars = []*SysVar{
}, GetGlobal: func(_ context.Context, s *SessionVars) (string, error) {
return strconv.FormatFloat(PreparedPlanCacheMemoryGuardRatio.Load(), 'f', -1, 64), nil
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableGeneralPlanCache, Value: BoolToOnOff(DefTiDBEnableGeneralPlanCache), Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
{Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableNonPreparedPlanCache, Value: BoolToOnOff(DefTiDBEnableNonPreparedPlanCache), Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
s.EnableNonPreparedPlanCache = TiDBOptOn(val)
return nil
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBGeneralPlanCacheSize, Value: strconv.FormatUint(uint64(DefTiDBGeneralPlanCacheSize), 10), Type: TypeUnsigned, MinValue: 1, MaxValue: 100000, SetSession: func(s *SessionVars, val string) error {
{Scope: ScopeGlobal | ScopeSession, Name: TiDBNonPreparedPlanCacheSize, Value: strconv.FormatUint(uint64(DefTiDBNonPreparedPlanCacheSize), 10), Type: TypeUnsigned, MinValue: 1, MaxValue: 100000, SetSession: func(s *SessionVars, val string) error {
uVal, err := strconv.ParseUint(val, 10, 64)
if err == nil {
s.NonPreparedPlanCacheSize = uVal
Expand Down
12 changes: 6 additions & 6 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,10 @@ const (
// TiDBEnablePrepPlanCacheMemoryMonitor indicates whether to enable prepared plan cache monitor
TiDBEnablePrepPlanCacheMemoryMonitor = "tidb_enable_prepared_plan_cache_memory_monitor"

// TiDBEnableGeneralPlanCache indicates whether to enable general plan cache.
TiDBEnableGeneralPlanCache = "tidb_enable_general_plan_cache"
// TiDBGeneralPlanCacheSize controls the size of general plan cache.
TiDBGeneralPlanCacheSize = "tidb_general_plan_cache_size"
// TiDBEnableNonPreparedPlanCache indicates whether to enable non-prepared plan cache.
TiDBEnableNonPreparedPlanCache = "tidb_enable_non_prepared_plan_cache"
// TiDBNonPreparedPlanCacheSize controls the size of non-prepared plan cache.
TiDBNonPreparedPlanCacheSize = "tidb_non_prepared_plan_cache_size"

// TiDBConstraintCheckInPlacePessimistic controls whether to skip certain kinds of pessimistic locks.
TiDBConstraintCheckInPlacePessimistic = "tidb_constraint_check_in_place_pessimistic"
Expand Down Expand Up @@ -1114,8 +1114,8 @@ const (
DefTiDBEnableFastReorg = true
DefTiDBDDLDiskQuota = 100 * 1024 * 1024 * 1024 // 100GB
DefExecutorConcurrency = 5
DefTiDBEnableGeneralPlanCache = false
DefTiDBGeneralPlanCacheSize = 100
DefTiDBEnableNonPreparedPlanCache = false
DefTiDBNonPreparedPlanCacheSize = 100
DefTiDBEnableTiFlashReadForWriteStmt = false
// MaxDDLReorgBatchSize is exported for testing.
MaxDDLReorgBatchSize int32 = 10240
Expand Down

0 comments on commit 1ab88f2

Please sign in to comment.