quinnj/SQLite.jl — pull request #54 by Sean1708 (2014-12-07 20:38:17+00:00)
Title: Aggregate functions (finally!).

This is definitely far from finished but the good news is, it works. The bad news is, the implementation is horrifically vile, basically a huge hack full of `unsafe_copy!`s to get round the garbage collector. I'll keep working on it over the next couple of days but I thought I'd let you have a look, see if anything jumps out at you.

The basic idea is that an integer and a pointer are stored contiguously in the buffer returned by `sqlite3_aggregate_context`. The pointer points to a bytearray (allocated with `c_malloc` so that the garbage collector doesn't free it when the step function finishes executing) which contains the serialized value returned from the user's step function. The integer just stores the length of this bytearray.

As I say, I'll keep working on it over the next couple of days.