package granary
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Pure-OCaml SQL engine
Install
dune-project
Dependency
Authors
Maintainers
Sources
0.0.3.tar.gz
sha256=8b18780ea373be48301d9f333925860a2f9110fc0ac28684295118d72b65a67e
sha512=25ca3c9c5e2b528704a542502e0f37dc33ba003f65622d969b8c2b800778585f8ef0cf89b36e6679832e3993e8303aecddfc662742baf7044d6afe4a796b8f11
doc/src/granary.unix/granary_unix.ml.html
Source file granary_unix.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87(* Unix platform driver for granary (#170): file-backed database constructors plus the file provider that powers ATTACH and VACUUM on the otherwise platform-agnostic core. The core libraries (block/store/db) carry no [unix] dependency; this driver supplies the Unix-specific pieces. *) open Lwt.Syntax module Unix_file = Unix_file module Fault_inject = Fault_inject module Store = Store (* The process-wide provider the core uses for ATTACH and VACUUM. VACUUM passes the source database's geometry (#176) so the rebuilt file keeps its page_size and reserved bytes; opening an existing file (ATTACH, vacuum reopen) ignores it and peeks the header instead. *) let provider : Granary.Db.file_provider = { Granary.Db.open_store = (fun ?geom ?as_of_history ~path () -> match geom with | None -> Store.open_file ?as_of_history ~path () | Some g -> Store.open_file ?as_of_history ~page_size:g.Granary_storage.Geometry.page_size ~reserved_bytes_per_page:g.Granary_storage.Geometry.reserved_bytes_per_page ~explicit_geometry:true ~path ()) ; remove_file = (fun p -> try Unix.unlink p with | Unix.Unix_error _ -> ()) ; rename_file = Unix.rename } ;; let install () = Granary.Db.set_file_provider provider let to_db ?clock ?durability ~path = function | Error e -> Lwt.return (Error (Granary.Db.Runtime (Format.asprintf "%a" Granary_store.Store.pp_error e))) | Ok store -> let* db = Granary.Db.of_store ?clock ?durability ~file_path:path store in Lwt.return (Ok db) ;; let open_file ?page_size ?reserved_bytes_per_page ?clock ?as_of_history ~path () = install (); let explicit_geometry = page_size <> None || reserved_bytes_per_page <> None in let* r = Store.open_file ?page_size ?reserved_bytes_per_page ?as_of_history ~explicit_geometry ~path () in to_db ?clock ~path r ;; let open_file_wal ?page_size ?reserved_bytes_per_page ?clock ?durability ?as_of_history ~path () = install (); let explicit_geometry = page_size <> None || reserved_bytes_per_page <> None in let* r = Store.open_file_wal ?page_size ?reserved_bytes_per_page ?as_of_history ~explicit_geometry ~path () in to_db ?clock ?durability ~path r ;; [@@@ai_disclosure "ai-generated"] [@@@ai_model "claude-opus-4-7"] [@@@ai_provider "Anthropic"]
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>