Minimal SQLite key-value store for OCaml
0
fork

Configure Feed

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

Fix orphan user rows on concurrent OAuth identity race

create_user now catches Unique_violation from the identity insert and
deletes the just-inserted user row before re-raising. Added delete_row
to ocaml-sqlite for generic table row deletion (with index cleanup).

+20
+15
lib/sqlite.ml
··· 937 937 gt.g_unique_indexes; 938 938 rowid 939 939 940 + let delete_row t ~table:name rowid = 941 + let gt = table t name in 942 + (* Remove from unique indexes first *) 943 + (match Btree.Table.find gt.g_btree rowid with 944 + | None -> () 945 + | Some payload -> 946 + let values = Btree.Record.decode payload in 947 + let values = fixup_values ~schema:gt.g_schema ~rowid values in 948 + List.iter 949 + (fun ui -> 950 + let key = encode_index_key ui values in 951 + Btree.Index.delete ui.ui_btree key) 952 + gt.g_unique_indexes); 953 + Btree.Table.delete gt.g_btree rowid 954 + 940 955 (* Namespaced Tables *) 941 956 942 957 module Table = struct
+5
lib/sqlite.mli
··· 138 138 @raise Failure if the table doesn't exist. 139 139 @raise Unique_violation if the row violates a [UNIQUE] constraint. *) 140 140 141 + val delete_row : t -> table:string -> int64 -> unit 142 + (** [delete_row t ~table rowid] deletes the row with the given [rowid] from 143 + [table]. No-op if the rowid doesn't exist. 144 + @raise Failure if the table doesn't exist. *) 145 + 141 146 (** {1 Schema Parsing} *) 142 147 143 148 val parse_create_table : string -> column list