table partition: add more warnings to inform the user that setting TiDB partition prune mode to dynamic at session level (#35046)
close pingcap/tidb#35042
This commit is contained in:
@ -1406,6 +1406,7 @@ var defaultSysVars = []*SysVar{
|
||||
newMode := strings.ToLower(strings.TrimSpace(val))
|
||||
if PartitionPruneMode(s.PartitionPruneMode.Load()) == Static && PartitionPruneMode(newMode) == Dynamic {
|
||||
s.StmtCtx.AppendWarning(errors.New("Please analyze all partition tables again for consistency between partition and global stats"))
|
||||
s.StmtCtx.AppendWarning(errors.New("Please avoid setting partition prune mode to dynamic at session level and set partition prune mode to dynamic at global level"))
|
||||
}
|
||||
s.PartitionPruneMode.Store(newMode)
|
||||
return nil
|
||||
|
||||
@ -729,3 +729,17 @@ func TestIssue31721(t *testing.T) {
|
||||
tk.MustExec("insert into t_31721 values ('1')")
|
||||
tk.MustExec("select * from t_31721 partition(p0, p1) where col1 != 2;")
|
||||
}
|
||||
|
||||
func TestPruneModeWarningInfo(t *testing.T) {
|
||||
store, _, clean := testkit.CreateMockStoreAndDomain(t)
|
||||
defer clean()
|
||||
|
||||
tk := testkit.NewTestKit(t, store)
|
||||
tk.MustExec("set @@tidb_partition_prune_mode = 'static'")
|
||||
tk.MustQuery("show warnings").Check(testkit.Rows())
|
||||
tk.MustExec("set session tidb_partition_prune_mode = 'dynamic'")
|
||||
tk.MustQuery("show warnings").Sort().Check(testkit.Rows("Warning 1105 Please analyze all partition tables again for consistency between partition and global stats",
|
||||
"Warning 1105 Please avoid setting partition prune mode to dynamic at session level and set partition prune mode to dynamic at global level"))
|
||||
tk.MustExec("set global tidb_partition_prune_mode = 'dynamic'")
|
||||
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 Please analyze all partition tables again for consistency between partition and global stats"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user