Skip to main content

DataType

Enum DataType 

Source
pub enum DataType {
Show 32 variants SmallInt, Int, BigInt, Float, Text, Varchar(u32), Char(u32), Bool, Vector { dim: u32, encoding: VecEncoding, }, Numeric { precision: u8, scale: u8, }, Date, Timestamp, Timestamptz, Interval, Json, Jsonb, Bytes, TextArray, IntArray, BigIntArray, TsVector, TsQuery, Uuid, Time, Year, TimeTz, Money, Range(RangeKind), Hstore, IntArray2D, BigIntArray2D, TextArray2D,
}
Expand description

Runtime type tags. Vector { dim, encoding } / Varchar(max) / Char(size) are parameterised; the parameter travels with both the column schema and the on-wire serialised representation.

Variants§

§

SmallInt

16-bit signed. Backed by Value::SmallInt(i16); arithmetic that would overflow surfaces as a type error at INSERT time.

§

Int

§

BigInt

§

Float

§

Text

§

Varchar(u32)

VARCHAR(n) — same byte representation as Text, but INSERT rejects values longer than n Unicode characters.

§

Char(u32)

CHAR(n) — same representation as Text, but INSERT right-pads with U+0020 to exactly n Unicode characters (or rejects when the input is already longer).

§

Bool

§

Vector

pgvector-style fixed-dimension vector. encoding selects the in-cell representation (F32 = pre-v6 raw f32 buffer; Sq8 = v6.0.1 8-bit scalar-quantised). The DDL grammar surfaces encoding via the optional USING <encoding> clause: VECTOR(128) USING SQ8.

Fields

§dim: u32
§encoding: VecEncoding
§

Numeric

NUMERIC(precision, scale) — exact fixed-point decimal stored as a scaled i128. precision caps total decimal digits, scale fixes digits after the decimal point. v1.12 supports up to precision 38 (the i128-safe ceiling). NUMERIC and NUMERIC(p) surface as Numeric { precision: p, scale: 0 }.

Fields

§precision: u8
§scale: u8
§

Date

DATE — calendar date with day precision, stored as i32 days since the Unix epoch (1970-01-01).

§

Timestamp

TIMESTAMP (a.k.a. MySQL DATETIME) — instant with microsecond precision, stored as i64 microseconds since the Unix epoch.

§

Timestamptz

v7.9.2 TIMESTAMPTZ — bit-identical to Timestamp on disk (i64 microseconds, UTC by convention). Carried as a distinct type tag so the PG-wire layer can advertise OID 1184 (PG’s timestamp with time zone) and sqlx/pgx/JDBC clients decode into their TZ-aware datetime types. The internal semantics are unchanged: SPG never stored per-row offsets, and neither did PG — TIMESTAMPTZ in PG is also UTC i64.

§

Interval

INTERVAL — calendar-aware span (months + microseconds). v2.11 supports INTERVAL only as a runtime intermediate (literals, arithmetic results); on-disk encoding is rejected so this branch can’t appear in a ColumnSchema.

§

Json

v4.9: JSON — text-backed JSON document. We don’t parse the content (no path operators or jsonb functions yet) — the column accepts any TEXT-compatible value and round-trips it verbatim. PG OID 114 on the wire.

§

Jsonb

v7.9.0: JSONB — semantically identical to Json on the storage side (same Value::Json cells, same row codec), but advertised as PG OID 3802 on the wire so sqlx-style clients that bind jsonb columns decode correctly. mailrs migration blocker #3.

§

Bytes

v7.10.4: BYTES / BYTEA — variable-length raw binary. Backed by Value::Bytes(Vec<u8>). PG wire OID 17. Literal forms accepted by parser/engine: PG hex form '\xDEADBEEF' (case-insensitive hex pairs) and escape form 'foo\\000bar' (the latter decoded at coercion time when the target column is BYTEA — TEXT columns leave the backslash sequence verbatim).

§

TextArray

v7.10.9: TEXT[] — single-dimension TEXT array. Elements may be NULL (PG semantics). PG wire OID 1009. Literal forms: ARRAY['a', 'b', NULL] and the PG external form '{a,b,NULL}'::TEXT[]. Engine implements = ANY(arr), <> ALL(arr), and 1-based indexing arr[i]. Catalog FILE_VERSION 18+; older snapshots reject this DataType (forward-only by design — TEXT[] columns aren’t readable on a pre-v7.10 binary).

§

IntArray

v7.11.12: INT[] — single-dimension i32 array. PG wire OID 1007 (_int4). Same ARRAY[...] / '{1,2,3}'::INT[] literal surface as TEXT[]. Catalog FILE_VERSION 19+.

§

BigIntArray

v7.11.12: BIGINT[] — single-dimension i64 array. PG wire OID 1016 (_int8). Catalog FILE_VERSION 19+.

§

TsVector

