Re: [sqlite] Custom aggregate functions in Tcl

2019-02-02 Thread Andy Goth
I made many updates to my implementation, which can be found here: https://chiselapp.com/user/andy/repository/sqlite-andy/timeline?r=andygoth-tcl-function https://chiselapp.com/user/andy/repository/sqlite-andy/artifact?fn=src/tclsqlite.c&ci=andygoth-tcl-function https://chiselapp.com/user/andy/re

Re: [sqlite] Custom aggregate functions in Tcl

2019-01-31 Thread Andy Goth
I read some more about window functions and now see more clearly that they are an extension to aggregate functions. Now I understand why it makes sense to have a method name for both aggregate and window functions. I'll also go ahead and put window function support in my code next chance I get, rat

Re: [sqlite] Custom aggregate functions in Tcl

2019-01-30 Thread Andy Goth
On 1/30/19 3:27 PM, Andy Goth wrote: The next chance I get (probably tomorrow morning), I'll go ahead and add "step" or "final" as the initial argument to aggregate functions. I'll also lift the prohibition on aggregate functions with no arguments. This change is now committed. https://chisel

Re: [sqlite] Custom aggregate functions in Tcl

2019-01-30 Thread Andy Goth
On 1/30/19 1:59 PM, Richard Hipp wrote: It seems that you distinguish between the xStep and xFinal methods by the number of argments. xStep [has] 1+N argument (where N is the number of function parameters) and xFinal has just 1. Yes. I was explicit about that in my first email. Dan suggests

Re: [sqlite] Custom aggregate functions in Tcl

2019-01-30 Thread Richard Hipp
It seems that you distinguish between the xStep and xFinal methods by the number of argments. xStep as 1+N argument (where N is the number of function parameters) and xFinal has just 1. Dan suggests (and I agree) that this will not extend well to window functions. It might be better to have an i

Re: [sqlite] Custom aggregate functions in Tcl

2019-01-30 Thread Andy Goth
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 .l

Re: [sqlite] Custom aggregate functions in Tcl

2019-01-29 Thread Gerry Snyder
I hope your work makes into the SQLite source code. It will be useful. Gerry Snyder On Tue, Jan 29, 2019 at 12:16 AM Andy Goth wrote: > I wish to define custom aggregate functions in Tcl, but this capability is > currently not exposed through the Tcl interface. Thus I am thinking about > how be

Re: [sqlite] Custom aggregate functions in Tcl

2019-01-29 Thread Andy Goth
Oh yeah, I meant to say that I was going to leave window functions for future expansion. First I need to get more familiar with their use. Yesterday was my first time implementing an aggregate function, and I need to work my way up. On Tue, Jan 29, 2019, 07:46 Richard Hipp On 1/29/19, Andy Goth

Re: [sqlite] Custom aggregate functions in Tcl

2019-01-29 Thread Richard Hipp
On 1/29/19, Andy Goth wrote: > > Question: does xFinal() get called if an error occurs during (or between) > calling xStep()? Are errors even possible? I'm curious if there's any way > to leak the Tcl_Obj pointed to by the aggregate context. xFinal() gets called by sqlite3_reset() or sqlite3_fina

[sqlite] Custom aggregate functions in Tcl

2019-01-28 Thread Andy Goth
I wish to define custom aggregate functions in Tcl, but this capability is currently not exposed through the Tcl interface. Thus I am thinking about how best to add it. Here's a first crack at a design proposal: Extend the [db function] command to accept an -aggregate switch that makes the new fun