aiondb-core

Shared runtime types used by every other crate. Defines the value model, column data types, identifiers, errors with SQLSTATE codes, and a few cross-cutting helpers (text encoding, network address types, checksums, temporal formatting). It has no internal dependency on the rest of the workspace; everything else depends on it.

Cargo

[dependencies]
aiondb-core = { path = "../aiondb-core" }

Modules

ModulePurpose
valueRuntime tagged value (Value) and VectorValue.
data_typeColumn/expression type descriptor (DataType).
rowRow wrapper around Vec<Value>.
errorDbError, DbResult<T>, SqlState, ErrorReport.
idsStrongly typed identifier wrappers (TxnId, RelationId, ...).
numericNumericValue (arbitrary precision) and IntervalValue.
temporalPgDate, DateStyleSetting, TimeZoneSetting, DateOrder.
networkMacAddr, MacAddr8.
pg_lsnPgLsnValue (Postgres log sequence number).
tidTidValue (Postgres tuple identifier).
text_utilsescape_sql_literal, hex_encode, pg_array_unescape_quoted.
checksumPage/buffer checksum helpers.
convertValue-to-value conversions used by the cast paths.
fkFkAction, FkMatchType enums for foreign key descriptors.
identityIdentitySpec, IdentityOptions, IdentityGeneration.
pg_compatConstants and OIDs that match Postgres defaults.
vector_limitsBounds for vector index parameters.
vector_storageLayout helpers for stored vectors.
bounded_ioLength-bounded readers/writers used at the engine boundary to keep adversarial peer input from exhausting memory.
replication_fsFilesystem helpers (atomic file create, directory fsync, tmp-then-rename) used by the replication metadata writers.
sql_traceSQL trace-id propagation helpers and trace-id types.
trace_contextPer-task tracing context, including the active trace-id slot used by background workers.

Values

Value is the runtime tagged union for every column value. Variants (definition in crates/aiondb-core/src/value.rs):

Null  Int  BigInt  Real  Double  Numeric  Money  Text  Boolean  Blob
Timestamp  TimestampTz  Date  LargeDate  Time  TimeTz  Interval
Uuid  Tid  PgLsn  Jsonb  MacAddr  MacAddr8  Vector  Array

Blob holds raw bytes (Vec<u8>). LargeDate carries PgDate for years outside the range representable by time::Date. Tid and PgLsn exist so PostgreSQL system columns and system functions can be returned without lossy conversions.

use aiondb_core::Value;

let v = Value::Int(42);
assert!(matches!(v, Value::Int(_)));

let v_text = Value::Text("hello".to_string());
let v_null = Value::Null;

Rows

use aiondb_core::{Row, Value};

let row = Row::new(vec![Value::Int(1), Value::Text("alice".to_string())]);
assert_eq!(row.len(), 2);
for v in row.iter() {
    println!("{:?}", v);
}

Data types

DataType is the static type descriptor used by the planner and the executor.

use aiondb_core::DataType;

let int_type = DataType::Int;
let varchar = DataType::VarChar { length: 64 };

Variants include Int, BigInt, Real, Double, Numeric, Boolean, Text, Char { length }, VarChar { length }, Date, Time, TimeTz, Timestamp, TimestampTz, Interval, Uuid, Jsonb, MacAddr, MacAddr8, and Vector { ... }.

Errors

Every fallible API returns DbResult<T> = Result<T, DbError>. Each DbError carries an explicit SqlState.

use aiondb_core::{DbError, SqlState};

let err = DbError::new(SqlState::UndefinedTable, "relation \"users\" does not exist");
assert_eq!(err.sqlstate.code(), "42P01");

Convenience constructors group errors by category:

use aiondb_core::{DbError, SqlState};

let _ = DbError::syntax_error("missing ;");
let _ = DbError::authentication_error("invalid password");
let _ = DbError::not_authorized("permission denied for table users");
let _ = DbError::transaction_error(SqlState::SerializationFailure, "could not serialize");

SqlState::code() returns the five-character Postgres SQLSTATE string. SqlState::from_code(...) parses it back.

Identifiers

Strongly typed wrappers over u64. Each one is Copy, Debug, and serde-friendly. The macro defines them uniformly:

use aiondb_core::{RelationId, TxnId};

let table_id = RelationId::new(42);
let txn = TxnId::new(7);
assert_eq!(table_id.get(), 42);

Available identifiers: TxnId, TenantId, DatabaseId, SchemaId, RelationId, IndexId, ColumnId, SequenceId, TupleId.

Numerics

NumericValue provides arbitrary-precision decimals, used to back the SQL NUMERIC type. IntervalValue represents INTERVAL with separate months / days / microseconds components.

use aiondb_core::{IntervalValue, NumericValue};

let n: NumericValue = "1234.5678".parse().expect("valid numeric literal");
let interval = IntervalValue::from_components(1, 0, 0); // 1 month
let _ = (n, interval);

Vectors

VectorValue carries the element type plus the dimensions. vector_limits exposes bounds applied by the planner:

use aiondb_core::{HNSW_BASELINE_EF_SEARCH, HNSW_MAX_EF_SEARCH, VECTOR_MAX_K};

assert!(HNSW_BASELINE_EF_SEARCH <= HNSW_MAX_EF_SEARCH);
assert!(VECTOR_MAX_K > 0);

Network types

use aiondb_core::{MacAddr, MacAddr8};

let mac = MacAddr::new([0x00, 0x1a, 0x2b, 0x3c, 0x4d, 0x5e]);
let mac8 = MacAddr8::new([0x00, 0x1a, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f, 0x70]);
let _ = (mac, mac8);

Text utilities

use aiondb_core::{escape_sql_literal, hex_encode};

assert_eq!(escape_sql_literal("o'reilly"), "'o''reilly'");
assert_eq!(hex_encode(b"AB"), "4142");

Postgres compatibility constants

The pg_compat module exposes the OIDs and default settings AionDB returns to clients that introspect the server (for example, pg_catalog, information_schema, client_encoding, server_version_num).

use aiondb_core::{compat_server_version_num_string, COMPAT_PG_CATALOG_NAMESPACE_OID};

let _version = compat_server_version_num_string();
let _oid = COMPAT_PG_CATALOG_NAMESPACE_OID;