Skip to Content
Motoko

Schema

  • Records are JSON text in LONGTEXT: MySQL's JSON type rewrites the text (key order, numbers), and TEXT holds only 64 KB. pi-durable's JSON-encoded lone surrogates and NUL are stored as written.
  • Indexed strings hold the JSON encoding of the string in utf8mb4_0900_bin columns, which compare and order by the bytes of their UTF-8 encoding and pad nothing ('a' and 'a ' differ). An InnoDB index key holds at most 3072 bytes, 4 per character, so each has the length its indexes leave it, in characters of its JSON encoding (INDEXED_LENGTHS): a task's kind and a submission's request ID 760, a document's kind 256 and its key 500. A commit that holds a longer one rejects before it writes anything.
  • A scope's kind and name hold up to 1024 characters each, which no index key fits: their unique key is a generated scope_key, the SHA-256 of the kind, a NUL and the name.
  • The lease's expiry and every time are DATETIME(3) in UTC by the database clock (UTC_TIMESTAMP(3)), which no session time_zone converts. Drizzle reads them as UTC too.
  • Integers are BIGINT and at most 2^53.
  • MySQL has no partial index: generated columns stand in for Postgres's (unfinished on the scopes, marker_id on the entries).

What needs which MySQL version (the package is tested on 8.4.13, 8.0.46 and 8.0.24):

FeatureSince
Altering a table with an expression default (the init migration's CREATE INDEX on the scopes)8.0.24
Table value constructors (VALUES ROW(...), a write's rows)8.0.19
utf8mb4_0900_bin (byte order, no padding)8.0.17
Enforced CHECK constraints8.0.16
LATERAL derived tables (an entry scan, a document read)8.0.14
Expression defaults (DEFAULT (UTC_TIMESTAMP(3)))8.0.13
JSON_TABLE (a commit's read)8.0.4
The SET_VAR hint (fork chains deeper than 1000)8.0.3
Recursive CTEs (fork chains, erase)8.0.1

Before 8.0.24, MySQL refuses any ALTER TABLE or CREATE INDEX on a table that has a NOT NULL column with an expression default, with Invalid default value for 'created_at'. The init migration creates the scopes with created_at DEFAULT (UTC_TIMESTAMP(3)) and indexes them after, so it stops there.

MySQL 8.4 plans chain JOIN LATERAL (... LIMIT 1) ORDER BY ord LIMIT 1 by keeping one row of the chain before the join, which finds nothing past the first fork segment. The storage never writes that shape; the code says where it would.