Skip to main content

Module queries

Module queries 

Source
Expand description

SQL schema and statement constants for the SQLite checkpoint saver.

SQLite-specific notes:

  • Uses TEXT for JSON columns (SQLite has no native JSONB; json_extract() handles filtering).
  • Uses BLOB for binary payloads (Postgres BYTEA).
  • Bind parameters use ? placeholders.
  • WAL mode is enabled at connection setup for concurrent reads.

Constants§

INSERT_CHECKPOINT_WRITES_SQL
Insert checkpoint writes (ignore on conflict). Default for normal per-task writes which should be append-only.
MIGRATIONS
SQL migrations for the checkpoint schema. Applied in order; each migration’s index is recorded in checkpoint_migrations.v.
SELECT_BLOBS_SQL
Fetch all blobs (channel values) for a given checkpoint by joining checkpoint.channel_versions with the blobs table.
SELECT_CHECKPOINT_SQL
Select base columns for a checkpoint row. Channel values and pending writes are fetched separately (SQLite lacks array_agg).
SELECT_WRITES_SQL
Fetch pending writes for a given checkpoint, ordered by task and idx.
UPSERT_CHECKPOINTS_SQL
Upsert a checkpoint, replacing the JSON payload and metadata if the (thread, ns, id) tuple already exists.
UPSERT_CHECKPOINT_BLOBS_SQL
Upsert checkpoint blobs. Blobs are immutable per (channel, version), so on conflict we keep the existing row.
UPSERT_CHECKPOINT_WRITES_SQL
Upsert checkpoint writes (overwrite on conflict). Used for special channels like __error__ whose value may legitimately change.