aboutsummaryrefslogtreecommitdiffstats
path: root/lib/scl/executor.ml
blob: 3785c4a8311124042c37ac948c5718a5546bcfbb (plain) (blame)
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
let default_batch = 50

type cursor_batch = {
  cursor_id : string;
  rows : Tuple.materialized list;
  has_more : bool;
}

type exec_result =
  | Batch of cursor_batch
  | Closed of Sublanguage_types.transition_delta

module Make (NT : Nt.S) = struct
  module DrlExec = Drl.Executor.Make (NT)

  module Error = struct
    open Condition
    (* TODO: more structure *)
    let cursor_error msg = condition "cursor-error" ("message" |=| (of_string msg))
  end

  let ( let* ) = Result.bind

  let execute (ctx : Sublanguage_context.t) (stmt : Ast.statement) :
      (exec_result, Condition.t) result =
    ignore default_batch;
    match stmt with
    | Ast.Begin _ ->
        Error (Error.cursor_error "cursors not yet implemented")
    | Ast.Fetch _ ->
        Error (Error.cursor_error "cursors not yet implemented")
    | Ast.Close _ ->
        let* () = Ok () in
        Ok (Closed ctx.branch#multigroups)
end

module Memory = Make (Nt.Memory)