aboutsummaryrefslogtreecommitdiffstats
path: root/lib/scl
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-05-11 23:10:27 -0300
committerGitHub <noreply@github.com>2026-05-11 23:10:27 -0300
commite3d3e20dfea253de291d5b31059cd55c0eaabf02 (patch)
tree82cf0d46ea3768171c8a87630cab5011d1ccf2a1 /lib/scl
parent4fdf3392868c72ff4c33b70d165a177e97f2fece (diff)
downloadSakura-e3d3e20dfea253de291d5b31059cd55c0eaabf02.tar.gz
Sakura-e3d3e20dfea253de291d5b31059cd55c0eaabf02.zip
Multigroup unified reference for hierarchical access
Diffstat (limited to '')
-rw-r--r--lib/scl/executor.ml49
1 files changed, 9 insertions, 40 deletions
diff --git a/lib/scl/executor.ml b/lib/scl/executor.ml
index d48d852..7532eaa 100644
--- a/lib/scl/executor.ml
+++ b/lib/scl/executor.ml
@@ -6,10 +6,7 @@ type cursor_batch = {
has_more : bool;
}
-type exec_result = Batch of cursor_batch | Closed of Management.Database.t
-
-let sessions : Session.t option ref = ref None
-let set_sessions s = sessions := Some s
+type exec_result = Batch of cursor_batch | Closed of Management.Multigroup.multigroup
module Make (Storage : Management.Physical.S) = struct
module DrlExec = Drl.Executor.Make (Storage)
@@ -27,46 +24,18 @@ module Make (Storage : Management.Physical.S) = struct
| QueryError e -> DrlExec.sexp_of_error e
| CursorError s -> List [ Atom "cursor-error"; Atom s ]
- let get_sessions () =
- match !sessions with
- | Some s -> Ok s
- | None ->
- Error
- (CursorError
- "The session registry has not been initialised; ensure \
- `set_sessions` is called at startup.")
-
let ( let* ) = Result.bind
- let execute (storage : Storage.t) (db : Management.Database.t)
+ let execute (_storage : Storage.t) (db : Management.Multigroup.multigroup)
(stmt : Ast.statement) : (exec_result, error) result =
+ ignore default_batch;
match stmt with
- | Ast.Begin { query; limit } ->
- let* reg = get_sessions () in
- let* rel =
- DrlExec.execute storage db query
- |> Result.map_error (fun e -> QueryError e)
- in
- let gen = Alg.to_generator storage rel in
- let query_str = Drl.Parser.to_string query in
- let cur = Session.register reg ~db ~query:query_str ~generator:gen in
- let batch = Option.value ~default:default_batch limit in
- let* rows, has_more =
- Session.fetch reg ~id:cur.Session.id ~limit:batch
- |> Result.map_error (fun s -> CursorError s)
- in
- Ok (Batch { cursor_id = cur.Session.id; rows; has_more })
- | Ast.Fetch { cursor; limit } ->
- let* reg = get_sessions () in
- let batch = Option.value ~default:default_batch limit in
- let* rows, has_more =
- Session.fetch reg ~id:cursor ~limit:batch
- |> Result.map_error (fun s -> CursorError s)
- in
- Ok (Batch { cursor_id = cursor; rows; has_more })
- | Ast.Close { cursor } ->
- let* reg = get_sessions () in
- Session.close reg ~id:cursor;
+ | Ast.Begin _ ->
+ Error (CursorError "cursors not yet implemented")
+ | Ast.Fetch _ ->
+ Error (CursorError "cursors not yet implemented")
+ | Ast.Close _ ->
+ let* () = Ok () in
Ok (Closed db)
end