jackc/pgx · error

cannot scan NULL into %T

Error message

cannot scan NULL into %T

What it means

Error "cannot scan NULL into %T" thrown in jackc/pgx.

Source

Thrown at pgtype/float4.go:207

	case TextFormatCode:
		switch target.(type) {
		case *float32:
			return scanPlanTextAnyToFloat32{}
		case Float64Scanner:
			return scanPlanTextAnyToFloat64Scanner{}
		case Int64Scanner:
			return scanPlanTextAnyToInt64Scanner{}
		}
	}

	return nil
}

type scanPlanBinaryFloat4ToFloat32 struct{}

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

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

	n := int32(raw)
	f := (dst).(*float32)
	*f = math.Float32frombits(uint32(n))

	return nil
}

type scanPlanBinaryFloat4ToFloat64Scanner struct{}

func (scanPlanBinaryFloat4ToFloat64Scanner) Scan(src []byte, dst any) error {
	s := (dst).(Float64Scanner)

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/float4.go:207 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/f3f708df0f7f18eb.json. Report an issue: GitHub.