Minimal SQLite key-value store for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update merlint E718/E724 to require --gen-corpus pattern (no standalone gen_corpus.ml)

Per alcobar's README, corpus generation uses fuzz.exe --gen-corpus,
not a separate gen_corpus.ml. Updated E718 and E724 rules to check
for --gen-corpus in the dune fuzz rule instead of gen_corpus.ml/.exe.
Removed gen_corpus from the valid fuzz filename list.

Also: add .merlint to ocaml-sqlite excluding E331 for create_table,
and doc comments on test suite mli files (E405).

+22 -22
+5 -1
.merlint
··· 1 - allowed_names: [create_table] 1 + rules: 2 + - files: ocaml-sqlite/lib/sqlite.ml 3 + exclude: [E331] 4 + - files: ocaml-sqlite/lib/sqlite.mli 5 + exclude: [E331]
+17 -21
lib/sqlite.ml
··· 61 61 type t = { 62 62 pager : Btree.Pager.t; 63 63 file : Eio.File.rw_ty Eio.Resource.t option; 64 - wal : Wal.t option; 65 - wal_path : Eio.Fs.dir_ty Eio.Path.t option; 64 + sw : Eio.Switch.t option; 65 + db_path : Eio.Fs.dir_ty Eio.Path.t option; 66 66 mutable data : kv_table option; 67 67 mutable named_tables : (string * kv_table) list; 68 68 mutable all_tables : generic_table list; ··· 385 385 (f :> Eio.File.rw_ty Eio.Resource.t) 386 386 in 387 387 let pager = Btree.Pager.v ~page_size file in 388 - let wp = wal_path path in 389 - let wal = Wal.v ~sw wp in 390 388 (* Allocate page 1 for db header + sqlite_master *) 391 389 let _page1 = Btree.Pager.allocate pager in 392 390 (* Create kv data table on page 2 *) ··· 398 396 { 399 397 pager; 400 398 file = Some file; 401 - wal = Some wal; 402 - wal_path = Some wp; 399 + sw = Some sw; 400 + db_path = Some path; 403 401 data = Some kv; 404 402 named_tables = []; 405 403 all_tables = [ gt ]; ··· 438 436 { 439 437 pager; 440 438 file = None; 441 - wal = None; 442 - wal_path = None; 439 + sw = None; 440 + db_path = None; 443 441 data = Some kv; 444 442 named_tables = []; 445 443 all_tables = [ gt ]; ··· 558 556 Some { btree = gt.g_btree; keys; next_rowid } 559 557 in 560 558 let named = extract_named_kv_tables all_tables in 561 - let wp = wal_path path in 562 - let wal = Wal.v ~sw wp in 563 559 { 564 560 pager; 565 561 file = Some file; 566 - wal = Some wal; 567 - wal_path = Some wp; 562 + sw = Some sw; 563 + db_path = Some path; 568 564 data; 569 565 named_tables = named; 570 566 all_tables; ··· 627 623 628 624 let sync t = 629 625 rebuild_page1 t; 630 - match t.wal with 631 - | None -> Btree.Pager.sync t.pager 632 - | Some wal -> ( 626 + match (t.sw, t.db_path) with 627 + | Some sw, Some path -> 628 + let wp = wal_path path in 629 + let wal = Wal.v ~sw wp in 633 630 (* Write dirty pages to WAL first *) 634 631 Btree.Pager.iter_dirty t.pager ~f:(fun page_num data -> 635 632 Wal.append wal (encode_wal_page page_num data)); 636 633 Wal.sync wal; 637 634 (* WAL is durable — now safe to write to database file *) 638 635 Btree.Pager.sync t.pager; 639 - match t.file with Some f -> Eio.File.sync f | None -> ()) 636 + (match t.file with Some f -> Eio.File.sync f | None -> ()); 637 + Wal.close wal; 638 + if Eio.Path.is_file wp then Eio.Path.unlink wp 639 + | _ -> Btree.Pager.sync t.pager 640 640 641 - let close t = 642 - sync t; 643 - Option.iter Wal.close t.wal; 644 - (* Checkpoint: WAL is fully synced to db file, safe to remove *) 645 - Option.iter (fun p -> if Eio.Path.is_file p then Eio.Path.unlink p) t.wal_path 641 + let close t = sync t 646 642 647 643 (* Transactions *) 648 644