Re: [sqlite] two threads block eachother opening db (WAL)

2018-07-02 Thread Rowan Worth
On 2 July 2018 at 23:32, Charles Samuels wrote: > I have found that when my process has a lot of threads each of which opens > a > DIFFERENT database, they each block on eachother while opening each > database. > > This is at least on conflict with the documentation, as the documentation >

Re: [sqlite] Segfault in window function

2018-07-02 Thread Charles Leifer
Beautiful, working on my end now as well. Thanks so much. On Mon, Jul 2, 2018 at 12:49 PM, Dan Kennedy wrote: > On 07/02/2018 10:54 PM, Charles Leifer wrote: > >> I'm getting a segfault with the following query, which uses window >> functions: >> > > Thanks for reporting this. Should now be

Re: [sqlite] Window Function Crash -- overriding builtin aggregate

2018-07-02 Thread Keith Medcalf
Dan, Yes, the exact query looks like this: with gsrange(f, t) as (values(1, 10)) select if(value == f, null, value-1) as rowvalue_1, value as rowvalue_2, if(value == t, null, value+1) as rowvalue_3, if(value == f or value == t, (if(value == f, 0, value-1) + value

Re: [sqlite] New WIndow Functions ... question

2018-07-02 Thread Dan Kennedy
On 07/02/2018 06:20 AM, Keith Medcalf wrote: They are part of the current draft release: http://www.sqlite.org/draft/releaselog/3_25_0.html Dan, I see that there is a new create function to create the window functions which have some slight changes to the methods being called and what they

Re: [sqlite] Typo in window function docs

2018-07-02 Thread Dan Kennedy
On 07/02/2018 03:14 PM, Domingo Alvarez Duarte wrote: Hello ! This sql example on the new window function docs is missing the parenthesis on the "rank" function: Thanks for pointing this out. New version uploaded now. Dan. === SELECT x, y, row_number() OVER*win1*, rank OVER*win2*

Re: [sqlite] Segfault in window function

2018-07-02 Thread Dan Kennedy
On 07/02/2018 10:54 PM, Charles Leifer wrote: I'm getting a segfault with the following query, which uses window functions: Thanks for reporting this. Should now be fixed here: https://www.sqlite.org/src/info/693b4350d7413912 Thanks also for the sum() bug report in the follow-up. That one

Re: [sqlite] Time Precision

2018-07-02 Thread dmp
> Igor wrote: > select (julianday('now') - julianday('1970-01-01'))*24*60*60*1000 > Keith wrote: > select (julianday() - 2440587.5) * 86400.0 Both of these got me on my way, Igor's a little more clearer. I'll doing a little more checking to insure the solution below is correct, but seems good.

Re: [sqlite] Window Function Crash -- overriding builtin aggregate

2018-07-02 Thread Dan Kennedy
On 07/02/2018 01:40 PM, Keith Medcalf wrote: I have overridden the builtin AVG function with a function of my own that computes the average by using the "running average" method rather than the simple sum/count method. This function is registered as an old fashioned aggregate function. After

Re: [sqlite] insert or replace performance with self "references" column

2018-07-02 Thread Simon Slavin
On 2 Jul 2018, at 2:45pm, Allen wrote: > My C program was creating a "Parent_Index" on two different tables, so > the second Parent_Index on the Transactions table was not being > created, and this was causing the "replace" to do a table scan. I > solved the problem by making the index names

Re: [sqlite] Segfault in window function

2018-07-02 Thread Charles Leifer
Furthermore, I've found another example of a window function returning incorrect results. Using the above "sample" table and sample data, the following query produces the wrong results. Query: SELECT "counter", "value", SUM("value") OVER (ORDER BY "id" ROWS 2 PRECEDING) FROM "sample" ORDER BY

Re: [sqlite] Segfault in window function

2018-07-02 Thread Charles Leifer
Oh, and gdb is reporting the segfault occurs in "dupedExprSize". Partial traceback: #0 0x74d4645b in dupedExprSize () from /usr/local/lib/libsqlite3.so.0 No symbol table info available. #1 0x74d5bf12 in exprDup () from /usr/local/lib/libsqlite3.so.0 No symbol table info

[sqlite] Segfault in window function

2018-07-02 Thread Charles Leifer
I'm getting a segfault with the following query, which uses window functions: SELECT "t1"."counter", "t1"."value", RANK() OVER w AS "rank" FROM "sample" AS "t1" WINDOW w AS (PARTITION BY "t1"."counter" ORDER BY "t1"."value" DESC) ORDER BY "t1"."counter", RANK() OVER w The sql used to create the

[sqlite] two threads block eachother opening db (WAL)

2018-07-02 Thread Charles Samuels
I have found that when my process has a lot of threads each of which opens a DIFFERENT database, they each block on eachother while opening each database. Here is a little rust program to demonstrate the problem: If you simply remove the line "PRAGMA journal_mode = WAL;", then the program runs

Re: [sqlite] insert or replace performance with self "references" column

2018-07-02 Thread Allen
Thank you for your assistance. I got the same results as you using the shell, and was only getting the problem in my C program. My C program was creating a "Parent_Index" on two different tables, so the second Parent_Index on the Transactions table was not being created, and this was causing the

Re: [sqlite] Window Function Crash -- overriding builtin aggregate

2018-07-02 Thread Simon Slavin
On 2 Jul 2018, at 11:48am, Keith Medcalf wrote: > If I rename the function then both the builtin avg and my new function work > correctly. Thanks. Worth testing just in case something weird happened. But it didn't. I leave it up to the experts. Simon.

Re: [sqlite] Window Function Crash -- overriding builtin aggregate

2018-07-02 Thread Keith Medcalf
If I rename the function then both the builtin avg and my new function work correctly. --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original Message- >From: sqlite-users [mailto:sqlite-users-

Re: [sqlite] Window Function Crash -- overriding builtin aggregate

2018-07-02 Thread Simon Slavin
On 2 Jul 2018, at 7:40am, Keith Medcalf wrote: > Even if I register the override function using the new > sqlite_create_window_function and explicitly set the xValue and xInverse to 0 > (null), the program still crashes when attempting to run the non-existent > xValue function ... As a test,

Re: [sqlite] FTS4 content table

2018-07-02 Thread Peter Johnson
Wording looks great, thanks Dan. FWIW I believe the same docs issue applies to the FTS5 module. Docs are hard, I often find myself re-reading paragraphs and then figuring out that I'm just a big dummy and didn't 'get it' the first time. The FTS docs are actually pretty great, they introduce

[sqlite] Typo in window function docs

2018-07-02 Thread Domingo Alvarez Duarte
Hello ! This sql example on the new window function docs is missing the parenthesis on the "rank" function: === SELECT x, y, row_number() OVER*win1*, rank OVER*win2* FROM t0 --< here the rank function is missing "()" WINDOW*win1* AS (ORDER BY y RANGE BETWEEN UNBOUNDED PRECEDING AND

Re: [sqlite] FTS4 content table

2018-07-02 Thread Dan Kennedy
On 07/01/2018 05:20 PM, Peter Johnson wrote: I recall you must still enumerate the column names of the fields you wish to link to the contentless table when creating the virtual table. If I remember correctly, failing to do so will result in 'no such column' errors. Last time I looked at the

[sqlite] Window Function Crash -- overriding builtin aggregate

2018-07-02 Thread Keith Medcalf
I have overridden the builtin AVG function with a function of my own that computes the average by using the "running average" method rather than the simple sum/count method. This function is registered as an old fashioned aggregate function. After the window extension is put in place, it