diff --git a/expression/integration_test.go b/expression/integration_test.go index 50014a4acd910..5f96b0ac5c164 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -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()) +} diff --git a/expression/util.go b/expression/util.go index c41077c2cf06b..f9ea967b3cf93 100644 --- a/expression/util.go +++ b/expression/util.go @@ -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 diff --git a/tests/integrationtest/r/ddl/multi_schema_change.result b/tests/integrationtest/r/ddl/multi_schema_change.result deleted file mode 100644 index d7ffba91144a6..0000000000000 --- a/tests/integrationtest/r/ddl/multi_schema_change.result +++ /dev/null @@ -1,9 +0,0 @@ -drop table if exists t; -create table t (a int auto_increment primary key, b int) auto_id_cache = 100; -insert into t(b) values(1); -alter table t modify column b tinyint, auto_increment = 200; -insert into t (b) values (2); -select * from t; -a b -1 1 -200 2 diff --git a/tests/integrationtest/r/expression/cast.result b/tests/integrationtest/r/expression/cast.result deleted file mode 100644 index c7938cb727e72..0000000000000 --- a/tests/integrationtest/r/expression/cast.result +++ /dev/null @@ -1,30 +0,0 @@ -drop table if exists t0; -create table t0(c0 tinyint(1) unsigned not null ); -insert into t0 values (1); -select * from t0 where case 0 when t0.c0 > -1.194192591e9 then null else 1 end; -c0 -1 -select t0.c0 > -1.194192591e9 from t0; -t0.c0 > -1.194192591e9 -1 -select t0.c0 < -1.194192591e9 from t0; -t0.c0 < -1.194192591e9 -0 -select -1.194192591e9 > t0.c0 from t0; --1.194192591e9 > t0.c0 -0 -select -1.194192591e9 < t0.c0 from t0; --1.194192591e9 < t0.c0 -1 -select t0.c0 > 1.194192591e9 from t0; -t0.c0 > 1.194192591e9 -0 -select t0.c0 < 1.194192591e9 from t0; -t0.c0 < 1.194192591e9 -1 -select 1.194192591e9 > t0.c0 from t0; -1.194192591e9 > t0.c0 -1 -select 1.194192591e9 < t0.c0 from t0; -1.194192591e9 < t0.c0 -0 diff --git a/tests/integrationtest/t/ddl/multi_schema_change.test b/tests/integrationtest/t/ddl/multi_schema_change.test deleted file mode 100644 index ce96326cb92cd..0000000000000 --- a/tests/integrationtest/t/ddl/multi_schema_change.test +++ /dev/null @@ -1,7 +0,0 @@ -# TestMultiSchemaChangeTableOption -drop table if exists t; -create table t (a int auto_increment primary key, b int) auto_id_cache = 100; -insert into t(b) values(1); -alter table t modify column b tinyint, auto_increment = 200; -insert into t (b) values (2); -select * from t; diff --git a/tests/integrationtest/t/expression/cast.test b/tests/integrationtest/t/expression/cast.test deleted file mode 100644 index 6876072d60365..0000000000000 --- a/tests/integrationtest/t/expression/cast.test +++ /dev/null @@ -1,13 +0,0 @@ -# TestNegFloatConvertToUnsigned -drop table if exists t0; -create table t0(c0 tinyint(1) unsigned not null ); -insert into t0 values (1); -select * from t0 where case 0 when t0.c0 > -1.194192591e9 then null else 1 end; -select t0.c0 > -1.194192591e9 from t0; -select t0.c0 < -1.194192591e9 from t0; -select -1.194192591e9 > t0.c0 from t0; -select -1.194192591e9 < t0.c0 from t0; -select t0.c0 > 1.194192591e9 from t0; -select t0.c0 < 1.194192591e9 from t0; -select 1.194192591e9 > t0.c0 from t0; -select 1.194192591e9 < t0.c0 from t0;