Skip to content

Commit

Permalink
expression: fail ColumnSubstituteImpl if creating function returns …
Browse files Browse the repository at this point in the history
…error (#53716) (#53815)

close #53580, close #53582, close #53594, close #53603
  • Loading branch information
ti-chi-bot authored Jun 6, 2024
1 parent ed5986b commit 4a4b42e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 60 deletions.
14 changes: 14 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8064,3 +8064,17 @@ func TestCastBinaryStringToJSON(t *testing.T) {
tk.MustQuery("select 1 from t where cast(BINARY vc as json) = '1';").Check(testkit.Rows())
tk.MustQuery("select 1 from t where cast(BINARY c as json) = '1';").Check(testkit.Rows())
}

func TestTestIssue53580(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("create table t (col TEXT);")
tk.MustQuery(`
select 1 from (select t.col as c0, 46578369 as c1 from t) as t where
case when (
t.c0 in (t.c0, cast((cast(1 as unsigned) - cast(t.c1 as signed)) as char))
) then 1 else 2 end;
`).Check(testkit.Rows())
}
6 changes: 5 additions & 1 deletion expression/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,11 @@ func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression
}
}
if substituted {
return true, hasFail, NewFunctionInternal(v.GetCtx(), v.FuncName.L, v.RetType, refExprArr.Result()...)
newFunc, err := NewFunction(v.GetCtx(), v.FuncName.L, v.RetType, refExprArr.Result()...)
if err != nil {
return true, true, v
}
return true, hasFail, newFunc
}
}
return false, false, expr
Expand Down
9 changes: 0 additions & 9 deletions tests/integrationtest/r/ddl/multi_schema_change.result

This file was deleted.

30 changes: 0 additions & 30 deletions tests/integrationtest/r/expression/cast.result

This file was deleted.

7 changes: 0 additions & 7 deletions tests/integrationtest/t/ddl/multi_schema_change.test

This file was deleted.

13 changes: 0 additions & 13 deletions tests/integrationtest/t/expression/cast.test

This file was deleted.

0 comments on commit 4a4b42e

Please sign in to comment.