[sqlite] [patch] for test/backup2.test

2017-07-06 Thread Pavel Volkov
Hello. Please, make test 'test/backup2.test' more compatible with FreeBSD. This is patch for it: --- test/backup2.test.orig 2017-07-07 04:59:34 UTC +++ test/backup2.test @@ -143,7 +143,7 @@ do_test backup2-9 { # if {$tcl_platform(platform)=="windows"} { set msg {cannot open source databa

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Keith Medcalf
select wonkys, fubars, sets, constants, comments, logs, whipitys, doodas from (select sum(wonkies == 'WNK') as wonkys, sum(fubars == 'FBR') as fubars from table_to_summarize ) as S1, (select sum(code_type == 'SET') as sets, sum(code_type == '

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Keith Medcalf
That is the one and only whole statement, and I see no references to anything else in the initial query. So, delete with kcounts(t, c) as ( select code_type, count(*) from keys group by code_type ), ... select ..., (select c from kcounts where t = 'SET') as "#sets", (sele

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Dominique Devienne
On Thu, Jul 6, 2017 at 4:17 PM, Dominique Devienne wrote: > On Thu, Jul 6, 2017 at 4:07 PM, Keith Medcalf wrote: > >> >> select sum(code_type == 'SET') as "#sets", >>sum(code_type == 'CST') as "#constants", >>sum(code_type == 'CMT') as #comments", >>sum(code_type == 'LOG'

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Dominique Devienne
On Thu, Jul 6, 2017 at 4:07 PM, Keith Medcalf wrote: > > select sum(code_type == 'SET') as "#sets", >sum(code_type == 'CST') as "#constants", >sum(code_type == 'CMT') as #comments", >sum(code_type == 'LOG') as "#logs" > from keys; > > will do a single table scan and retu

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Dominique Devienne
On Thu, Jul 6, 2017 at 3:56 PM, Clemens Ladisch wrote: > Dominique Devienne wrote: > > It's a group-by query, so despite using the index, all rowids for the > only > > 4 different "index entries" must still be counted, > > and that's still definitely longer to do that than full scanning the > tab

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Keith Medcalf
select sum(code_type == 'SET') as "#sets", sum(code_type == 'CST') as "#constants", sum(code_type == 'CMT') as #comments", sum(code_type == 'LOG') as "#logs" from keys; will do a single table scan and return the sums in a single statement with no complications ... -- ˙uʍ

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Dominique Devienne
On Thu, Jul 6, 2017 at 3:50 PM, Clemens Ladisch wrote: > Dominique Devienne wrote: > > On Thu, Jul 6, 2017 at 12:54 PM, Clemens Ladisch wrote: > >> You could put kcounts into a temporary table. > > > > I could it in a table, but then who updates kcounts when keys (or > keys_tab) > > changes? > >

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Clemens Ladisch
Dominique Devienne wrote: > It's a group-by query, so despite using the index, all rowids for the only > 4 different "index entries" must still be counted, > and that's still definitely longer to do that than full scanning the table > once. So why using GROUP BY? The top-level query does not real

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Dominique Devienne
On Thu, Jul 6, 2017 at 2:49 PM, Simon Slavin wrote: > On 6 Jul 2017, at 12:32pm, Dominique Devienne wrote: > > Actually not that much apparently. > > No Simon, I didn't have an index on code_type. > > In fact keys is itself a view, and cote_type a case expression. > > The index you created is no

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Clemens Ladisch
Dominique Devienne wrote: > On Thu, Jul 6, 2017 at 12:54 PM, Clemens Ladisch wrote: >> You could put kcounts into a temporary table. > > I could it in a table, but then who updates kcounts when keys (or keys_tab) > changes? I did not say "table" but "temporary table": BEGIN; CREATE TEMPORARY TABL

Re: [sqlite] Sqlite problem with opening database

2017-07-06 Thread Chris Locke
This is actually answered on the system.data.sqlite download page. https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki Scroll down to the section, "Using Native Library Pre-Loading". For some reason (?) on Chrome the text is about 30pt, so you shouldn't be able to miss it. Essen

Re: [sqlite] Sqlite problem with opening database

2017-07-06 Thread Paul Sanderson
Could your 32 bit app be picking up a 64 bit dll. Could you rename the dll's and hard code the location into your library? May not work for your release code but may help you narrow down the issue. Paul On Wed, 5 Jul 2017 at 18:19, Simon Slavin wrote: > > > On 5 Jul 2017, at 1:41pm, Gregor Pa

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Simon Slavin
On 6 Jul 2017, at 12:32pm, Dominique Devienne wrote: > Actually not that much apparently. > No Simon, I didn't have an index on code_type. > In fact keys is itself a view, and cote_type a case expression. The index you created is not helpful. It is not useful for what you’re doing. I suggest

Re: [sqlite] Error Message "The database disk image is malformed"

2017-07-06 Thread Richard Hipp
On 7/6/17, Manoj Sengottuvel wrote: > Hi Richard, > > if I do the Vacuum database before the encryption(SEE) then I didn't have > any issue like "The database disk image is malformed". > > Should I do the vacuum every time before applying the encryption/ > decryption (SEE) ? > Running VACUUM sho

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Dominique Devienne
On Thu, Jul 6, 2017 at 12:54 PM, Clemens Ladisch wrote: > Dominique Devienne wrote: > > with > > kcounts(t, c) as ( > > select code_type, count(*) > >from keys > > group by code_type > > ), > > ... > > select ..., > >(select c from kcounts where t = 'SET') as "#sets", > >(

Re: [sqlite] Hierarchical Queries with Looping in SQLite DB

2017-07-06 Thread Jean-Luc Hainaut
On 06/07/2017 08:08, Ashif Ahamed wrote: When there is some data bringing looping scenario : *INSERT INTO FOLDER VALUES(2, 'Loop Data', 5);* After inserting this loop data , when i trigger the above recursive query in SQLite it keeps on running without bringing any results. Note: In oracle

Re: [sqlite] Hierarchical Queries with Looping in SQLite DB

2017-07-06 Thread Clemens Ladisch
Ashif Ahamed wrote: > I 'm trying to achieve , oracle's hierarchical CONNECT BY NOCYCLE PRIOR in > SQLite database hierarchical queries i.e. with clause queries(common table > expression) > > When there is a loop in the data ,with clause queries in SQLite database is > running for long with infinit

Re: [sqlite] List of Warnings when compiling SQLite

2017-07-06 Thread Clemens Ladisch
bdoom wrote: > https://pastebin.com/muEvCTz2 > sqlite3.c(16979,5): warning : 'SQLITE_4_BYTE_ALIGNED_MALLOC' is not defined, > evaluates to 0 [-Wundef] > 2>#if SQLITE_4_BYTE_ALIGNED_MALLOC > 2>^ > Is this anything to worry about? No. The C standard says that in the #if expression, identifie

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Clemens Ladisch
Dominique Devienne wrote: > with > kcounts(t, c) as ( > select code_type, count(*) >from keys > group by code_type > ), > ... > select ..., >(select c from kcounts where t = 'SET') as "#sets", >(select c from kcounts where t = 'CST') as "#constants", >(select c from

Re: [sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Simon Slavin
On 6 Jul 2017, at 9:52am, Dominique Devienne wrote: > With all 4 counts, the views takes ~ 6.5s to compute its 1 row Just checking …. Do you have an index on keys(code_type) ? Would it not be possible to express this VIEW without the "WITH" construction ? For instance if there is a "SETS"

Re: [sqlite] syntax error near AS

2017-07-06 Thread John McMahon
On 06/07/2017 17:01, Domingo Alvarez Duarte wrote: I already did this before but it was not accepted. For myself I did a modification on sqlite3 to allow the use of "AS" on delete/update statements. You can see the parser part here https://github.com/mingodad/sqlite/blob/decimal64/src/parse

Re: [sqlite] syntax error near AS

2017-07-06 Thread John McMahon
On 06/07/2017 16:04, Paul Sanderson wrote: The SQLite syntax diagrams are my first point of call when looking at an error in my code like this. https://sqlite.org/lang_update.html "AS" and an alias are clearly not part of the statement. And that is how (with testing) I eventually worked out

Re: [sqlite] syntax error near AS

2017-07-06 Thread John McMahon
On 06/07/2017 16:33, Clemens Ladisch wrote: John McMahon wrote: an alias for an "UPDATE" table name is not permitted. Is there a particular reason for this? The UPDATE statement affects a single table. While an alias might be a convenience, it is not necessary (any naming conflicts in subq

Re: [sqlite] clusterfuzz-found issue in GDAL, Ubuntu packages

2017-07-06 Thread Even Rouault
> Aha, I wasn't certain we were allowed to mark it public yet. I don't want > to upset anyone needlessly, but it would be easier to discuss the bug in > public. I've just turned https://bugs.launchpad.net/ubuntu/+source/sqlite3/+bug/1700937 public > (Especially since it appears to be 'just' out-o

Re: [sqlite] syntax error near AS

2017-07-06 Thread John McMahon
On 06/07/2017 15:03, Keith Medcalf wrote: Do you know of any implementation of SQL that accepts an AS clause for the updated table? I don't think any do. No Keith, I don't. My only exposure to SQL is sqlite. Some versions have a FROM extension and you CAN specify an alias for the update

[sqlite] Hierarchical Queries with Looping in SQLite DB

2017-07-06 Thread Ashif Ahamed
I 'm trying to achieve , oracle's hierarchical CONNECT BY NOCYCLE PRIOR in SQLite database hierarchical queries i.e. with clause queries(common table expression) When there is a loop in the data ,with clause queries in SQLite database is running for long with infinite loops Consider the below sam

Re: [sqlite] clusterfuzz-found issue in GDAL, Ubuntu packages

2017-07-06 Thread Seth Arnold
[Sorry for the late reply, but I enjoyed a nice long weekend except for the sunburns. I kept the wider Cc:s since it feels like this can be opened.] On Sat, Jul 01, 2017 at 12:52:54PM +0200, Even Rouault wrote: > Seth, I can turn the Launchpad bug report as public if you wish. I > marked it privat

[sqlite] List of Warnings when compiling SQLite

2017-07-06 Thread bdoom
https://pastebin.com/muEvCTz2 Is this anything to worry about? It's a massive list of warnings. That isn't even all of them. However, they are all for #define macros which seem to not be found anywhere. I even downloaded a copy from sqlite.org of SQLite.c and could not find those macros in the fil

Re: [sqlite] syntax error near AS

2017-07-06 Thread John McMahon
On 06/07/2017 17:01, Domingo Alvarez Duarte wrote: I already did this before but it was not accepted. For myself I did a modification on sqlite3 to allow the use of "AS" on delete/update statements. You can see the parser part here https://github.com/mingodad/sqlite/blob/decimal64/src/parse

Re: [sqlite] syntax error near AS

2017-07-06 Thread John McMahon
On 06/07/2017 16:33, Clemens Ladisch wrote: John McMahon wrote: an alias for an "UPDATE" table name is not permitted. Is there a particular reason for this? The UPDATE statement affects a single table. While an alias might be a convenience, it is not necessary (any naming conflicts in subq

Re: [sqlite] syntax error near AS

2017-07-06 Thread John McMahon
On 06/07/2017 16:04, Paul Sanderson wrote: The SQLite syntax diagrams are my first point of call when looking at an error in my code like this. https://sqlite.org/lang_update.html "AS" and an alias are clearly not part of the statement. And that is how (with testing) I eventually worked out

Re: [sqlite] syntax error near AS

2017-07-06 Thread John McMahon
On 06/07/2017 15:03, Keith Medcalf wrote: Do you know of any implementation of SQL that accepts an AS clause for the updated table? I don't think any do. No Keith, I don't. My only exposure to SQL is sqlite. Some versions have a FROM extension and you CAN specify an alias for the update

[sqlite] Any way to avoid scanning a large table several times?

2017-07-06 Thread Dominique Devienne
I have a view gathering statistics from 3 different tables, one of which is largish (~ 2M rows). The view is similar to this: with kcounts(t, c) as ( select code_type, count(*) from keys group by code_type ), ... select ..., (select c from kcounts where t = 'SET') as "#sets",

Re: [sqlite] Error Message "The database disk image is malformed"

2017-07-06 Thread Manoj Sengottuvel
Hi Richard, if I do the Vacuum database before the encryption(SEE) then I didn't have any issue like "The database disk image is malformed". Should I do the vacuum every time before applying the encryption/ decryption (SEE) ? Let me know How to restore the malformed database? Regards, Manoj

Re: [sqlite] syntax error near AS

2017-07-06 Thread Domingo Alvarez Duarte
I already did this before but it was not accepted. For myself I did a modification on sqlite3 to allow the use of "AS" on delete/update statements. You can see the parser part here https://github.com/mingodad/sqlite/blob/decimal64/src/parse.y . Cheers ! On 06/07/17 05:16, John McMahon wro