Hello !  

There is an user pointer that you pass and you can get it back using?
https://www.sqlite.org/c3ref/user_data.html !  

Cheers !  
>  Sat Mar 05 2016 9:22:23 pm CET CET from "Stephan Beal"
><sgbeal at googlemail.com>  Subject: [sqlite] How does your sqlite script
>binding handle aggregate UDFs?
>
>  Hi, all,
> 
> this question is aimed at any of you who have experience adding
> script-defined UDF support to sqlite/script bindings (regardless of the
> scripting language). Everyone can tap delete now :).
> 
> "i've got this friend" who has an sqlite3/script-language binding which (as
> of an hour or so ago) now allows sqlite UDFs to be created via script code,
> e.g.:
> 
> myDb.createUDF('myfunc', function(a,b) { return a+b });
> 
> it also does aggregates, but i've got questions about those...
> 
> Aggregates are _currently_ modeled as a single function which gets called
> just like normal function, but in the aggregate's "final" call the engine
> calls the aggregate function with no arguments (this is how the call knows
> it's the "final" one). The final call does any last-minute work returns
> whatever the accumulated value is. In pseudocode, such an aggregate
> callback might look like:
> 
> function aggregateCallback() {
> if no arguments then
> this is the final call. Return accumulated data.
> else
> this is a "normal" call. Accumulate/calculate/whatever. Result is
> ignored.
> end
> }
> 
> i'm not aware of any aggregates which (in normal use) take no arguments, so
> this "seems" kosher to me (i.e., i "don't think" the convention of passing
> no arguments for the final call is going to bite me). However, i'm
> envisioning corner cases involving resetting of the data accumulator
> (assuming a SUM-like aggregator). Specifically: if sqlite calls the
> aggregate's step() function once, and then is interrupted by an error
> triggered from another function in the same statement, the final() call for
> the aggregate will never(?) be made. i.e., the final() call cannot be
> reliably used as a place to initialize the aggregate before the _next_
> round of calls.
> 
> How are script bindings handling such situations? Where are they
> initializing and resetting any "accumulator data" in their aggregates?
> 
> Any insights and suggestions would be appreciated.
> 
> -- 
> ----- stephan beal
> http://wanderinghorse.net/home/stephan/
> http://gplus.to/sgbeal
> "Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
> those who insist on a perfect world, freedom will have to do." -- Bigby
>Wolf
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> 
>
>  



?

Reply via email to