jackc/pgx · error

time

Error message

time: %w

What it means

scanPlanBinaryTimeToTimeScanner wraps pgio.Uint64Exact: the binary time-of-day payload was not exactly 8 bytes, so the microseconds value cannot be read. The wrapped error details the size mismatch.

Solutions

  1. Treat the value as corrupt and fail the scan
  2. Verify the column is a time type and the binary payload is 8 bytes
  3. Check for truncation in custom transport or buffering code
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgtype/time.go:168 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/422d162ac595f8cb. Report an issue: GitHub.

Appendix: source

Thrown at pgtype/time.go:168

			return scanPlanTextAnyToTimeScanner{}
		}
	}

	return nil
}

type scanPlanBinaryTimeToTimeScanner struct{}

func (scanPlanBinaryTimeToTimeScanner) Scan(src []byte, dst any) error {
	scanner := (dst).(TimeScanner)

	if src == nil {
		return scanner.ScanTime(Time{})
	}

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

	usec := int64(raw)

	return scanner.ScanTime(Time{Microseconds: usec, Valid: true})
}

type scanPlanBinaryTimeToTextScanner struct{}

func (scanPlanBinaryTimeToTextScanner) Scan(src []byte, dst any) error {
	ts, ok := (dst).(TextScanner)
	if !ok {
		return ErrScanTargetTypeChanged
	}

	if src == nil {
		return ts.ScanText(Text{})
	}

View on GitHub (pinned to ec1a0befd2)