Skip to content

Commit

Permalink
expression, executor: forbid pushing trim2Args, trim3Args to tiflash (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
XuHuaiyu authored Dec 1, 2021
1 parent 6b14eb5 commit ae76eac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions executor/tiflash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,3 +959,20 @@ func (s *tiflashTestSuite) TestForbidTiflashDuringStaleRead(c *C) {
c.Assert(strings.Contains(res, "tiflash"), IsFalse)
c.Assert(strings.Contains(res, "tikv"), IsTrue)
}

func (s *tiflashTestSuite) TestIssue29154(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a char(20))")
tk.MustExec("alter table t set tiflash replica 1")
tb := testGetTableByName(c, tk.Se, "test", "t")
err := domain.GetDomain(tk.Se).DDL().UpdateTableReplicaInfo(tk.Se, tb.Meta().ID, true)
c.Assert(err, IsNil)
time.Sleep(2 * time.Second)
tk.MustExec("set session tidb_isolation_read_engines=\"tiflash\";")
tk.MustQuery("explain select * from t where trim('x' from a)")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 Scalar function 'trim'(signature: Trim2Args, return type: var_string(5)) can not be pushed to storage layer"))
tk.MustQuery("explain select * from t where trim(trailing 'x' from a)")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 Scalar function 'trim'(signature: Trim3Args, return type: var_string(20)) can not be pushed to storage layer"))
}
7 changes: 6 additions & 1 deletion expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,13 @@ func scalarExprSupportedByFlash(function *ScalarFunction) bool {
ast.Radians, ast.Degrees, ast.Conv, ast.CRC32,
ast.JSONLength,
ast.InetNtoa, ast.InetAton, ast.Inet6Ntoa, ast.Inet6Aton,
ast.Coalesce, ast.ASCII, ast.Length, ast.Trim, ast.Position:
ast.Coalesce, ast.ASCII, ast.Length, ast.Position:
return true
case ast.Trim:
switch function.Function.PbCode() {
case tipb.ScalarFuncSig_Trim1Arg:
return true
}
case ast.Substr, ast.Substring, ast.Left, ast.Right, ast.CharLength:
switch function.Function.PbCode() {
case
Expand Down

0 comments on commit ae76eac

Please sign in to comment.