[sqlite] User-defined SQL functions

2016-02-23 Thread Dan Kennedy
On 02/23/2016 07:36 PM, E.Pasma wrote: > 22 feb 2016, Dan Kennedy: > >> On 02/23/2016 01:33 AM, E.Pasma wrote: >>> >>> I reproduced the memory leak and added a test in the sql script. >>> An alternative fix, instead of adding the missing break, is: >>> >>> case SQLITE_TEXT: >>> case SQL

[sqlite] User-defined SQL functions

2016-02-23 Thread E.Pasma
23 feb 2016, Dan Kennedy: > On 02/23/2016 07:36 PM, E.Pasma wrote: >> 22 feb 2016, Dan Kennedy: >> >>> On 02/23/2016 01:33 AM, E.Pasma wrote: I reproduced the memory leak and added a test in the sql script. An alternative fix, instead of adding the missing break, is:

[sqlite] User-defined SQL functions

2016-02-23 Thread E.Pasma
22 feb 2016, Dan Kennedy: > On 02/23/2016 01:33 AM, E.Pasma wrote: >> >> I reproduced the memory leak and added a test in the sql script. >> An alternative fix, instead of adding the missing break, is: >> >> case SQLITE_TEXT: >> case SQLITE_BLOB: >> pval->n=sqlite3_value_bytes(

[sqlite] User-defined SQL functions

2016-02-23 Thread Dan Kennedy
On 02/23/2016 01:33 AM, E.Pasma wrote: > > I reproduced the memory leak and added a test in the sql script. > An alternative fix, instead of adding the missing break, is: > >case SQLITE_TEXT: >case SQLITE_BLOB: > pval->n=sqlite3_value_bytes(arg); > if (!pval->n) {

[sqlite] User-defined SQL functions

2016-02-22 Thread E.Pasma
Hi, forget to mention that a function like this was earlier considered as being tricky and living dangerously. Also we found a bug (missing break) between line 80 and 81 which will lead to a memory leak every time a text value is stored ... switch (pval->t) { case SQLITE_INTEGER:

[sqlite] User-defined SQL functions

2016-02-22 Thread E.Pasma
21 feb 2016, Igor Tandetnik: > On 2/21/2016 12:09 PM, Olivier Mascia wrote: >> Is it possible to implement a SQL function >> (https://www.sqlite.org/c3ref/create_function.html >> ), which implementation would be able to return the same value for >> the duration of the current transaction? >> >

[sqlite] User-defined SQL functions

2016-02-22 Thread Keith Medcalf
n=0; pval->r=sqlite3_value_double(arg); break; } } > -Original Message- > From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users- > bounces at mailinglists.sqlite.org] On Behalf Of E.Pasma > Sent: Monday, 22 February, 2016

[sqlite] User-defined SQL functions

2016-02-21 Thread Olivier Mascia
> Le 21 f?vr. 2016 ? 22:35, Keith Medcalf a ?crit : > > Of course it is. > > The function merely needs to store a value associated with a connection if > the value does not exist (for that connection) when it is called and use a > commit_hook and rollback_hook so that it knows when it needs to

[sqlite] User-defined SQL functions

2016-02-21 Thread Olivier Mascia
Stephan, > Le 21 f?vr. 2016 ? 18:22, Stephan Beal a ?crit : > > This _might_ suffice for you, but maybe not: the SQLITE_DETERMINISTIC flag > for sqlite3_create_function(). > > Copied from the header file: > > > ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC] > ** to s

[sqlite] User-defined SQL functions

2016-02-21 Thread Richard Hipp
On 2/21/16, Olivier Mascia wrote: > > The way I had read that documentation is: if your function is meant to be > deterministic, returning the same result for the very same input, at least > for the duration of the SQL statement (or of course always), then you should > tag it as SQLITE_DETERMINIST

[sqlite] User-defined SQL functions

2016-02-21 Thread Stephan Beal
On Sun, Feb 21, 2016 at 6:09 PM, Olivier Mascia wrote: > Dear all, > > Is it possible to implement a SQL function ( > https://www.sqlite.org/c3ref/create_function.html), which implementation > would be able to return the same value for the duration of the current > transaction? > This _might_ su

[sqlite] User-defined SQL functions

2016-02-21 Thread Olivier Mascia
Dear all, Is it possible to implement a SQL function (https://www.sqlite.org/c3ref/create_function.html), which implementation would be able to return the same value for the duration of the current transaction? In other words, assume I'd like to implement some function which I could name 'now(

[sqlite] User-defined SQL functions

2016-02-21 Thread Keith Medcalf
list > Subject: [sqlite] User-defined SQL functions > > Dear all, > > Is it possible to implement a SQL function > (https://www.sqlite.org/c3ref/create_function.html), which implementation > would be able to return the same value for the duration of the current > trans

[sqlite] User-defined SQL functions

2016-02-21 Thread Igor Tandetnik
On 2/21/2016 12:09 PM, Olivier Mascia wrote: > Is it possible to implement a SQL function > (https://www.sqlite.org/c3ref/create_function.html), which implementation > would be able to return the same value for the duration of the current > transaction? > > In other words, assume I'd like to imp