jackc/pgx · error

empty range: %w

Error message

empty range: %w

What it means

Error "empty range: %w" thrown in jackc/pgx.

Source

Thrown at pgtype/range.go:214

	emptyMask          = 1
	lowerInclusiveMask = 2
	upperInclusiveMask = 4
	lowerUnboundedMask = 8
	upperUnboundedMask = 16
)

func parseUntypedBinaryRange(src []byte) (*untypedBinaryRange, error) {
	ubr := &untypedBinaryRange{}
	r := pgio.NewReader(src)

	rangeType := r.Byte()
	if r.Err() != nil {
		return nil, fmt.Errorf("range too short: %v", len(src))
	}

	if rangeType&emptyMask > 0 {
		if err := r.Finish(); err != nil {
			return nil, fmt.Errorf("empty range: %w", err)
		}
		ubr.LowerType = Empty
		ubr.UpperType = Empty
		return ubr, nil
	}

	switch {
	case rangeType&lowerInclusiveMask > 0:
		ubr.LowerType = Inclusive
	case rangeType&lowerUnboundedMask > 0:
		ubr.LowerType = Unbounded
	default:
		ubr.LowerType = Exclusive
	}

	switch {
	case rangeType&upperInclusiveMask > 0:
		ubr.UpperType = Inclusive

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/range.go:214 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/082a47c5960950e4.json. Report an issue: GitHub.