jackc/pgx · error

line

Error message

line: %w

What it means

After reading the three float64 coefficients (A, B, C) of a binary-encoded line, the plan requires that the 24-byte payload is fully consumed. This wrapper fires when pgio's reader reports leftover or insufficient bytes — the value's length did not exactly match the fixed line layout, indicating a truncated or malformed binary value.

Solutions

  1. Verify the column is a PostgreSQL line type and the value wasn't truncated in transit
  2. Check for bugs in custom binary encoding if the value was produced client-side
  3. Use the text format for the column as a workaround
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgtype/line.go:162 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/6d06e6a072dad79b. Report an issue: GitHub.

Appendix: source

Thrown at pgtype/line.go:162

}

type scanPlanBinaryLineToLineScanner struct{}

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

	if src == nil {
		return scanner.ScanLine(Line{})
	}

	r := pgio.NewReader(src)

	a := r.Uint64()
	b := r.Uint64()
	c := r.Uint64()

	if err := r.Finish(); err != nil {
		return fmt.Errorf("line: %w", err)
	}

	return scanner.ScanLine(Line{
		A:     math.Float64frombits(a),
		B:     math.Float64frombits(b),
		C:     math.Float64frombits(c),
		Valid: true,
	})
}

type scanPlanTextAnyToLineScanner struct{}

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

	if src == nil {
		return scanner.ScanLine(Line{})
	}

View on GitHub (pinned to ec1a0befd2)