diff options
| author | 2022-06-25 01:35:34 +0200 | |
|---|---|---|
| committer | 2022-07-14 17:04:24 +0200 | |
| commit | 9d011583eaf01be6bdc8bd3b777fd7e3e2bbf572 (patch) | |
| tree | 3c19103447f17f87f16d56ecb79c32de836e7891 /query.zig | |
| parent | readme: fix allocator usage (diff) | |
| download | zig-sqlite-9d011583eaf01be6bdc8bd3b777fd7e3e2bbf572.tar.gz zig-sqlite-9d011583eaf01be6bdc8bd3b777fd7e3e2bbf572.tar.xz zig-sqlite-9d011583eaf01be6bdc8bd3b777fd7e3e2bbf572.zip | |
add a way to get the aggregate context with createAggregateFunction
The old way of working was that we always passed the user context as
first argument to both `step` and `finalize` functions and the caller
had no way of getting the aggregate context from
SQLite (http://www3.sqlite.org/c3ref/aggregate_context.html).
Now both `step` and `finalize` functions must have a first argument of type `FunctionContext`:
fn step(fctx: FunctionContext, input: u32) void {
var ctx = fctx.aggregateContext(*u32) orelse return;
ctx.* += input;
}
fn finalize(ctx: *u32) u32 {
var ctx = fctx.aggregateContext(*u32) orelse return 0;
return ctx.sum;
}
Fixes #89
Diffstat (limited to 'query.zig')
0 files changed, 0 insertions, 0 deletions