Skip to content

Instantly share code, notes, and snippets.

@indutny
Last active February 3, 2023 05:30
Show Gist options
  • Save indutny/2ae1d7ac06b06c0abf6671900e4ea443 to your computer and use it in GitHub Desktop.
Save indutny/2ae1d7ac06b06c0abf6671900e4ea443 to your computer and use it in GitHub Desktop.
Relatively Small Repro for Crashing FTS5 in Sqlite
CREATE VIRTUAL TABLE x USING fts5(content);
INSERT INTO x(x, rank) VALUES('pgsz', 32);
# Repeat next three lines 2000 times
INSERT INTO x(content) VALUES('hello world');
INSERT INTO x(content) VALUES('how are you');
INSERT INTO x(x, rank) VALUES('optimize', 1);
# If you repeat them less - you can below to see
# what's actually going in the FTS5 index.
SELECT fts5_decode(rowid, block) FROM x_data WHERE rowid IS 10;
{structure} {lvl=0 nMerge=0 nSeg=0} {lvl=1 nMerge=0 nSeg=0} {lvl=2 nMerge=0 nSeg=0} {lvl=3 nMerge=0 nSeg=0} {lvl=4 nMerge=0 nSeg=0} {lvl=5 nMerge=0 nSeg=0} {lvl=6 nMerge=0 nSeg=0} {lvl=7 nMerge=0 nSeg=1 {id=4 leaves=1..4}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment