jackc/pgx · error

is less than minimum value for int32

Error message

%d is less than minimum value for int32

What it means

Range guard converting an int64 into Go int32: the value is below math.MinInt32 and would overflow, so it is rejected.

Solutions

  1. Scan into int64 or pgtype.Int8
  2. Widen the column type or constrain values in SQL
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgtype/builtin_wrappers.go:72 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/a8e301c436433967. Report an issue: GitHub.

Appendix: source

Thrown at pgtype/builtin_wrappers.go:72

	return nil
}

func (w int16Wrapper) Int64Value() (Int8, error) {
	return Int8{Int64: int64(w), Valid: true}, nil
}

type int32Wrapper int32

func (w int32Wrapper) SkipUnderlyingTypePlan() {}

func (w *int32Wrapper) ScanInt64(v Int8) error {
	if !v.Valid {
		return fmt.Errorf("cannot scan NULL into *int32")
	}

	if v.Int64 < math.MinInt32 {
		return fmt.Errorf("%d is less than minimum value for int32", v.Int64)
	}
	if v.Int64 > math.MaxInt32 {
		return fmt.Errorf("%d is greater than maximum value for int32", v.Int64)
	}
	*w = int32Wrapper(v.Int64)

	return nil
}

func (w int32Wrapper) Int64Value() (Int8, error) {
	return Int8{Int64: int64(w), Valid: true}, nil
}

type int64Wrapper int64

func (w int64Wrapper) SkipUnderlyingTypePlan() {}

func (w *int64Wrapper) ScanInt64(v Int8) error {

View on GitHub (pinned to ec1a0befd2)