aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nt.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-07-06 22:46:09 -0300
committerGitHub <noreply@github.com>2026-07-06 22:46:09 -0300
commitbe375a52da6174dfda5b68617d27e1542cc80499 (patch)
tree129119f2b01a672addf88d698e259c0a44105576 /lib/nt.ml
parentc284fcd570342c31bc21169960579a20a763e32e (diff)
downloadSakura-be375a52da6174dfda5b68617d27e1542cc80499.tar.gz
Sakura-be375a52da6174dfda5b68617d27e1542cc80499.zip
Fix memory layout and populate attributes for join on clauseHEADmaster
Diffstat (limited to '')
-rw-r--r--lib/nt.ml14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/nt.ml b/lib/nt.ml
index d526428..15e9f61 100644
--- a/lib/nt.ml
+++ b/lib/nt.ml
@@ -298,7 +298,7 @@ module Make (B : Backend) = struct
match Nt_ffi.ptr_to_opt raw with
| None -> Error (Error.cursor_error ("plan_scan failed for path: " ^ path))
| Some p -> Ok p )
- | Join {left; right; _} -> (
+ | Join {left; right; on_attrs} -> (
let* lp = build_plan left in
match build_plan right with
| Error e ->
@@ -309,8 +309,18 @@ module Make (B : Backend) = struct
let join = getf act Nt_ffi.action_join in
setf join Nt_ffi.join_left (Nt_ffi.nint_to_ptr lp);
setf join Nt_ffi.join_right (Nt_ffi.nint_to_ptr rp);
+ (* NULL-terminated const char**; backing arrays stay reachable until
+ assemble returns *)
+ let cattrs = List.map Nt_ffi.cstring on_attrs in
+ let arr =
+ Ctypes.CArray.of_list (Ctypes.ptr Ctypes.char)
+ (List.map Ctypes.CArray.start cattrs @ [Nt_ffi.null_char_ptr])
+ in
+ setf join Nt_ffi.join_attrs (Ctypes.CArray.start arr);
(* assemble takes ownership of both children *)
- match Nt_ffi.ptr_to_opt (Nt_ffi.rnt_plan_assemble act) with
+ let raw = Nt_ffi.rnt_plan_assemble act in
+ ignore (Sys.opaque_identity (cattrs, arr));
+ match Nt_ffi.ptr_to_opt raw with
| None -> Error (Error.cursor_error "plan_join failed")
| Some p -> Ok p ) )
| Take {limit; source} -> (