jackc/pgx · error

cannot scan Infinity into *time.Time

Error message

cannot scan Infinity into *time.Time

What it means

Error "cannot scan Infinity into *time.Time" thrown in jackc/pgx.

Source

Thrown at pgtype/zeronull/timestamp.go:28

type Timestamp time.Time

// SkipUnderlyingTypePlan implements the [pgtype.SkipUnderlyingTypePlanner] interface.
func (Timestamp) SkipUnderlyingTypePlan() {}

// ScanTimestamp implements the [pgtype.TimestampScanner] interface.
func (ts *Timestamp) ScanTimestamp(v pgtype.Timestamp) error {
	if !v.Valid {
		*ts = Timestamp{}
		return nil
	}

	switch v.InfinityModifier {
	case pgtype.Finite:
		*ts = Timestamp(v.Time)
		return nil
	case pgtype.Infinity:
		return fmt.Errorf("cannot scan Infinity into *time.Time")
	case pgtype.NegativeInfinity:
		return fmt.Errorf("cannot scan -Infinity into *time.Time")
	default:
		return fmt.Errorf("invalid InfinityModifier: %v", v.InfinityModifier)
	}
}

// TimestampValue implements the [pgtype.TimestampValuer] interface.
func (ts Timestamp) TimestampValue() (pgtype.Timestamp, error) {
	if time.Time(ts).IsZero() {
		return pgtype.Timestamp{}, nil
	}

	return pgtype.Timestamp{Time: time.Time(ts), Valid: true}, nil
}

// Scan implements the [database/sql.Scanner] interface.
func (ts *Timestamp) Scan(src any) error {

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/zeronull/timestamp.go:28 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/b48178584509aa19.json. Report an issue: GitHub.