Skip to content

Commit

Permalink
Merge branch 'release-4.0' into release-4.0-db3c96b3ff83
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 authored Sep 28, 2020
2 parents d506d4f + d4c688f commit eb8307e
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions executor/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
14 changes: 14 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
10 changes: 7 additions & 3 deletions expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions expression/expression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion expression/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit eb8307e

Please sign in to comment.