vitessio/vitess · error
overflow
Error message
overflow
What it means
errOverflow is a sentinel error in go/mysql/decimal returned by parseDecimal64 when the digits being accumulated into a uint64 would exceed math.MaxUint64 — either n already reached the cutoff (n*10 would overflow) or adding the next digit wrapped (n1 < n). NewFromMySQL propagates it when decoding a MySQL wire-format decimal whose significant digits don't fit in 64 bits.
Source
Thrown at go/mysql/decimal/scan.go:31
See the License for the specific language governing permissions and
limitations under the License.
*/
package decimal
import (
"bytes"
"errors"
"fmt"
"math"
"math/big"
"math/bits"
"strings"
"vitess.io/vitess/go/mysql/fastparse"
)
var errOverflow = errors.New("overflow")
func parseDecimal64(s []byte) (Decimal, error) {
const cutoff = math.MaxUint64/10 + 1
var n uint64
dot := -1
for i, c := range s {
var d byte
switch {
case c == '.':
if dot > -1 {
return Decimal{}, errors.New("too many .s")
}
dot = i
continue
case '0' <= c && c <= '9':
d = c - '0'
default:View on GitHub (pinned to 01a25a7d17)
Solutions
- Reduce the value's magnitude/scale (e.g. divide, or store as exponent/scientific form) so it fits in uint64
- Use a smaller column scale/precision or a different type (e.g. store as string or big.Decimal) if values legitimately exceed 64 bits
- Handle the error in the caller by falling back to the slower big-number decimal path instead of the 64-bit fast path
Example fix
// before
dec, err := decimal.NewFromMySQL(raw) // errors for huge values
// after
dec, err := decimal.NewFromMySQL(raw)
if errors.Is(err, decimal.ErrOverflow /* errOverflow */) {
return handleBigValueWithBigFloat(raw)
} Defensive patterns
Strategy: type-guard
Validate before calling
// strip sign and split on '.', then check integer digits before calling NewFromMySQL:
if len(intPart) > 20 { return errors.New("value exceeds 64-bit decimal fast path") }
if len(intPart) == 20 && intPart > "18446744073709551615" { return errors.New("overflow") } Type guard
func fitsDecimal64(s string) bool {
digits := strings.SplitN(strings.Trim(s, "-+"), ".", 2)[0]
return len(digits) <= 19
} Try / catch
dec, err := decimal.NewFromMySQL(raw)
if err != nil && errors.Is(err, errOverflow) {
return parseWithBigFloat(raw) // fallback path
} Prevention
- Pre-check magnitude of DECIMAL/BIGINT UNSIGNED values exceeding uint64
- Avoid SUM/aggregations that overflow 64 bits before parsing
- Maintain a big-number fallback path for wide decimals
When it happens
Trigger: parseDecimal64 receiving a digit string whose integer part exceeds MaxUint64 (~1.8e19); NewFromMySQL decoding a DECIMAL column value with more significant digits than uint64 can hold (more than 20 digits, or 19-20 large values).
Common situations: DECIMAL(30,6) or BIGINT UNSIGNED columns holding very large values; aggregations (SUM) that overflow; importing data from systems with wider decimals than the 64-bit fast path supports.
Related errors
- unexpected character %q
- can't convert %q to decimal: too short
- can't convert %s to decimal: %v
- can't convert %s to decimal: too many .s
- too many .s
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/5873f2ac591a68b4.
Report an issue: GitHub.