Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: fail ColumnSubstituteImpl if creating function returns error (#53716) #53815

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading