Skip to content

Run store.yaml's indexKeys drift guard on each SQL store - #600

Merged
jasperblues merged 4 commits into
mainfrom
index-keys-511
Nov 27, 2026
Merged

jasperblues merged 4 commits into
mainfrom
index-keys-511

Conversation

@jasperblues

@jasperblues jasperblues commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Closes #511

#511's binding part, the compiler's _cyk_ index-key bind on Oracle, was already in. What was left was item 2: store.yaml's indexKeys drift guard (liberation-data/drivine-cypher-spec#286). The guard catches a module that works out a different key for a value than the store's index holds. A lookup by such a value would find nothing where the node is there.

drivine4j's IndexKeysCrossEngineTest checks it by calling the module's IndexKey.column and IndexKey.of directly. The module's JSON entry gives a library neither, so tests/integration/sql/test_index_keys.py (and its generated sync copy) checks what Python can reach, on Postgres, Oracle and SQLite.

Setup: a range index over each key of a probe label (id, and $id, stored as $$id), made through the schema API and dropped after. Each value the store pins is stored at rest under each key. Postgres uses Oracle's pins, as drivine4j does. A temporal tag carries its sort key s, which the module's temporalKey works out. A duration has none.

Checked on every store:

  • A lookup the module compiles for the value finds the node.
  • A temporal's key, its sort key or its text, equals the pin. This check needs no store, because the stored and bound tags both take s from the module: a drift there would otherwise hide behind a lookup that still matches.

Store by store:

  • SQLite: a lookup compares the class and key the index expressions give. The test also reads the probe index's own expressions back from sqlite_master, evaluates them over the node, and compares them with the pins, as drivine4j does with IndexKey.column. An EXPLAIN QUERY PLAN shows the lookup searches that index.
  • Oracle: a text, number or boolean is compared as its typed value with the key the module binds (_cyk_v). Where it binds one, the test checks it equals the pin. A temporal, and an integer past 2^53, bind none: they are compared by the SQL over the value.
  • Postgres: the property's JSON is compared with the value's.

Control test: a value the node doesn't hold isn't found: another text, a number, another date, and a date's digits as a text.

Mutation check: storing temporals without their sort key made every temporal row fail, under both keys. Giving SQLite Oracle's pins made the index readback report the difference.

Not checked here, so the guard is weaker than drivine4j's on two stores:

Tests:

  • The new tests: 12 passed, on Postgres, Oracle and SQLite, async and sync.
  • Whole suite with Oracle (ORACLE_TESTS=true) on the final commit:
    • tests/integration: 4720 passed, 291 skipped, 7 xfailed, 1 xpassed, 0 failed
    • tests/sync_integration: 4650 passed, 290 skipped, 7 xfailed, 1 xpassed, 0 failed

Review: 3 passes, last CLEAN (the last fixed a comment only).

  • Pass 1 added the no-store temporal-key check and the SQLite index readback, reused the spec runner's reader, and rewrote the docstring.
  • Pass 2 corrected the docstring on what each store's lookup compares.
  • Pass 3 noted that an integer past 2^53 binds no _cyk_ on Oracle either.

…st is found through a range index by a lookup the module compiles, and Oracle binds the key the spec pins (#511)
…index expressions back as drivine4j does, and use the spec runner's reader (#511)
…le the typed value or the whole tag, Postgres the JSON (#511)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Take the compiler's _cyk_ index-key bind on Oracle, and run store.yaml's indexKeys drift guard (drivine-cypher-spec#286)

1 participant