jackc/pgx · error
timestamp
Error message
timestamp: %w
What it means
A binary timestamp must be exactly 8 bytes (int64 microseconds since 2000-01-01); pgio.Uint64Exact rejected the payload size. The wrapped error describes the length mismatch, after which decoding cannot proceed.
Solutions
- Fail the scan — the binary timestamp payload is corrupt
- Verify the column type is timestamp and the wire data was not truncated
- Check custom codec/buffering layers for size corruption
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/timestamp.go:267 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/9a16a3f9ae126f3d.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/timestamp.go:267
return &scanPlanTextTimestampToTimestampScanner{location: c.ScanLocation}
}
}
return nil
}
type scanPlanBinaryTimestampToTimestampScanner struct{ location *time.Location }
func (plan *scanPlanBinaryTimestampToTimestampScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TimestampScanner)
if src == nil {
return scanner.ScanTimestamp(Timestamp{})
}
raw, err := pgio.Uint64Exact(src)
if err != nil {
return fmt.Errorf("timestamp: %w", err)
}
var ts Timestamp
microsecSinceY2K := int64(raw)
switch microsecSinceY2K {
case infinityMicrosecondOffset:
ts = Timestamp{Valid: true, InfinityModifier: Infinity}
case negativeInfinityMicrosecondOffset:
ts = Timestamp{Valid: true, InfinityModifier: -Infinity}
default:
tim := time.Unix(
microsecFromUnixEpochToY2K/1_000_000+microsecSinceY2K/1_000_000,
(microsecFromUnixEpochToY2K%1_000_000*1_000)+(microsecSinceY2K%1_000_000*1000),
).UTC()
if plan.location != nil {
tim = time.Date(tim.Year(), tim.Month(), tim.Day(), tim.Hour(), tim.Minute(), tim.Second(), tim.Nanosecond(), plan.location)
}View on GitHub (pinned to ec1a0befd2)