Skip to content

Commit 3d68bd2

Browse files
authored
expression: fail ColumnSubstituteImpl if creating function returns error (#53716)
close #53580, close #53582, close #53594, close #53603
1 parent 073f746 commit 3d68bd2

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

pkg/expression/util.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,11 @@ func ColumnSubstituteImpl(ctx BuildContext, expr Expression, schema *Schema, new
519519
}
520520
}
521521
if substituted {
522-
return true, hasFail, NewFunctionInternal(ctx, v.FuncName.L, v.RetType, refExprArr.Result()...)
522+
newFunc, err := NewFunction(ctx, v.FuncName.L, v.RetType, refExprArr.Result()...)
523+
if err != nil {
524+
return true, true, v
525+
}
526+
return true, hasFail, newFunc
523527
}
524528
}
525529
return false, false, expr

tests/integrationtest/r/planner/core/integration.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4305,3 +4305,10 @@ id
43054305
2
43064306
drop table sys.t;
43074307
set tidb_isolation_read_engines=DEFAULT;
4308+
drop table if exists t;
4309+
create table t (col TEXT);
4310+
select 1 from (select t.col as c0, 46578369 as c1 from t) as t where
4311+
case when (
4312+
t.c0 in (t.c0, cast((cast(1 as unsigned) - cast(t.c1 as signed)) as char))
4313+
) then 1 else 2 end;
4314+
1

tests/integrationtest/t/planner/core/integration.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,3 +2369,11 @@ set tidb_isolation_read_engines='tiflash';
23692369
select * from sys.t;
23702370
drop table sys.t;
23712371
set tidb_isolation_read_engines=DEFAULT;
2372+
2373+
# TestIssue53580
2374+
drop table if exists t;
2375+
create table t (col TEXT);
2376+
select 1 from (select t.col as c0, 46578369 as c1 from t) as t where
2377+
case when (
2378+
t.c0 in (t.c0, cast((cast(1 as unsigned) - cast(t.c1 as signed)) as char))
2379+
) then 1 else 2 end;

0 commit comments

Comments
 (0)