-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
update, expression: fix update float panic #8045
Conversation
f0d3b75
to
d870cdc
Compare
/run-all-tests |
@crazycs520 I think we should modify the datum before |
@zz-jason the |
@crazycs520 Yes, we can convert it back to float32. |
@zz-jason done. PTAL, insert/replace already have a cast before |
executor/update.go
Outdated
@@ -194,6 +194,12 @@ func (e *UpdateExec) composeNewRow(rowIdx int, oldRow []types.Datum) ([]types.Da | |||
if err1 := e.handleErr(assign.Col.ColName, rowIdx, err); err1 != nil { | |||
return nil, err1 | |||
} | |||
|
|||
val, err = val.ConvertTo(e.ctx.GetSessionVars().StmtCtx, fields[assign.Col.Index]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use
Line 149 in a84cce1
func CastValue(ctx sessionctx.Context, val types.Datum, col *model.ColumnInfo) (casted types.Datum, err error) { |
here.
/run-all-tests |
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@jackysp PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
@crazycs520 Should we cherrypick this PR to the release-2.1 and release-2.0 branch? |
@zz-jason No, there is no |
This pr could cherry-pick to 2.1 now. @crazycs520 |
What problem does this PR solve?
sql:
What is changed and how it works?
Root cause:
UpdateExec.evalBuffer
init with typefloat32
, butscalar_function
eval
returnfloat64
whenFoldConstant
, thenevalBuffer.SetDatum
will panic.Fix this : add a cast when type is Float.
Check List
Tests
Code changes
Side effects
Related changes