Liking cljdoc? Tell your friends :D

datahike.pg.types

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)
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)
raw docstring

cast-bit-typesclj

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".
raw docstring

cast-boolean-typesclj

SQL type names that cast to boolean.

SQL type names that cast to boolean.
raw docstring

cast-bytes-typesclj

SQL type names that cast to a byte array.

SQL type names that cast to a byte array.
raw docstring

cast-categoryclj

(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).
raw docstring

cast-date-typesclj

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).
raw docstring

cast-float-typesclj

SQL type names that cast to floating point (Clojure double).

SQL type names that cast to floating point (Clojure double).
raw docstring

cast-integer-typesclj

SQL type names that cast to integer (Clojure long).

SQL type names that cast to integer (Clojure long).
raw docstring

cast-text-typesclj

SQL type names that cast to text (Clojure string).

SQL type names that cast to text (Clojure string).
raw docstring

cast-time-typesclj

SQL type names that cast to a TIME (no date component).

SQL type names that cast to a TIME (no date component).
raw docstring

cast-timestamp-typesclj

SQL type names that cast to timestamp/instant.

SQL type names that cast to timestamp/instant.
raw docstring

cast-uuid-typesclj

SQL type names that cast to UUID.

SQL type names that cast to UUID.
raw docstring

dh-type->oidclj

Map Datahike :db/valueType to PostgreSQL type OID for wire protocol.

Map Datahike :db/valueType to PostgreSQL type OID for wire protocol.
raw docstring

dh-type->pg-nameclj

Map Datahike :db/valueType to PostgreSQL type name string.

Map Datahike :db/valueType to PostgreSQL type name string.
raw docstring

dh-type-for-sql-nameclj

(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).
raw docstring

format-typeclj

(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.
raw docstring

infer-oid-from-valueclj

(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.
raw docstring

oid->pg-nameclj

Map PostgreSQL type OID to canonical type name string.

Map PostgreSQL type OID to canonical type name string.
raw docstring

oid->wire-sizeclj

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.
raw docstring

oid-boolclj


oid-bpcharclj


oid-byteaclj


oid-dateclj


oid-float4clj


oid-float8clj


oid-for-dh-typeclj

(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.
raw docstring

oid-int2clj


oid-int4clj


oid-int8clj


oid-intervalclj


oid-jsonclj


oid-jsonbclj


oid-nameclj


oid-numericclj


oid-oidclj


oid-textclj


oid-timeclj


oid-timestampclj


oid-timestamptzclj


oid-uuidclj


oid-varcharclj


pg-name->oidclj

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.
raw docstring

pg-name-for-dh-typeclj

(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.
raw docstring

pg-type-catalogclj

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]
raw docstring

sql-name->dh-typeclj

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.
raw docstring

wire-sizeclj

(wire-size oid)

Return the wire protocol type size for an OID.

Return the wire protocol type size for an OID.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close