On 1/29/19 1:15 AM, Andy Goth wrote:
I wish to define custom aggregate functions in Tcl

Initial implementation:

https://chiselapp.com/user/andy/repository/sqlite-andy/info/e0689f05d1f8792d

Sample program, intended to be run from the root of a built SQLite tree:

#!/usr/bin/env tclsh load .libs/libtclsqlite3.so sqlite3 db db function incr -deterministic { apply {{arg} { incr arg }} } db function list -deterministic -aggregate { apply {{state args} { concat $state $args }} } puts [db eval { SELECT list(column1, ''), incr(42) FROM (VALUES ('#'), ('#'), (' c '), ('\'), ('\\'), ('{ xx '), ('}')) }] db close # vim: set sts=4 sw=4 tw=80 et ft=tcl:

Here's the output:

{{#} {} # {} { c } {} \\ {} {\\} {} \{\ xx\ {} \} {}} 43

Notice that the first # element is brace-quoted and the second one is not. This demonstrates TIP 401 compliance (http://tip.tcl.tk/401) in recent Tcl.

Before I can call this project finished, I need to update the test suite and documentation. But I didn't want to wait for that to release the code I've already written, so here you go.

As a separate project, I would like to improve the Tcl script dispatch. For several reasons, safeToUseEvalObjv() doesn't really meet its stated goal. I have a lot to say about this but should wait until another time to go into detail. Let's finish the aggregate function project first.

Another good follow-on project would be adding support for window functions. Before I can take that on, I need to gain some experience using, let alone writing, window functions.

--
Andy Goth | <andrew.m.goth/at/gmail/dot/com>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to