Skip to main content

Module relation

Module relation 

Source
Expand description

Reading one relation out of the store, without going through a query language to do it.

§Why this module exists

The SQL evaluator used to obtain its rows by BUILDING AN NQL STRING and parsing it back:

    let mut q = format!("FROM {}", cname);
    if let Some(seq) = temporal.get(&key) { q.push_str(&format!(" AS OF {}", seq)); }
    ...
    crate::nql::query(db, &q)

That is a translation. It is the same translation the project spent months removing, pointed the other way — and it carried the same class of defect, because a clause that fails to make it into the string is a clause that silently does not happen. The retry path in pgwire did exactly that: it rebuilt a shorter string by hand and dropped VALID AS OF and SEARCH while carefully preserving AS OF, because someone had been bitten by AS OF specifically and fixed that one.

A struct cannot forget a field. This module is the scan expressed as data, executed by calling the store directly.

§This is the fold, not a second implementation

matches_valid_as_of and node_contains_text LIVE HERE NOW. They were private to nql, and NQL’s executor calls into this module for them rather than keeping a copy. That ordering matters: two copies of “what does VALID AS OF mean” is the exact failure mode being removed, and it would be absurd to create one while removing one.

What remains in nql is its parser and its predicate evaluator. When the last caller of those is gone, so is the file.

Structs§

Scan
One relation to read, and the qualifiers that shape it.

Constants§

DEFAULT_TRACE_LIMIT
The cap NQL used, preserved so a migrated query answers identically.

Functions§

matches_valid_as_of
Is node valid at date?
node_contains_text
Full-text over the document’s rendered JSON, case-insensitively.
read
Read the relation.
read_json
Read the relation as query rows.