jackc/pgx · error
is greater than maximum value for int
Error message
%d is greater than maximum value for int
What it means
Range guard converting an int64 into Go int: the value exceeds the platform's math.MaxInt and would overflow, so the conversion is refused.
Solutions
- Scan into int64 or pgtype.Int8 (especially on 32-bit platforms)
- Constrain or cast the data to the platform int range
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/builtin_wrappers.go:117 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04).
Data as JSON: /api/errors/c7e88bdbfb1d6290.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/builtin_wrappers.go:117
func (w int64Wrapper) Int64Value() (Int8, error) {
return Int8{Int64: int64(w), Valid: true}, nil
}
type intWrapper int
func (w intWrapper) SkipUnderlyingTypePlan() {}
func (w *intWrapper) ScanInt64(v Int8) error {
if !v.Valid {
return fmt.Errorf("cannot scan NULL into *int")
}
if v.Int64 < math.MinInt {
return fmt.Errorf("%d is less than minimum value for int", v.Int64)
}
if v.Int64 > math.MaxInt {
return fmt.Errorf("%d is greater than maximum value for int", v.Int64)
}
*w = intWrapper(v.Int64)
return nil
}
func (w intWrapper) Int64Value() (Int8, error) {
return Int8{Int64: int64(w), Valid: true}, nil
}
type uint8Wrapper uint8
func (w uint8Wrapper) SkipUnderlyingTypePlan() {}
func (w *uint8Wrapper) ScanInt64(v Int8) error {
if !v.Valid {
return fmt.Errorf("cannot scan NULL into *uint8")View on GitHub (pinned to ec1a0befd2)