jackc/pgx · error

uint64

Error message

uint64: %w

What it means

scanPlanBinaryUint64ToUint64 wraps pgio.Uint64Exact: the binary uint64 payload was not exactly 8 bytes, so it cannot be decoded. The wrapped error details the size mismatch.

Solutions

  1. Fail the scan; the binary payload is malformed
  2. Check for truncation/corruption or a custom encoder emitting the wrong width
  3. Verify the column/domain really is uint64
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgtype/uint64.go:255 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/c6cb0a433f1e2a9f. Report an issue: GitHub.

Appendix: source

Thrown at pgtype/uint64.go:255

	var n uint64
	err := codecScan(c, m, oid, format, src, &n)
	if err != nil {
		return nil, err
	}
	return n, nil
}

type scanPlanBinaryUint64ToUint64 struct{}

func (scanPlanBinaryUint64ToUint64) Scan(src []byte, dst any) error {
	if src == nil {
		return fmt.Errorf("cannot scan NULL into %T", dst)
	}

	raw, err := pgio.Uint64Exact(src)
	if err != nil {
		return fmt.Errorf("uint64: %w", err)
	}

	p := (dst).(*uint64)
	*p = raw

	return nil
}

type scanPlanBinaryUint64ToUint64Scanner struct{}

func (scanPlanBinaryUint64ToUint64Scanner) Scan(src []byte, dst any) error {
	s, ok := (dst).(Uint64Scanner)
	if !ok {
		return ErrScanTargetTypeChanged
	}

	if src == nil {
		return s.ScanUint64(Uint64{})

View on GitHub (pinned to ec1a0befd2)