jackc/pgx · error

unknown format code %d

Error message

unknown format code %d

What it means

Error "unknown format code %d" thrown in jackc/pgx.

Source

Thrown at pgtype/record_codec.go:88

	}

	return nil
}

func (RecordCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error) {
	if src == nil {
		return nil, nil
	}

	switch format {
	case TextFormatCode:
		return string(src), nil
	case BinaryFormatCode:
		buf := make([]byte, len(src))
		copy(buf, src)
		return buf, nil
	default:
		return nil, fmt.Errorf("unknown format code %d", format)
	}
}

func (RecordCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
	if src == nil {
		return nil, nil
	}

	switch format {
	case TextFormatCode:
		return string(src), nil
	case BinaryFormatCode:
		scanner := NewCompositeBinaryScanner(m, src)
		// The field count is a hint for the initial allocation only. Append the
		// values actually present rather than indexing into a presized slice, as
		// the source may carry more or fewer fields than the header claims.
		values := make([]any, 0, scanner.FieldCount())
		for scanner.Next() {

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/record_codec.go:88 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/7a0deb9a77eecc95.json. Report an issue: GitHub.