jackc/pgx · error

hstore: %w

Error message

hstore: %w

What it means

Error "hstore: %w" thrown in jackc/pgx.

Source

Thrown at pgtype/hstore.go:194

	return nil
}

type scanPlanBinaryHstoreToHstoreScanner struct{}

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

	if src == nil {
		return scanner.ScanHstore(Hstore(nil))
	}

	r := pgio.NewReader(src)

	// Each pair carries at minimum two int32 length headers (key, value). This bounds the
	// up-front make() against a malicious server claiming a huge pair count in a small message.
	pairCount := r.Count(8)
	if err := r.Err(); err != nil {
		return fmt.Errorf("hstore: %w", err)
	}

	hstore := make(Hstore, pairCount)
	// one allocation for all *string, rather than one per string, just like text parsing
	valueStrings := make([]string, pairCount)

	for i := range pairCount {
		keyBytes, keyNull := r.Value()
		valueBytes, valueNull := r.Value()
		if err := r.Err(); err != nil {
			return fmt.Errorf("hstore pair %d: %w", i, err)
		}
		if keyNull {
			return fmt.Errorf("hstore pair %d: key cannot be NULL", i)
		}

		key := string(keyBytes)
		if valueNull {

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/hstore.go:194 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/3020d6764eddd672.json. Report an issue: GitHub.