Skip to content

Commit

Permalink
expression: fail ColumnSubstituteImpl if creating function returns …
Browse files Browse the repository at this point in the history
…error (#53716)

close #53580, close #53582, close #53594, close #53603
  • Loading branch information
YangKeao authored Jun 3, 2024
1 parent 073f746 commit 3d68bd2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/expression/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,11 @@ func ColumnSubstituteImpl(ctx BuildContext, expr Expression, schema *Schema, new
}
}
if substituted {
return true, hasFail, NewFunctionInternal(ctx, v.FuncName.L, v.RetType, refExprArr.Result()...)
newFunc, err := NewFunction(ctx, v.FuncName.L, v.RetType, refExprArr.Result()...)
if err != nil {
return true, true, v
}
return true, hasFail, newFunc
}
}
return false, false, expr
Expand Down
7 changes: 7 additions & 0 deletions tests/integrationtest/r/planner/core/integration.result
Original file line number Diff line number Diff line change
Expand Up @@ -4305,3 +4305,10 @@ id
2
drop table sys.t;
set tidb_isolation_read_engines=DEFAULT;
drop table if exists t;
create table t (col TEXT);
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;
1
Expand Down
8 changes: 8 additions & 0 deletions tests/integrationtest/t/planner/core/integration.test
Original file line number Diff line number Diff line change
Expand Up @@ -2369,3 +2369,11 @@ set tidb_isolation_read_engines='tiflash';
select * from sys.t;
drop table sys.t;
set tidb_isolation_read_engines=DEFAULT;

# TestIssue53580
drop table if exists t;
create table t (col TEXT);
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;

0 comments on commit 3d68bd2

Please sign in to comment.