PostgreSQL type system registry for the PgWire compatibility layer.
Centralizes all type mappings between PostgreSQL OIDs, SQL type names, Datahike value types, and wire protocol format codes.
Authoritative source: PostgreSQL 19devel src/include/catalog/pg_type.dat
Three directions of mapping:
PostgreSQL type system registry for the PgWire compatibility layer. Centralizes all type mappings between PostgreSQL OIDs, SQL type names, Datahike value types, and wire protocol format codes. Authoritative source: PostgreSQL 19devel src/include/catalog/pg_type.dat Three directions of mapping: 1. SQL name → Datahike type (for CREATE TABLE) 2. Datahike type → PG OID (for wire protocol RowDescription) 3. PG OID → SQL name (for format_type() and information_schema) 4. SQL name → category (for CAST type classification)
SQL type names that cast to a PG bit string — emitted as a string of
ASCII '0'/'1' characters in PG's text format. pgjdbc's testgetBadBoolean
asserts 29::bit(4) serializes as "1101".
SQL type names that cast to a PG bit string — emitted as a string of ASCII '0'/'1' characters in PG's text format. pgjdbc's testgetBadBoolean asserts `29::bit(4)` serializes as "1101".
SQL type names that cast to boolean.
SQL type names that cast to boolean.
SQL type names that cast to a byte array.
SQL type names that cast to a byte array.
(cast-category sql-type-name)Classify a SQL type name for CAST handling. Returns :integer, :float, :text, :boolean, :date, :time, :timestamp, :uuid, :bytes, or nil. :date and :time are checked before :timestamp so callers can emit the display-appropriate Java type (LocalDate / LocalTime vs Instant).
Classify a SQL type name for CAST handling. Returns :integer, :float, :text, :boolean, :date, :time, :timestamp, :uuid, :bytes, or nil. :date and :time are checked before :timestamp so callers can emit the display-appropriate Java type (LocalDate / LocalTime vs Instant).
SQL type names that cast to a DATE (no time component). Needed because PG's DATE/TIME/TIMESTAMP all serialize differently in text format — e.g. DATE is '2017-03-13', TIME is '14:25:48', TIMESTAMP is '2017-03-13 14:25:48'. Datahike stores them all as :db.type/instant, so the distinction is only preserved through CAST expressions (where we know the target display type).
SQL type names that cast to a DATE (no time component). Needed because PG's DATE/TIME/TIMESTAMP all serialize differently in text format — e.g. DATE is '2017-03-13', TIME is '14:25:48', TIMESTAMP is '2017-03-13 14:25:48'. Datahike stores them all as :db.type/instant, so the distinction is only preserved through CAST expressions (where we know the target display type).
SQL type names that cast to floating point (Clojure double).
SQL type names that cast to floating point (Clojure double).
SQL type names that cast to integer (Clojure long).
SQL type names that cast to integer (Clojure long).
SQL type names that cast to text (Clojure string).
SQL type names that cast to text (Clojure string).
SQL type names that cast to a TIME (no date component).
SQL type names that cast to a TIME (no date component).
SQL type names that cast to timestamp/instant.
SQL type names that cast to timestamp/instant.
Map Datahike :db/valueType to PostgreSQL type OID for wire protocol.
Map Datahike :db/valueType to PostgreSQL type OID for wire protocol.
Map Datahike :db/valueType to PostgreSQL type name string.
Map Datahike :db/valueType to PostgreSQL type name string.
(dh-type-for-sql-name sql-name)Return the Datahike valueType for a SQL type name (lowercased).
Return the Datahike valueType for a SQL type name (lowercased).
(format-type type-oid _typmod)PostgreSQL format_type(oid, typmod) — return type name for an OID.
PostgreSQL format_type(oid, typmod) — return type name for an OID.
(infer-oid-from-value v)Infer a PostgreSQL type OID from a Clojure runtime value.
Infer a PostgreSQL type OID from a Clojure runtime value.
Map PostgreSQL type OID to canonical type name string.
Map PostgreSQL type OID to canonical type name string.
Map OID to type size for RowDescription's typlen field. Positive = fixed size in bytes, -1 = variable length.
Map OID to type size for RowDescription's typlen field. Positive = fixed size in bytes, -1 = variable length.
(oid-for-dh-type vtype)Return the PostgreSQL type OID for a Datahike valueType keyword.
Return the PostgreSQL type OID for a Datahike valueType keyword.
Map a PostgreSQL type name (the string stored on :pg/type when
the column's original SQL type doesn't match the Datahike
valueType 1:1 — e.g. date vs timestamp both collapse to
:db.type/instant) back to its wire OID. Used by
infer-param-oid-for-column so pgjdbc's ParameterDescription sees
the SQL-declared type, not our internal reduction.
Map a PostgreSQL type name (the string stored on :pg/type when the column's original SQL type doesn't match the Datahike valueType 1:1 — e.g. `date` vs `timestamp` both collapse to :db.type/instant) back to its wire OID. Used by infer-param-oid-for-column so pgjdbc's ParameterDescription sees the SQL-declared type, not our internal reduction.
(pg-name-for-dh-type vtype)Return the PostgreSQL type name string for a Datahike valueType keyword.
Return the PostgreSQL type name string for a Datahike valueType keyword.
Common PostgreSQL types for the pg_type virtual table. Each entry: [oid typname typlen typtype]
Common PostgreSQL types for the pg_type virtual table. Each entry: [oid typname typlen typtype]
Map SQL type names (lowercased) to Datahike :db/valueType keywords. Covers all common SQL and PostgreSQL type name variants.
Map SQL type names (lowercased) to Datahike :db/valueType keywords. Covers all common SQL and PostgreSQL type name variants.
(wire-size oid)Return the wire protocol type size for an OID.
Return the wire protocol type size for an OID.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |