Skip to content

Commit c8dbdab

Browse files
authored
expression: fail ColumnSubstituteImpl if creating function returns error (#53716) (#54192)
close #53580, close #53582, close #53594, close #53603
1 parent df19951 commit c8dbdab

File tree

4 files changed

+17
-55
lines changed

4 files changed

+17
-55
lines changed

expression/integration_test/integration_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8087,3 +8087,15 @@ func TestCastAsStringExplicitCharSet(t *testing.T) {
80878087
tk.MustExec("insert into test values(1,'张三'), (2,'李四'), (3,'张三'), (4,'李四')")
80888088
tk.MustQuery("select id from test order by cast(update_user as char) desc , id limit 3").Check(testkit.Rows("2", "4", "1"))
80898089
}
8090+
8091+
func TestIssue53580(t *testing.T) {
8092+
store := testkit.CreateMockStore(t)
8093+
tk := testkit.NewTestKit(t, store)
8094+
8095+
tk.MustExec("use test")
8096+
tk.MustExec("create table t (col TEXT);")
8097+
tk.MustQuery(`select 1 from (select t.col as c0, 46578369 as c1 from t) as t where
8098+
case when (
8099+
t.c0 in (t.c0, cast((cast(1 as unsigned) - cast(t.c1 as signed)) as char))
8100+
) then 1 else 2 end;`).Check(testkit.Rows())
8101+
}

expression/util.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,11 @@ func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression
513513
}
514514
}
515515
if substituted {
516-
return true, hasFail, NewFunctionInternal(v.GetCtx(), v.FuncName.L, v.RetType, refExprArr.Result()...)
516+
newFunc, err := NewFunction(v.GetCtx(), v.FuncName.L, v.RetType, refExprArr.Result()...)
517+
if err != nil {
518+
return true, true, v
519+
}
520+
return true, hasFail, newFunc
517521
}
518522
}
519523
return false, false, expr

tests/integrationtest/r/ddl/db_rename.result

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

tests/integrationtest/t/ddl/db_rename.test

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

0 commit comments

Comments
 (0)