Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: fail ColumnSubstituteImpl if creating function returns error (#53716) #54193

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;