jackc/pgx · error
is greater than maximum value for Int8
Error message
%d is greater than maximum value for Int8
What it means
ScanInt64 on *Int8 received a valid Int8 value exceeding math.MaxInt64 — in practice unreachable since both are int64; it fires only if an Int64Valuer produced an out-of-range value (e.g. via uint64 conversion elsewhere). The oversized source value is the faulting input.
Solutions
- Treat as a bug: check how the Int8 value was constructed
- Avoid manually crafting Int8 values with out-of-range contents
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/int.go:1200 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/8e252a97523e31da.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/int.go:1200
}
type Int8 struct {
Int64 int64
Valid bool
}
// ScanInt64 implements the [Int64Scanner] interface.
func (dst *Int8) ScanInt64(n Int8) error {
if !n.Valid {
*dst = Int8{}
return nil
}
if n.Int64 < math.MinInt64 {
return fmt.Errorf("%d is less than minimum value for Int8", n.Int64)
}
if n.Int64 > math.MaxInt64 {
return fmt.Errorf("%d is greater than maximum value for Int8", n.Int64)
}
*dst = Int8{Int64: int64(n.Int64), Valid: true}
return nil
}
// Int64Value implements the [Int64Valuer] interface.
func (n Int8) Int64Value() (Int8, error) {
return Int8{Int64: int64(n.Int64), Valid: n.Valid}, nil
}
// Scan implements the [database/sql.Scanner] interface.
func (dst *Int8) Scan(src any) error {
if src == nil {
*dst = Int8{}
return nil
}
View on GitHub (pinned to ec1a0befd2)