Skip to content

Commit 4a4b42e

Browse files
authored
expression: fail ColumnSubstituteImpl if creating function returns error (#53716) (#53815)
close #53580, close #53582, close #53594, close #53603
1 parent ed5986b commit 4a4b42e

File tree

6 files changed

+19
-60
lines changed

6 files changed

+19
-60
lines changed

expression/integration_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8064,3 +8064,17 @@ func TestCastBinaryStringToJSON(t *testing.T) {
80648064
tk.MustQuery("select 1 from t where cast(BINARY vc as json) = '1';").Check(testkit.Rows())
80658065
tk.MustQuery("select 1 from t where cast(BINARY c as json) = '1';").Check(testkit.Rows())
80668066
}
8067+
8068+
func TestTestIssue53580(t *testing.T) {
8069+
store := testkit.CreateMockStore(t)
8070+
tk := testkit.NewTestKit(t, store)
8071+
8072+
tk.MustExec("use test")
8073+
tk.MustExec("create table t (col TEXT);")
8074+
tk.MustQuery(`
8075+
select 1 from (select t.col as c0, 46578369 as c1 from t) as t where
8076+
case when (
8077+
t.c0 in (t.c0, cast((cast(1 as unsigned) - cast(t.c1 as signed)) as char))
8078+
) then 1 else 2 end;
8079+
`).Check(testkit.Rows())
8080+
}

expression/util.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,11 @@ func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression
487487
}
488488
}
489489
if substituted {
490-
return true, hasFail, NewFunctionInternal(v.GetCtx(), v.FuncName.L, v.RetType, refExprArr.Result()...)
490+
newFunc, err := NewFunction(v.GetCtx(), v.FuncName.L, v.RetType, refExprArr.Result()...)
491+
if err != nil {
492+
return true, true, v
493+
}
494+
return true, hasFail, newFunc
491495
}
492496
}
493497
return false, false, expr

tests/integrationtest/r/ddl/multi_schema_change.result

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/integrationtest/r/expression/cast.result

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/integrationtest/t/ddl/multi_schema_change.test

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/integrationtest/t/expression/cast.test

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)