@@ -1093,7 +1093,7 @@ func convertToInt64(t NumberTypeImpl_, v any, round Round) (int64, sql.ConvertIn
10931093 if v < float64 (math .MinInt64 ) {
10941094 return math .MinInt64 , sql .OutOfRange , nil
10951095 }
1096- if math . IsInf ( v , 0 ) || math . IsNaN (v ) {
1096+ if ! IsValidFloat (v ) {
10971097 return 0 , sql .OutOfRange , sql .ErrInvalidValue .New (v , t .String ())
10981098 }
10991099 return int64 (math .Round (v )), sql .InRange , nil
@@ -1294,7 +1294,7 @@ func convertToUint64(t NumberTypeImpl_, v any, round Round) (uint64, sql.Convert
12941294 if v < 0 {
12951295 return uint64 (math .MaxUint64 - uint (- v - 1 )), sql .OutOfRange , nil
12961296 }
1297- if math . IsInf ( v , 0 ) || math . IsNaN (v ) {
1297+ if ! IsValidFloat (v ) {
12981298 return 0 , sql .OutOfRange , sql .ErrInvalidValue .New (v , t .String ())
12991299 }
13001300 return uint64 (math .Round (v )), sql .InRange , nil
@@ -1395,8 +1395,8 @@ func convertToFloat64(t NumberTypeImpl_, v interface{}) (float64, error) {
13951395 case float32 :
13961396 return float64 (v ), nil
13971397 case float64 :
1398- if math . IsInf ( v , 0 ) || math . IsNaN (v ) {
1399- return 0 , sql .ErrInvalidValue .New (v , t .String ())
1398+ if ! IsValidFloat (v ) {
1399+ return v , sql .ErrInvalidValue .New (v , t .String ())
14001400 }
14011401 return v , nil
14021402 case decimal.Decimal :
@@ -1565,3 +1565,9 @@ func ConvertHexBlobToDecimalForNumericContext(val interface{}, originType sql.Ty
15651565 }
15661566 return val , nil
15671567}
1568+
1569+ // IsValidFloat returns false in go-mysql-server if a float is NaN or infinity. Since NaN and infinity values are
1570+ // allowed in Doltgres, this function is replaced there.
1571+ var IsValidFloat = func (f float64 ) bool {
1572+ return ! math .IsNaN (f ) && ! math .IsInf (f , 0 )
1573+ }
0 commit comments