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) (#54191)

close #53580, close #53582, close #53594, close #53603
  • Loading branch information
ti-chi-bot authored Jul 1, 2024
1 parent 9c3a66e commit c31e07c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
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(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
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 @@ -3952,3 +3952,10 @@ p o v a
3 5 5 3
3 9 9 9
set @@tidb_enable_pipelined_window_function=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: 7 additions & 1 deletion tests/integrationtest/t/planner/core/integration.test
Original file line number Diff line number Diff line change
Expand Up @@ -2071,4 +2071,10 @@ set @@tidb_enable_pipelined_window_function=0;
select *, first_value(v) over (partition by p order by o range between 3.1 preceding and 2.9 following) as a from planner__core__integration.first_range;
set @@tidb_enable_pipelined_window_function=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 c31e07c

Please sign in to comment.