-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Tidb SET TIMESTAMP=3147483698 out of range is not compatible with mysql. #31585
Comments
This could be seen as a regression of #25686 although at the time, We used to have a feature to by default error for an out of range value, but then changed that to AutoConvert because it was observed MySQL seems to always do this. However, this looks like an exception where AutoConvert is not desired. MySQL is right here to return an error because a warning is dangerous. See this code: tidb/sessionctx/variable/sysvar.go Lines 118 to 124 in 79171be
We could change it to something like the following: {Scope: ScopeSession, Name: Timestamp, Value: DefTimestamp, skipInit: true, MinValue: 0, MaxValue: math.MaxUint64, Type: TypeFloat, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) {
val := tidbOptFloat64(val, DefTimestamp)
if val > math.MaxInt64 {
return originalValue, errors.New("out of range")
}
return normalizedValue, nil
}}, GetSession: func(s *SessionVars) (string, error) {
if timestamp, ok := s.systems[Timestamp]; ok && timestamp != DefTimestamp {
return timestamp, nil
}
timestamp := s.StmtCtx.GetOrStoreStmtCache(stmtctx.StmtNowTsCacheKey, time.Now()).(time.Time)
return types.ToString(float64(timestamp.UnixNano()) / float64(time.Second))
}}, (Not exactly like this, since the error returned should match the mysql one, and it will need tests etc.) |
The other option is to reintroduce |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: