jackc/pgx · error

%d is less than minimum value for Int4

Error message

%d is less than minimum value for Int4

What it means

Error "%d is less than minimum value for Int4" thrown in jackc/pgx.

Source

Thrown at pgtype/int.go:611

	n := int64(int16(raw))

	return s.ScanText(Text{String: strconv.FormatInt(n, 10), Valid: true})
}

type Int4 struct {
	Int32 int32
	Valid bool
}

// ScanInt64 implements the [Int64Scanner] interface.
func (dst *Int4) ScanInt64(n Int8) error {
	if !n.Valid {
		*dst = Int4{}
		return nil
	}

	if n.Int64 < math.MinInt32 {
		return fmt.Errorf("%d is less than minimum value for Int4", n.Int64)
	}
	if n.Int64 > math.MaxInt32 {
		return fmt.Errorf("%d is greater than maximum value for Int4", n.Int64)
	}
	*dst = Int4{Int32: int32(n.Int64), Valid: true}

	return nil
}

// Int64Value implements the [Int64Valuer] interface.
func (n Int4) Int64Value() (Int8, error) {
	return Int8{Int64: int64(n.Int32), Valid: n.Valid}, nil
}

// Scan implements the [database/sql.Scanner] interface.
func (dst *Int4) Scan(src any) error {
	if src == nil {
		*dst = Int4{}

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/int.go:611 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: /data/errors/b45e377efb3840bf.json. Report an issue: GitHub.