Modules

ModuleSource FileDescription
b_tree b_tree.f90

An open B+-tree. Pure data plus the open unit — the comparator and its context are stateless and supplied per call, so a handle can be closed and reopened freely and carries nothing un-persistable. A forward cursor over entries in ascending (key,payload) order. Obtained from bt_first (whole tree) or bt_seek (lower bound on a key); advanced and read with bt_next.

   b_tree_sm b_tree_sm.f90
clib_wrap clib_wrap.f90

atomic rename/replace (same filesystem) unlink a file or remove an empty directory create one directory (mode 0777 & umask on POSIX) does the path exist? recursively remove a directory tree flush a file's data to stable storage flush a directory's entries to stable storage set a file's length (shrink or grow) try (non-blocking) to take an advisory lock release an advisory lock and close its handle downgrade an exclusive advisory lock to shared is standard input a terminal?

   clib_wrap_impl clib_wrap_sm.f90
cmdgraph cmdgraph.f90

Library version. major and minor are synchronised across all implementations; patch may differ per implementation. Compile-time library version constant. Declarative argument specification attached to a command. Preferred over direct initialisation — use the arg_is_int / arg_is_real / arg_is_char / arg_is_rest constructor functions. When a command has an args= spec the engine validates count and types before invoking the action; failure short-circuits with RC_ERROR. Read-only description of one command in the current state, returned by engine_t%available_commands. The result depends only on the state name; safe to cache keyed by state name after finalize. State-graph driven command interpreter.

Read more…
   cmdgraph_sm cmdgraph_sm.f90
dlist dlist.f90

Doubly-linked list with polymorphic element storage. Iterate with iterate / reverse_iterate, or access by index with get. Abstract base for list element data. Extend this type to store custom data. Node holding a single integer value. Node holding a single real(8) value. Node holding a real(8) rank-1 array. Node holding a real(8) rank-2 array. Node holding an allocatable character string. Construct an integer node. Construct a real(8) scalar node. Construct a real(8) rank-1 array node. Construct a real(8) rank-2 array node. Construct a character node. Generic node constructor — dispatches on argument type. Visitor procedure signature for iterate / reverse_iterate. Set ok = .false. to stop iteration early.

   dlist_sm dlist_sm.f90
sql sql.f90

One AND-group of conditions. A WHERE clause is a disjunction (OR) of these groups; a row matches the clause iff it matches every condition of some group (disjunctive normal form — no parentheses needed). The outcome of executing one statement. A SELECT fills colnames and the (nrows, ncols) cells grid; a DML statement fills count; DDL fills message. Both the REPL and the test suite consume this same structure, so output is asserted directly rather than scraped from text. source line -> token stream source line -> one statement AST statement AST -> result (drives the engine) source line -> result (lex + parse + exec) result -> printed to a unit (the REPL renderer)

   sql_base sql_base.f90

Lower-case an ASCII string (for case-insensitive keyword matching). .true. if token t is the (case-insensitive) keyword kw. .true. if token t is the punctuation p. Record an error: set stat (when present) to code and copy msg into errmsg (when present, truncated to its length). Decimal text of an integer.

      sql_executor sql_exec.f90

Gathering context for a db_scan (and reused by the cursor path): the table being read, the WHERE clause to apply, and the growing set of matching rows (ids + record buffers).

      sql_parser sql_parse.f90
sqr sqr.f90

A (possibly composite) secondary index. The key is the member column bytes concatenated in declared order; a single-column index is just arity 1. unique enforces that no two live rows share a key. One open table: schema, derived layout, open units and index set. One undo record captured before a transaction overwrites part of a base file. A REGION record stores the original bytes of an in-place overwrite (rollback writes them back); an EXTEND record stores only the original file length (rollback truncates appended bytes away). Module-private — exposed only as a component of journal_t. Pre-transaction snapshot of one table's in-memory counters. The undo journal restores file bytes; these cached values (high-water row id, live count, blob append position) are advanced in memory by row mutations and are not on disk per-write, so a rollback restores them from here — the record analogue of bt_reload for the index trees. Module-private — exposed only as a component of journal_t. Per-database rollback journal. Opaque to callers, carried as a component of db_t; driven by the txn_* / jrnl_* procedures. The file <db>/_journal.dat is a reusable sidecar — a hot (valid) journal exists iff a transaction is in flight or a crash interrupted one. An open database handle. Obtain with db_open; release with db_close. A handle is bound to one directory for its lifetime. A forward (ascending) cursor over the live rows of a table in the key order of one of its single-column indices. Obtain it from db_open_cursor (the whole index) or db_find_range (an inclusive [lo,hi] band), then pull rows with db_cursor_next until it reports exhaustion — the pull complement to the db_scan callback.

Read more…
   sqr_base sqr_base.f90
      sqr_admin sqr_admin.f90
      sqr_index sqr_index.f90
      sqr_journal sqr_journal.f90
      sqr_record sqr_record.f90
      sqr_rowbuf sqr_rowbuf.f90
      sqr_table sqr_table.f90
sqr_fault sqr_fault.f90
   sqr_fault_off sqr_fault_off_sm.f90