Skip to main content

Module int_width

Module int_width 

Source
Expand description

IntWidth — the declared width of an integer column.

nodedb stores every integer as a full i64 regardless of the width the DDL author declared: ColumnType::Int64 is the one storage variant for SMALLINT, INTEGER, and BIGINT alike. The declared width is therefore not a storage property — it is a constraint plus a wire contract:

  • Constraint — a value written to a column declared INTEGER must fit in an i32, exactly as PostgreSQL enforces (integer out of range). Without this, the wire contract below cannot be honoured.
  • Wire contract — the column’s RowDescription OID is 21/23/20, and under the binary result format the value is transmitted as 2/4/8 bytes. A client that declared SMALLINT decodes exactly two bytes; handing it a wider value is silent corruption, not a rounding error.

Because both of those depend on recognising the same set of SQL keywords, IntWidth::from_declared_type is the single place that maps a declared type string to a width. Every consumer — catalog introspection OIDs, RowDescription OIDs, and write-time range validation — resolves through it, so the three can never drift apart.

Enums§

IntWidth
The declared width of an integer column.