jackc/pgx · error

%d is less than minimum value for int2

Error message

%d is less than minimum value for int2

What it means

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

Source

Thrown at pgtype/int.go:184

}

type encodePlanInt2CodecBinaryInt64Valuer struct{}

func (encodePlanInt2CodecBinaryInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
	n, err := value.(Int64Valuer).Int64Value()
	if err != nil {
		return nil, err
	}

	if !n.Valid {
		return nil, nil
	}

	if n.Int64 > math.MaxInt16 {
		return nil, fmt.Errorf("%d is greater than maximum value for int2", n.Int64)
	}
	if n.Int64 < math.MinInt16 {
		return nil, fmt.Errorf("%d is less than minimum value for int2", n.Int64)
	}

	return pgio.AppendInt16(buf, int16(n.Int64)), nil
}

type encodePlanInt2CodecTextInt64Valuer struct{}

func (encodePlanInt2CodecTextInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
	n, err := value.(Int64Valuer).Int64Value()
	if err != nil {
		return nil, err
	}

	if !n.Valid {
		return nil, nil
	}

	if n.Int64 > math.MaxInt16 {

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/int.go:184 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/387da69c012a0d75.json. Report an issue: GitHub.