[sqlite] Expression-index bug with OR query

2018-12-13 Thread Jens Alfke
We’ve found a bug where creating indexes on expressions causes a query to give incorrect results. Our indexes use some complex custom functions, but the bug is easy to reproduce just using the ‘abs’ function: SELECT * FROM docs WHERE abs(a)=2 OR abs(b)=9 After indexing ‘abs(a)’ and ‘abs(b

Re: [sqlite] add constant to INTEGER PRIMARY KEY

2018-12-13 Thread Simon Slavin
On 13 Dec 2018, at 10:39pm, Roman Fleysher wrote: > UPDATE table1 SET t = t + 8000; > > > Error: UNIQUE constraint failed: table1.t This means there's an actual example where one value for t is 8000 greater than another. Use a larger constant. Simon. __

Re: [sqlite] add constant to INTEGER PRIMARY KEY

2018-12-13 Thread Roman Fleysher
Thank you, Keith, for suggestion. The "t" is time index, with respect to the start of a clock. Since clock can only move forward, it is unique. I need to shift the start of the clock My clock is on raster of 10 milliseconds, so are the shifts. Thus I can use your method to shift twice: by

Re: [sqlite] add constant to INTEGER PRIMARY KEY

2018-12-13 Thread Keith Medcalf
You cannot do that. The PRIMARY KEY is required to be unique at each "step" along the way, especially as this is the parent in a foreign key relationship. Letting alone why anyone would want to do such a thing (which is beyond my ken), you simply have to make sure that your values are unique.

Re: [sqlite] Grouping guidance

2018-12-13 Thread Joseph L. Casale
-Original Message- From: sqlite-users On Behalf Of Roman Fleysher Sent: Thursday, December 13, 2018 2:29 PM To: SQLite mailing list Subject: Re: [sqlite] Grouping guidance > Hypothesis can never be proven. It can only be rejected with data > contradicting it at hand. > > "..the quickest

[sqlite] add constant to INTEGER PRIMARY KEY

2018-12-13 Thread Roman Fleysher
Dear SQLiters, I would like to update a column declared as INTEGER PRIMARY KEY. This column is parent to a column of another table: table1 ( t INTEGER PRIMARY KEY NOT NULL); table2 (t INTEGER PRIMARY KEY NOT NULL REFERENCES table1(t) ON DELETE CASCADE ON UPDATE CASCADE); I keep PRAGMA foreign

Re: [sqlite] Grouping guidance

2018-12-13 Thread Roman Fleysher
Hypothesis can never be proven. It can only be rejected with data contradicting it at hand. "..the quickest way ..." implies someone else corrects you. From: sqlite-users [sqlite-users-boun...@mailinglists.sqlite.org] on behalf of Don V Nielsen [donvnie

Re: [sqlite] Grouping guidance

2018-12-13 Thread Don V Nielsen
Two thumbs up on Igor. They say the quickest way to the correct answer is to post the wrong answer on the internet. Hypothesis just proven. On Thu, Dec 13, 2018 at 3:00 PM Igor Tandetnik wrote: > On 12/13/2018 3:41 PM, Igor Tandetnik wrote: > > On 12/13/2018 3:27 PM, Don V Nielsen wrote: > >> Ma

Re: [sqlite] Grouping guidance

2018-12-13 Thread Igor Tandetnik
On 12/13/2018 3:41 PM, Igor Tandetnik wrote: On 12/13/2018 3:27 PM, Don V Nielsen wrote: Making a mountain out of a mole hill, but isn't the solution more complex that that? The description has to be Foo & Bar. But if given the following, then the simple answer dies. select Request from MyTabl

Re: [sqlite] Grouping guidance

2018-12-13 Thread Igor Tandetnik
On 12/13/2018 3:27 PM, Don V Nielsen wrote: Making a mountain out of a mole hill, but isn't the solution more complex that that? The description has to be Foo & Bar. But if given the following, then the simple answer dies. select Request from MyTable group by Request having sum(Description='Foo

Re: [sqlite] Grouping guidance

2018-12-13 Thread Don V Nielsen
Making a mountain out of a mole hill, but isn't the solution more complex that that? The description has to be Foo & Bar. But if given the following, then the simple answer dies. create table requests (request,task,description); insert into requests values ('REQ0090887','TASK0236753','Foo'), (

Re: [sqlite] Grouping guidance

2018-12-13 Thread Joseph L. Casale
-Original Message- From: sqlite-users On Behalf Of Igor Tandetnik Sent: Thursday, December 13, 2018 12:16 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] Grouping guidance > select Request from MyTable group by Request having count(distinct > Description) = 2 Nice, I ma

Re: [sqlite] Grouping guidance

2018-12-13 Thread Igor Tandetnik
On 12/13/2018 1:58 PM, Joseph L. Casale wrote: I have data that resembles the following: Request NumberDescription REQ0090887 TASK0236753 Foo REQ0090887 TASK0234920 Bar REQ0090887 TASK0234921 Bar REQ0090887 TASK0237261 Foo REQ0086880 TASK0224045 Foo REQ0086903 TA

[sqlite] Grouping guidance

2018-12-13 Thread Joseph L. Casale
Hi, I have data that resembles the following: Request NumberDescription REQ0090887 TASK0236753 Foo REQ0090887 TASK0234920 Bar REQ0090887 TASK0234921 Bar REQ0090887 TASK0237261 Foo REQ0086880 TASK0224045 Foo REQ0086903 TASK0224555 Bar REQ0086990 TASK0223977 Bar R

Re: [sqlite] Affinity of expression indexes

2018-12-13 Thread Jens Alfke
> On Dec 13, 2018, at 5:13 AM, Dan Kennedy wrote: > > The expression 'dog' also has no affinity (I think you're mistaken as to the > rules - but please correct me if that's not the case) You’re right — a literal has no affinity according to section 3.2. That surprised me. Thanks for the ans

Re: [sqlite] Updating Folder_Path in Windows 10 Photos App

2018-12-13 Thread Simon Slavin
On 13 Dec 2018, at 2:57pm, Carlo capaldo wrote: > UPDATE folder > >SET Folder_Path = 'E:\Photos' > > would change the directory references in all existing 16 rows currently > containing Folder_Path references to the wrong locations to the correct > location ‘E:\Photos’ however this also g

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-12-13 Thread Wout Mertens
On Fri, Nov 30, 2018 at 3:15 PM Dominique Devienne wrote: > sqlite> .header on > sqlite> create table t (c, n); > sqlite> insert into t values (1, 'one'), (2, 'two'), (3, 'three'); > sqlite> select n from t where c in (select value from json_each('[1, 3]')); > n > one > three Very nice! Now I c

Re: [sqlite] sqlite_btreeinfo

2018-12-13 Thread Keith Medcalf
You need to have SQLITE_ENABLE_DBPAGE_VTAB defined when compiling sqlite3.c ... otherwise the btreeinfo extension will not work. I append btreeinfo.c (and a whole pile of other .c files) to the end of sqlite3.c and also append the following at the very end: #ifdef USE_NUNICODE extern void* sq

[sqlite] Bug report: Wrong column type retrieved from metainfo for statements with zero rows

2018-12-13 Thread Машков Дмитрий Владимирович
Hi there, I have db with table as CREATE TABLE GasStats10s(GasStats10s_MaxValue REAL,GasStats10s_IntervalDuration INTEGER,GasStats10s_DataCount INTEGER,GasStats10s_MinValue REAL,GasStats10s_Value REAL,GasStats10s_DateTime INTEGER,GasStats10s_Source UID,GasStats10s_Sum REAL,Class UID,DeleteLog

Re: [sqlite] Updating Folder_Path in Windows 10 Photos App

2018-12-13 Thread Carlo capaldo
Simon, thank you for your reply. Unfortunately as a novice I’m still struggling to find a construct that will do what I want. Reading the on-line SQLite guide to the UPDATE statement: “If the UPDATE statement does not have a WHERE clause, all rows in the table are modified by the UPDATE.”

Re: [sqlite] Affinity of expression indexes

2018-12-13 Thread Dan Kennedy
On 12/13/2018 07:41 AM, Jens Alfke wrote: Consider CREATE INDEX foo_idx ON tbl (myfunction(a)); where ‘myfunction’ is a deterministic C function I’ve registered with the SQLite connection (and ‘a’ is a column of ‘tbl’ of course.) SQLite has no idea what data type(s) ‘myfunction’ returns, and it

Re: [sqlite] sqlite_btreeinfo

2018-12-13 Thread Wout Mertens
And how do you compile sqlite so it has the extension? The error I posted was actually with a loaded db, so that's not it. I must be compiling or loading the extension wrong somehow. Also, I saw that it requires sqlite_db[vtab? not sure] and that table is also missing Wout. On Thu, Dec 13, 2018