diff --git a/config/config.go b/config/config.go index e2332d5089109..9392eb797b95b 100644 --- a/config/config.go +++ b/config/config.go @@ -614,7 +614,7 @@ var defaultConf = Config{ StatsLease: "3s", RunAutoAnalyze: true, StmtCountLimit: 5000, - FeedbackProbability: 0.05, + FeedbackProbability: 0.0, QueryFeedbackLimit: 512, PseudoEstimateRatio: 0.8, ForcePriority: "NO_PRIORITY", diff --git a/config/config.toml.example b/config/config.toml.example index ff46dbccbfda5..9c527909c6dde 100644 --- a/config/config.toml.example +++ b/config/config.toml.example @@ -226,7 +226,7 @@ stats-lease = "3s" run-auto-analyze = true # Probability to use the query feedback to update stats, 0.0 or 1.0 for always false/true. -feedback-probability = 0.05 +feedback-probability = 0.0 # The max number of query feedback that cache in memory. query-feedback-limit = 512 diff --git a/config/config_test.go b/config/config_test.go index e9384ae2e5c69..0302fa9659994 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -148,7 +148,8 @@ disable-error-stack = false } func (s *testConfigSuite) TestConfig(c *C) { - conf := new(Config) + conf := NewConfig() + c.Assert(conf.Performance.FeedbackProbability, Equals, 0.0) conf.TempStoragePath = tempStorageDirName conf.Binlog.Enable = true conf.Binlog.IgnoreError = true diff --git a/executor/aggregate.go b/executor/aggregate.go index 58fd9b9cb613a..e1311636c0326 100644 --- a/executor/aggregate.go +++ b/executor/aggregate.go @@ -452,7 +452,7 @@ func getGroupKey(ctx sessionctx.Context, input *chunk.Chunk, groupKey [][]byte, return nil, err } - if err := expression.EvalExpr(ctx, item, input, buf); err != nil { + if err := expression.EvalExpr(ctx, item, tp.EvalType(), input, buf); err != nil { expression.PutColumn(buf) return nil, err } @@ -1110,7 +1110,7 @@ func (e *vecGroupChecker) evalGroupItemsAndResolveGroups(item expression.Express return err } defer e.releaseBuffer(col) - err = expression.EvalExpr(e.ctx, item, chk, col) + err = expression.EvalExpr(e.ctx, item, eType, chk, col) if err != nil { return err } diff --git a/executor/executor_test.go b/executor/executor_test.go index cf83ebd453ca1..035d7631bfa31 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -3167,6 +3167,12 @@ func (s *testSuite) TestBit(c *C) { tk.MustExec("insert into t values ('12345678')") _, err = tk.Exec("insert into t values ('123456789')") c.Assert(err, NotNil) + + tk.MustExec("drop table if exists t") + tk.MustExec("create table t (c1 bit(64))") + tk.MustExec("insert into t values (0xffffffffffffffff)") + tk.MustExec("insert into t values ('12345678')") + tk.MustQuery("select * from t where c1").Check(testkit.Rows("\xff\xff\xff\xff\xff\xff\xff\xff", "12345678")) } func (s *testSuite) TestEnum(c *C) { @@ -3183,6 +3189,10 @@ func (s *testSuite) TestEnum(c *C) { tk.MustExec("insert into t values ()") tk.MustExec("insert into t values (null), ('1')") tk.MustQuery("select c + 1 from t where c = 1").Check(testkit.Rows("2")) + + tk.MustExec("delete from t") + tk.MustExec("insert into t values(1), (2), (3)") + tk.MustQuery("select * from t where c").Check(testkit.Rows("a", "b", "c")) } func (s *testSuite) TestSet(c *C) { @@ -3201,6 +3211,10 @@ func (s *testSuite) TestSet(c *C) { tk.MustExec("insert into t values ()") tk.MustExec("insert into t values (null), ('1')") tk.MustQuery("select c + 1 from t where c = 1").Check(testkit.Rows("2")) + + tk.MustExec("delete from t") + tk.MustExec("insert into t values(3)") + tk.MustQuery("select * from t where c").Check(testkit.Rows("a,b")) } func (s *testSuite) TestSubqueryInValues(c *C) { diff --git a/expression/expression.go b/expression/expression.go index 36be2a14475fc..7062e6fedf5d3 100644 --- a/expression/expression.go +++ b/expression/expression.go @@ -322,12 +322,15 @@ func VecEvalBool(ctx sessionctx.Context, exprList CNFExprs, input *chunk.Chunk, defer deallocateZeroSlice(isZero) for _, expr := range exprList { eType := expr.GetType().EvalType() + if expr.GetType().Hybrid() { + eType = types.ETInt + } buf, err := globalColumnAllocator.get(eType, n) if err != nil { return nil, nil, err } - if err := EvalExpr(ctx, expr, input, buf); err != nil { + if err := EvalExpr(ctx, expr, eType, input, buf); err != nil { return nil, nil, err } @@ -463,8 +466,9 @@ func toBool(sc *stmtctx.StatementContext, eType types.EvalType, buf *chunk.Colum // EvalExpr evaluates this expr according to its type. // And it selects the method for evaluating expression based on // the environment variables and whether the expression can be vectorized. -func EvalExpr(ctx sessionctx.Context, expr Expression, input *chunk.Chunk, result *chunk.Column) (err error) { - evalType := expr.GetType().EvalType() +// Note: the input argument `evalType` is needed because of that when `expr` is +// of the hybrid type(ENUM/SET/BIT), we need the invoker decide the actual EvalType. +func EvalExpr(ctx sessionctx.Context, expr Expression, evalType types.EvalType, input *chunk.Chunk, result *chunk.Column) (err error) { if expr.Vectorized() && ctx.GetSessionVars().EnableVectorizedExpression { switch evalType { case types.ETInt: diff --git a/expression/expression_test.go b/expression/expression_test.go index b6b88506fabc5..2ecdc12f465eb 100644 --- a/expression/expression_test.go +++ b/expression/expression_test.go @@ -203,12 +203,12 @@ func (s *testEvaluatorSuite) TestEvalExpr(c *C) { var err error c.Assert(colExpr.Vectorized(), IsTrue) ctx.GetSessionVars().EnableVectorizedExpression = false - err = EvalExpr(ctx, colExpr, input, colBuf) + err = EvalExpr(ctx, colExpr, colExpr.GetType().EvalType(), input, colBuf) if err != nil { c.Fatal(err) } ctx.GetSessionVars().EnableVectorizedExpression = true - err = EvalExpr(ctx, colExpr, input, colBuf2) + err = EvalExpr(ctx, colExpr, colExpr.GetType().EvalType(), input, colBuf2) if err != nil { c.Fatal(err) } diff --git a/expression/util_test.go b/expression/util_test.go index 0b3c4242e9fc6..b86968c9675db 100644 --- a/expression/util_test.go +++ b/expression/util_test.go @@ -371,7 +371,7 @@ func (s *testUtilSuite) TestHashGroupKey(c *check.C) { bufs[j] = bufs[j][:0] } var err error - err = EvalExpr(ctx, colExpr, input, colBuf) + err = EvalExpr(ctx, colExpr, colExpr.GetType().EvalType(), input, colBuf) if err != nil { c.Fatal(err) }