Per-engine notes
Where the statements come from. The statements that make, drop and list each store’s indexes and constraints, and on
Oracle, Postgres and SQLite the graph’s tables and what finds them made, are written by the Cypher compiler’s module
(org.drivine.cypher.store.ddl, in drivine-cypher-spec), which
the three Drivine libraries share, so a store one library made is the store another reads and finds its indexes in. The
spec’s store.yaml pins them for each store, byte for byte, with how each store’s listings read back, which item is the
one a spec declares and in its shape, and what each store’s errors say (org.drivine.cypher.store.schema).
Where the decisions come from. What enforce, recreateAll, ensure and remove, and the indexes and
constraints managers’ ensure, recreate and drop, do on a store is decided by the module’s schema planner
(org.drivine.cypher.store.plan), which the three libraries share, so each decides alike of a store any of them made:
which item matches, drifts or is missing, what a changed version or recreateAll recreates, which items are co-owned,
orphaned or ensured at runtime, what the _DrivineSchema marker records, when a build is waited for and a store that
builds in the background is polled, when a violation is confirmed by the data, and what each owner reports, word for
word in its log lines. The spec’s plans.yaml pins its decisions, round by round. The planner plans in rounds: drivine4j
runs each round’s statements (DDL, listings and waits on a schema connection of their own, the marker’s statements
through the auto-commit manager, FalkorDB’s commands natively), hands back what each gave, a store’s error as the module
reads one, and logs and throws what the planner’s report says. Resolving which databases a catalog applies to, the
lowercased copies’ record, and the connections stay drivine4j’s. The planner reads a listing once and uses it until its
own DDL runs, where drivine4j once read it again for each item, so it sends fewer reads; what it writes, and in which
order, is what drivine4j wrote.
| Neo4j | Memgraph | FalkorDB | |
|---|---|---|---|
| Vector indexes | CREATE VECTOR INDEX … IF NOT EXISTS |
WITH CONFIG {…}, uSearch metrics |
OPTIONS {…}, unnamed |
| Full-text indexes | CREATE FULLTEXT INDEX … ON EACH […] (+ analyzer) |
CREATE TEXT INDEX … ON :L(props) |
CREATE FULLTEXT INDEX FOR (n:L) ON (n.prop), per-property, unnamed |
| Range indexes | Named, composite supported | Label-property style | Per-label coverage; extended incrementally |
| TEXT indexes | CREATE TEXT INDEX … IF NOT EXISTS FOR (n:L) ON (n.prop), from Neo4j 4.4 |
Refused: its TEXT INDEX is full-text, above |
Refused |
| Uniqueness | REQUIRE … IS UNIQUE |
ASSERT … IS UNIQUE |
Redis command GRAPH.CONSTRAINT (not Cypher) — Drivine issues it at driver level, auto-creates the required backing index, and polls the asynchronous build. A build FalkorDB marks FAILED is dropped, since it enforces nothing yet stays listed, and is a Violation when a key repeats. One found already in the store is dropped and built again, not taken as AlreadyMatching, and drop removes one. One found still UNDER CONSTRUCTION (another process’s build, or an earlier run’s) is waited on: AlreadyMatching once built, dropped and built again if its build fails |
| Item names | Yes | Vector only | No |
Oracle. Every item is an index over an expression, since a property is a path into a JSON column, and what Drivine made is recorded in the table <graph>_schema, which ensure and drift detection read. An item whose index or table was dropped by hand is made again by the next ensure.
| Oracle | |
|---|---|
| Vector indexes | A table of embeddings (VECTOR(n, FLOAT32)) beside the nodes, kept in step by a trigger and filled from the nodes there are, with CREATE VECTOR INDEX … ORGANIZATION NEIGHBOR PARTITIONS over it. An embedding of another dimension leaves its node out of the index |
| Full-text indexes | A table of the indexed text beside the nodes, kept in step by a trigger, with an Oracle Text search index over it. Without Oracle Text the index is recorded and nothing is made |
| Range indexes | Two indexes, each over a property’s class and key as the store layout holds a value, so a value is equal only to one of its kind: a temporal value’s kind and sort key, a number’s exact digits, any other value as JSON_VALUE reads it. One is over the property whatever the label, so two labels that index a property of one name share it. The other, CASE WHEN JSON_EXISTS(n.labels, '$[*]?(@ == "Label")') THEN … END around each, is over the property of the label’s nodes alone, which an eq on the label’s nodes reads. Composite supported. Both are built ONLINE, so writes to the graph’s nodes go on while each is built (drivine-cypher-spec#381); an edition without online builds (ORA-00439) builds them, and each after them in that ensure, with writes held until done, said once at WARN. A uniqueness constraint’s indexes are built that way always |
| TEXT indexes | Refused: Neo4j’s alone |
| Uniqueness | A unique index over the property’s class and key for the nodes that carry the label, with the range index over the property whatever the label. A node that lacks one of the properties is not constrained. Over one property, the unique index stands for the range index’s index over the label’s nodes, and none is made beside it |
| Index builds | Ensures of one item take turns to build it, as on Postgres (drivine4j#777): sessions issuing the same CREATE INDEX at once on one table deadlock in the library cache (ORA-04020). Before it builds, an ensure polls a count of the claims of its turn that other sessions hold, for 60 seconds at most, then takes its turn with a row of kind CLAIM:<kind> in the <graph>_schema table, written and committed in a transaction of its own (AUTONOMOUS_TRANSACTION), whatever transaction the connection is in; a take refused because another session’s claim stands (ORA-00001) polls again. It gives the turn up once it is done, made or failed. Where the wait runs out it goes on without its turn, said at INFO, and so it does at once where the claim can’t be written or its count read. A claim stamped more than 60 seconds ago by the store’s clock is taken over where no ONLINE build is under way on the node table, as its session ended without giving it up |
| Item names | Recorded; the Oracle object’s name is derived from the graph, label and properties, and recorded with it. A drop drops the object the record names |
The store’s identity (DrivineStore) and the schema marker are nodes of the graph on Oracle too, and the graph’s tables are made for them when they are the first thing asked of a new graph.
Postgres. Every item is a partial index over the nodes of its label, recorded in <graph>_schema as on Oracle. An index dropped by hand is not listed, and is made again by the next ensure. The store’s identity and the schema marker are nodes of the graph, as on Oracle.
| Postgres | |
|---|---|
| Vector indexes | CREATE INDEX … USING hnsw ((CAST(CAST(props -> 'p' AS text) AS vector(n))) vector_cosine_ops) WHERE labels @> '["Label"]' AND …, over the embeddings of the label’s nodes that are of its size (vector_l2_ops for Euclidean). Needs pgvector, which the index makes where it may |
| Full-text indexes | CREATE INDEX … USING gin ((lower(…)) gin_trgm_ops) WHERE labels @> '["Label"]', over the text a search reads, with pg_trgm, which the index makes where it may |
| Range indexes | CREATE INDEX … ((props -> 'p')) WHERE labels @> '["Label"]', one per label: the property’s JSON, whose equality is Cypher’s, so a text equals only a text, a number a number of the same value, and a temporal value only the same value. Composite supported |
| TEXT indexes | Refused: Neo4j’s alone |
| Uniqueness | The same index made UNIQUE, which also finds a node, so no range index is made beside it. A node that lacks one of the properties is not constrained |
| Item names | Recorded; the index’s name is derived from the graph, label and properties, and Postgres keeps it in lower case. A drop drops the index the record names |
| Index builds | Each index, a uniqueness constraint’s too (CREATE UNIQUE INDEX CONCURRENTLY), is built CONCURRENTLY, so writes to the graph’s nodes go on while it is built (drivine-cypher-spec#381, #382); the index a recreate builds beside the old one holds writes until done. Ensures of one item take turns to build it, as replicas booting together do (drivine-cypher-spec#382): before it builds, an ensure claims its turn with a row of kind CLAIM:<kind> in the <graph>_schema table, and gives it up once it is done, made or failed. Where another session holds the turn, it waits for it, for 60 seconds at most, then reads the store again, and finds the item that session made; where the wait runs out, it goes on without its turn, said at INFO. A claim older than 60 seconds, with no online build under way on the node table, is taken over, as its session ended without giving it up. An ensure that finds another session’s build of the index under way waits for it and reads how it ended, and one Postgres cancels as a deadlock with another online build on the node table waits for that build to end and builds again. On the connection of a caller’s transaction, which Postgres refuses that on (25001), it is built by a plain CREATE INDEX, which holds writes until it is done, and so is each after it in that ensure, said once at WARN: ensure the schema outside a transaction to build online. A build cut short leaves the index invalid under its name, and the next ensure drops it and builds it again. A session that builds an index in parallel keeps a shared memory segment in /dev/shm for as long as it lives, which in a container’s 64 MB can leave too little for a later HNSW build. So the session an index or a uniqueness constraint is built on is closed after it, out of its HikariCP pool, whether the build passed or failed. Where it cannot be, as on a DataSource of another pool or on the connection of a caller’s transaction, the build runs with no parallel workers (max_parallel_maintenance_workers 0), and the session’s own setting is put back after |
The form of an item on Oracle, Postgres and SQLite
Section titled “The form of an item on Oracle, Postgres and SQLite”Each record in <graph>_schema says the form its item was made in, "form": 1 first in its details. A form is how a
version, or a library, writes an item’s DDL: the same item, of the same kind, label, properties and uniqueness, made
with other expressions. Drivine for TypeScript and drivine-python made Oracle’s labelled and unique indexes with other
expressions than drivine4j’s, under the same names; on Postgres and SQLite the three made every item alike. A listing of
range indexes or of constraints, and on Postgres and Oracle one of vector or full-text indexes, gives after the records a
row for each object under a name Drivine gives (pg_index on Postgres; user_indexes, the hidden columns’ expressions,
and the side tables’ columns and triggers on Oracle; sqlite_master on SQLite), still in one query, and ensure checks
each is the object it would make. An item is then one of five:
| Outcome | What it is | What happens |
|---|---|---|
| current | this version’s form | as before |
| stale | an earlier form, or TypeScript’s or Python’s Oracle form | Kept and used, AlreadyMatching, with one WARN: Oracle RANGE_INDEX on Person[name] is of another form than this version makes (form 1 expected, found form 0): it is kept and used as it is. SchemaManager.recreateAll("<owner>") makes it again. (Call recreate() to make it again. from the indexes and constraints managers). Never a problem, so FAIL_FAST fails no owner for it, and never written to the marker |
| newer | a form above this version’s, which a newer version wrote during a rolling deploy | Kept and used, AlreadyMatching, and checked on its structure only: an index, on the node table, as unique as the item, by the same method, and on Oracle a vector or full-text item’s index of its type on its table. One WARN, … was made by a newer version of Drivine (form 2; this version makes form 1): this version uses it as it is., with no recreate suggested, so an older version never drops a newer one’s index |
| unrecorded | on Oracle, an item drivine4j made before records said a form | The record gets a one-off {"form": 1}; the index isn’t touched |
| mismatch | another object under the name Drivine gives the item: an index on another table, or over another property or label, of another uniqueness, method, operator class or vector size, or something that isn’t an index | Drift, never Created, with a WARN that names it: Index drift on Coupon[serial]: DRIVINE_IX_SERIAL_CA01FDF4, an index Drivine didn't make, stands under its name for the RANGE_INDEX: it is an index over [couponRef], so it is not taken as made. Call recreate() to replace it (destructive). Under FAIL_FAST it fails its owner, and under WARN it is logged and the marker written |
A recreate of a mismatch (recreate(spec), recreate-on-drift, a changed version, recreateAll) drops the other
index by its name, says so, Dropped Oracle index DRIVINE_IX_SERIAL_CA01FDF4, an index Drivine didn't make under its name for RANGE_INDEX on Coupon[serial]: it was an index over [couponRef], at INFO, and makes the item. A uniqueness
constraint’s other index is dropped only once its own is built beside it (below),
so data the constraint refuses leaves it standing. What isn’t
an index, such as a table under the name, is never dropped: its WARN says Drop or rename it: Drivine makes the item under that name, and recreate() leaves it., and it stays drift: constraints.recreate(spec) gives Drift, and
indexes.recreate(spec) throws a DrivineException that says the same.
On Oracle an item with no record is read from its objects’ text: a range index’s labelled index, a constraint’s unique
index, or a vector or full-text index’s trigger. TypeScript’s or Python’s are kept as stale, and no record is written
over them; a recreate drops just the objects that showed that form, saying so as a mismatch’s drop is said, and makes
the item in form 1. A range index listed incomplete in another form is kept with its WARN, not completed in this
version’s form, so it is never reported Created.
Before this (liberation-data/drivine4j#770), Oracle read only the record and that an object of the recorded name was
there, and CREATE INDEX IF NOT EXISTS passed over the name, so an index of another shape under Drivine’s generated name
was reported Created, and a uniqueness constraint could go unenforced with nothing said. What a form is, and each of
these outcomes and lines, is the module’s (org.drivine.cypher.store.schema, SqlStoreSchema.formOf), pinned by the
spec’s store.yaml forms and plans.yaml case 30.
A uniqueness constraint made again on Oracle, Postgres and SQLite
Section titled “A uniqueness constraint made again on Oracle, Postgres and SQLite”Every recreate of a uniqueness constraint on Oracle, Postgres and SQLite (recreate(spec), recreateAll,
recreate-on-drift, a changed version, recreate-on-startup, a stale runtime item, a mismatch, an item of another form)
makes it again in its place, so data that it refuses never leaves its label with no unique index
(liberation-data/drivine-cypher-spec#135 §4):
- An index a recreate cut short left under the name it builds under first, the constraint’s index’s name and
_r, is dropped. - Where the constraint ignores case, the lowercased copies are filled in again, with the old index standing.
- The unique index is built under that name, beside the old one.
- It is swapped into the old one’s place: on Postgres one block drops the old index and renames the new; on Oracle the old is dropped and the new renamed; on SQLite, which renames no index, the old is dropped, the index made again under its name, and the one built first dropped.
- The record is written as one made anew, in the current form, keeping its aliases.
Data that refuses the build, or the refill of the copies, is a Violation, with its sample, as an ensure’s is: nothing
is swapped, and the old index and its record are as they were, the old index enforcing what it did. A refusal no key
that repeats bears out is thrown. A recreate cut off after its old index was dropped leaves only the index built first:
ensure and enforce keep it and use it, with one WARN, and the next recreate puts it in its place, saying so at INFO.
Oracle builds no second index over the same expressions (ORA-01408), so there a constraint’s index made as this
version makes it is dropped first and made again, said at INFO: the data it held unique is unique still, but for a write
in between. Over an index of another form, the same line is at WARN, since the data may repeat a key, and the label is
left with no unique index until the constraint is made. Neo4j, Memgraph and FalkorDB drop a constraint and then make it,
as before: Neo4j refuses a second constraint over the same schema, and none of them renames one.
What each step runs on each store is the module’s (org.drivine.cypher.store.ddl), pinned by the spec’s store.yaml
(each constraint case’s recreate); what is run when, and what is said, by plans.yaml case 31.
Neptune and generic openCypher have no schema management support — operations fail loudly rather than silently no-op.

