# `Capstan.Binlog.TableMap`
[🔗](https://github.com/baselabs/capstan/blob/v1.3.1/lib/capstan/binlog/decoder.ex#L1)

A fully-decoded MySQL `TABLE_MAP_EVENT` body.

Ownership is deliberate: `Capstan.Binlog.Decoder` parses the **entire**
`TABLE_MAP` body — including the optional-metadata TLVs — into this struct.
`Capstan.Binlog.TableRegistry` stores and resolves these; `Capstan.Casting.Types`
casts row values against them. Neither re-parses the body, so this struct must
carry everything a later value-decode needs.

## Fields

  * `table_id` — the numeric table identity a row event references. Unstable across
    DDL and reused, so resolution is by this id via the registry, never by "most
    recent map" (ADR-0002).
  * `schema`, `table` — the qualified table name.
  * `column_types` — the raw MySQL type byte per column, in order (e.g. `3` = LONG,
    `254` = STRING/ENUM/SET). ENUM and SET both arrive as `254` and are told apart
    only via the metadata/TLVs.
  * `column_metadata` — the type-specific metadata blob, stored **RAW**. It is
    length-prefixed in the body and consumed here as a single unit; the per-column
    split needs type-aware widths and belongs to the casting layer
    (`Capstan.Casting.Types`), **not** here. Splitting it per-column in this module
    would cross that ownership boundary.
  * `null_bitmap` — the nullability bitmap over the columns.
  * `signedness` — optional-metadata TLV type 1: a bitmap over the NUMERIC columns,
    `1` = UNSIGNED. Signedness is **not** in the type byte; without this a
    `BIGINT UNSIGNED` of `18446744073709551615` would decode as `-1`. Retained raw
    because interpreting the bitmap requires the numeric-column ordering the casting
    layer owns.
  * `default_charset` — optional-metadata TLV type 2, retained raw.
  * `column_names` — optional-metadata TLV type 4, in column order (present under
    `binlog_row_metadata=FULL`).
  * `set_str_values` — optional-metadata TLV type 5: the allowed string values per
    `SET` column, in order. C1 must be able to detect `SET` (both it and `ENUM` are
    type `254`) to fail closed later, so these are unpacked here.
  * `enum_str_values` — optional-metadata TLV type 6: the allowed string values per
    `ENUM` column, in order.

Unknown optional-metadata TLV types (e.g. type 12 `COLUMN_VISIBILITY`, emitted by
8.0.46) are scanned past by their length and never cause a failure.

# `t`

```elixir
@type t() :: %Capstan.Binlog.TableMap{
  column_metadata: binary(),
  column_names: [String.t()],
  column_types: [byte()],
  default_charset: binary() | nil,
  enum_str_values: [[String.t()]],
  null_bitmap: binary(),
  schema: String.t(),
  set_str_values: [[String.t()]],
  signedness: binary() | nil,
  table: String.t(),
  table_id: non_neg_integer()
}
```

A decoded `TABLE_MAP_EVENT` body.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
