I've just figured out that sqlite3_get_auxdata() and
sqlite3_set_auxdata() are designed to be used only with scalar user
defined functions.  If they are used with aggregate functions, they
cause sporadic and mysterious segfaults.  In particular, VdbeFunc
within the context is not initialized for aggregate functions, so
get_auxdata() will occasionally return random garbage.

This is mentioned in the comments in sqlite.h.in, but it took me a
while to see it.  I offer this more as a hint to future unwary SQLite
hackers searching the archives than as a bug report.  On the bright
side, both functions appear to work excellently when used (as
designed) with scalar functions.   A work around for aggregate
functions is (presumably) to use sqlite3_aggregate_context().

--nate


Reply via email to