v7.12.0: PG tsvector — ordered, deduplicated set of (lexeme, positions, weight) tuples. PG wire OID 3614. Catalog FILE_VERSION 20+. Storage shape is row-codec tag 22; the schema-agnostic write_value path emits tag 18. Literal: 'foo:1 bar:2,3'::tsvector (PG external form). G-CRIT-3 entry — v7.12.0 only ships the type + codec; matching @@ lands in v7.12.2.

§

TsQuery

v7.12.0: PG tsquery — parse tree of lexemes joined by & | ! and phrase operators. PG wire OID 3615. Catalog FILE_VERSION 20+.

§

Uuid

v7.17.0: PG uuid — 128-bit identifier stored as Value::Uuid([u8; 16]). PG wire OID 2950. Canonical text form is lowercase 8-4-4-4-12 hyphenated; input also accepts uppercase, unhyphenated, and brace-wrapped forms ({xxxx…}). Catalog FILE_VERSION 36+; tag 24 on the dense type-tag side, tag 20 on the schema-agnostic value side. The drop-in PG/MySQL surface for Django / Rails / Hibernate “id UUID PRIMARY KEY DEFAULT gen_random_uuid()” default-PK pattern.

§

Time

v7.17.0 Phase 3.P0-32: PG time (without time zone) — i64 microseconds since 00:00:00. PG wire OID 1083. Display: canonical zero-padded HH:MM:SS when fractional is zero, HH:MM:SS.ffffff otherwise. Catalog FILE_VERSION 37+; tag 25 on the dense type-tag side, tag 21 on the schema- agnostic value side. The wall-clock-of-day half of PG’s date/time triplet (date / time / timestamp).

§

Year

v7.17.0 Phase 3.P0-33: MySQL YEAR — u16 in range 1901..=2155 plus the special zero-year sentinel 0. No dedicated PG OID (advertised as INT4 / OID 23 on the wire — psql renders integers, MySQL CLI renders 4-digit zero-padded text). Display always 4 digits: 0000 for the zero-year, 1985 / 2007 / etc otherwise. Catalog FILE_VERSION 38+; tag 26 on the dense type-tag side, tag 22 on the schema-agnostic value side.

§

TimeTz

v7.17.0 Phase 3.P0-34: PG time with time zone (TIMETZ) — i64 microseconds since 00:00:00 in the local wall clock PLUS i32 offset-from-UTC in seconds. PG wire OID 1266. Display: HH:MM:SS[.ffffff]±HH[:MM] (PG timetz_out). Range: offset in ±50400 seconds (±14 hours). Catalog FILE_VERSION 39+; tag 27 on the dense type-tag side, tag 23 on the schema-agnostic value side.

§

Money

v7.17.0 Phase 3.P0-35: PG money — i64 cents (locale- independent storage). PG wire OID 790. Display: en_US locale ($N,NNN.CC, negative → -$1.23). Input accepts $N.NN, $N,NNN.NN, bare integer (treated as major units), optional leading -. Range: full i64. Catalog FILE_VERSION 40+; tag 28 on the dense type-tag side, tag 24 on the schema-agnostic value side.

§

Range(RangeKind)

v7.17.0 Phase 3.P0-38: PG range type. The same DataType variant covers all six builtin ranges (int4range, int8range, numrange, tsrange, tstzrange, daterange) — RangeKind pins the element type so encode / decode / display can route off one switch. Catalog FILE_VERSION 43+; tag 29 + a 1-byte RangeKind on the dense type-tag side, tag 25 on the schema-agnostic value side.

§

Hstore

v7.17.0 Phase 3.P0-39: PG hstore extension type — flat text => text map with NULL value support. Catalog FILE_VERSION 44+; tag 30 on the dense type-tag side, tag 26 on the schema-agnostic value side. The contrib OID is installation-dependent in real PG; SPG advertises it via dynamic lookup, falling back to TEXT (OID 25) on the wire when the installed hstore extension hasn’t claimed an OID yet.

§

IntArray2D

v7.17.0 Phase 3.P0-40: PG int[][] — 2-dimensional INT matrix. Storage: row-major Vec<Vec<Option>>. All rows must share the same column count. Wire OID 1007 (same as INT[]; the dimension count travels in the data header, not the OID). Catalog FILE_VERSION 45+; tag 31 on the dense type-tag side, tag 27 on the schema-agnostic value side.

§

BigIntArray2D

v7.17.0 Phase 3.P0-40: PG bigint[][] — 2-dimensional BIGINT matrix. Storage / OID / tags mirror IntArray2D. Tag 32 dense, tag 28 schema-agnostic.

§

TextArray2D

v7.17.0 Phase 3.P0-40: PG text[][] — 2-dimensional TEXT matrix. Storage: row-major Vec<Vec<Option>>. Tag 33 dense, tag 29 schema-agnostic.

Trait Implementations§

Source§

impl Clone for DataType

Source§

fn clone(&self) -> DataType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for DataType

Source§

impl Debug for DataType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DataType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DataType

Source§

impl PartialEq for DataType

Source§

fn eq(&self, other: &DataType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DataType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.