Skip to content

Commit

Permalink
Fixed call to final aggregate function when no step function was called
Browse files Browse the repository at this point in the history
  • Loading branch information
mmottl committed Mar 19, 2021
1 parent 6569f1b commit 1231d26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Fixed missing GC registration of init values in aggregate functions.

* Fixed call to final aggregate function when no step function was called.

* Fixed incorrect required minimum OCaml version (now 4.12).


Expand Down
11 changes: 8 additions & 3 deletions src/sqlite3_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1457,9 +1457,14 @@ static void caml_sqlite3_user_function_##NAME(sqlite3_context *ctx) \
agg_ctx *agg_ctx = sqlite3_aggregate_context(ctx, sizeof(agg_ctx)); \
value v_res; \
caml_leave_blocking_section(); \
v_res = caml_callback_exn(GET_FUN, agg_ctx->v_acc); \
set_sqlite3_result(ctx, v_res); \
REMOVE_ROOT; \
if (!agg_ctx->initialized) { \
v_res = caml_callback_exn(GET_FUN, Field(data->v_fun, 1)); \
set_sqlite3_result(ctx, v_res); \
} else { \
v_res = caml_callback_exn(GET_FUN, agg_ctx->v_acc); \
set_sqlite3_result(ctx, v_res); \
REMOVE_ROOT; \
} \
caml_enter_blocking_section(); \
}

Expand Down

0 comments on commit 1231d26

Please sign in to comment.