{
  "slug": "sqlite-collation",
  "term": "SQLite collation",
  "aliases": [
    "SQLite collating sequence",
    "application-defined collation"
  ],
  "definition": "A SQLite collation is a named text-comparison rule used to determine ordering and equality in database operations.",
  "note": "Application-defined collations are registered on a connection. A shared name does not guarantee that two application versions use identical comparison rules; an existing index can disagree with a changed rule. [collation-api]\n\nRebuilding an index under the intended comparator can restore consistency, but changing equality can also make existing keys collide. In a two-row control, A and a became equal and rebuilding the UNIQUE index failed with SQLITE_CONSTRAINT_UNIQUE. The rolled-back fixture retained both rows and its original hash. [reindex] [experiment]\n\nTable layout changes the available validation path. In SQLite 3.45.1 and 3.54.1 WITHOUT ROWID controls, normal equality queries and NOT INDEXED variants both reported primary-key searches and shared wrong empty answers after an order reversal. The primary-key tree stores the table rows; agreement was not an independent correctness check. [without-rowid-doc] [layout-evidence]\n\nREINDEX main.sample restored every tested order-reversal fixture on a disposable copy, including WITHOUT ROWID. Equality stayed unchanged, unlike the separate UNIQUE-collision control. A unary-plus scan exposed the missing rows with TEXT-bound keys, but unary plus also removes affinity and can change other comparisons. Verify the expected rows and query semantics instead of treating NOT INDEXED as a universal scan guarantee. [unary-affinity] [layout-evidence]\n\nA SCAN report can describe traversal of index storage, not a separate physical structure. The expected row set supplies the correctness oracle in these fixtures. EXPLAIN QUERY PLAN is a version-sensitive diagnostic, not a stable machine interface. [eqp-scope]",
  "related": [
    "sqlite-expression-index",
    "sqlite-quick-check",
    "backup-verification"
  ],
  "citations": [
    {
      "id": "collation-api",
      "title": "SQLite C API: Define New Collating Sequences",
      "url": "https://sqlite.org/c3ref/create_collation.html",
      "accessed": "2026-10-18"
    },
    {
      "id": "reindex",
      "title": "SQLite REINDEX: rebuild scope and name resolution",
      "url": "https://www.sqlite.org/lang_reindex.html",
      "accessed": "2026-10-18"
    },
    {
      "id": "experiment",
      "title": "Hesela: SQLite index runtime experiment",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/",
      "accessed": "2026-10-18"
    },
    {
      "id": "without-rowid-doc",
      "title": "SQLite WITHOUT ROWID: table storage and primary-key structure",
      "url": "https://sqlite.org/withoutrowid.html",
      "accessed": "2026-10-22"
    },
    {
      "id": "unary-affinity",
      "title": "SQLite optimizer overview, section 8.1: unary plus removes affinity",
      "url": "https://sqlite.org/optoverview.html#disqualifying_where_clause_terms_using_unary_",
      "accessed": "2026-10-22"
    },
    {
      "id": "layout-evidence",
      "title": "Hesela: WITHOUT ROWID access-path observations and controls",
      "url": "https://hesela.dev/research/sqlite-without-rowid-collation/README.md",
      "accessed": "2026-10-23"
    },
    {
      "id": "eqp-scope",
      "title": "SQLite EXPLAIN QUERY PLAN: scan semantics and unstable diagnostic format",
      "url": "https://sqlite.org/eqp.html",
      "accessed": "2026-10-22"
    }
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-23",
  "provenance": [
    "Constructed fixtures on SQLite 3.45.1; callback changes deliberately violate existing index assumptions. No defect, incident-rate or cross-platform migration claim.",
    "48 retained states and 720 point lookups plus 24 affinity lookups across SQLite 3.45.1 and 3.54.1 on one Linux host; identical designed matrix, not independent incidents. Comparator order deliberately reversed without changing equality."
  ]
}
