Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-04 Thread Thomas Kurz
> What about just sticking with the ISO week definition? > > https://en.wikipedia.org/wiki/ISO_week_date From the document you cited: "The ISO standard does not define any association of weeks to months." ___ sqlite-users mailing list

Re: [sqlite] Problem with REAL PRIMARY KEY

2019-05-04 Thread Keith Medcalf
I should think so yes ... The query only appears to work if the index on the real value is not used -- but there appears no way to do that when using the IN operator ... QUERY PLAN |--SEARCH TABLE t1 USING COVERING INDEX sqlite_autoindex_t1_1 (c1=?) (~240 rows) `--LIST SUBQUERY 1 `--SCAN

Re: [sqlite] Problem with REAL PRIMARY KEY

2019-05-04 Thread Tim Streater
On 04 May 2019, at 18:49, Richard Hipp wrote: > On 5/4/19, Manuel Rigger wrote: >> Consider the following example: >> >> CREATE TABLE t1 (c0, c1 REAL, PRIMARY KEY (c1, c0)); >> INSERT INTO t1(c1) VALUES (0X7ff);; >> SELECT ALL * FROM t1 WHERE c1 = 5.76460752303423e+17; >> >> I

Re: [sqlite] Partial Index on "~" malfunctions when used with likely/unlikely

2019-05-04 Thread Manuel Rigger
Thanks for the explanation and the quick fix! Best, Manuel On Sat, May 4, 2019 at 7:41 PM Richard Hipp wrote: > Here is another case: > > CREATE TABLE t1(a,b,c); > INSERT INTO t1 VALUES(NULL,8,'yes'); > CREATE INDEX t1b ON t1(b) WHERE a IS NOT NULL; > SELECT c FROM t1 WHERE b=8 AND (a OR 1); >

Re: [sqlite] Problem with REAL PRIMARY KEY

2019-05-04 Thread Manuel Rigger
Sorry, I should have anticipated that we get slightly different values. Shouldn't the query "SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t1);" return a result though? Best, Manuel On Sat, May 4, 2019 at 8:17 PM Keith Medcalf wrote: > > Ooopsie ... that should have been 1e17, and it appears to

Re: [sqlite] Problem with REAL PRIMARY KEY

2019-05-04 Thread Keith Medcalf
Ooopsie ... that should have been 1e17, and it appears to be fine, except that: SELECT ALL * FROM t1 WHERE c1 = (select c1 from t1); does not work ever though the value returned from the subselect should be exactly the value in the index ... A table scan does however work correctly ...

Re: [sqlite] Problem with REAL PRIMARY KEY

2019-05-04 Thread Keith Medcalf
There is, however, something weird: SQLite version 3.29.0 2019-05-04 17:32:07 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> .version SQLite 3.29.0 2019-05-04 17:32:07

Re: [sqlite] Problem with REAL PRIMARY KEY

2019-05-04 Thread Richard Damon
On 5/4/19 12:36 PM, Manuel Rigger wrote: > Hi everyone, > > Consider the following example: > > CREATE TABLE t1 (c0, c1 REAL, PRIMARY KEY (c1, c0)); > INSERT INTO t1(c1) VALUES (0X7ff);; > SELECT ALL * FROM t1 WHERE c1 = 5.76460752303423e+17; > > I would expect the row to be fetched,

Re: [sqlite] Problem with REAL PRIMARY KEY

2019-05-04 Thread Richard Hipp
On 5/4/19, Manuel Rigger wrote: > Hi everyone, > > Consider the following example: > > CREATE TABLE t1 (c0, c1 REAL, PRIMARY KEY (c1, c0)); > INSERT INTO t1(c1) VALUES (0X7ff);; > SELECT ALL * FROM t1 WHERE c1 = 5.76460752303423e+17; > > I would expect the row to be fetched, which is

Re: [sqlite] Problem with REAL PRIMARY KEY

2019-05-04 Thread Keith Medcalf
The actual value is 5.7646075230342348e+17 or 5.764607523034235e+17 (depending on compiler, floating point mode, FPU rounding settings, etc.). This is a common problem with using = with floating point numbers ... You can find the actual exact value using: select printf('%!.20e', c1) from t1;

Re: [sqlite] Partial Index on "~" malfunctions when used with likely/unlikely

2019-05-04 Thread Richard Hipp
Here is another case: CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(NULL,8,'yes'); CREATE INDEX t1b ON t1(b) WHERE a IS NOT NULL; SELECT c FROM t1 WHERE b=8 AND (a OR 1); The problem was in the theorem prover that determines when a partial index can be used. The problem goes all the way back to

Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-04 Thread Petite Abeille
> On May 4, 2019, at 15:59, Luuk wrote: > > This is the 'standard' used here where i live, so i can accept that ;) "The nice thing about standards is that you have so many to choose from." -- Andrew Stuart "Andy" Tanenbaum :P ___ sqlite-users

[sqlite] Problem with REAL PRIMARY KEY

2019-05-04 Thread Manuel Rigger
Hi everyone, Consider the following example: CREATE TABLE t1 (c0, c1 REAL, PRIMARY KEY (c1, c0)); INSERT INTO t1(c1) VALUES (0X7ff);; SELECT ALL * FROM t1 WHERE c1 = 5.76460752303423e+17; I would expect the row to be fetched, which is not the case. I confirmed that the real value

Re: [sqlite] Where are the likes of sqlite3_db and sqlite3_stmt defined?

2019-05-04 Thread x
Thanks Simon. From: sqlite-users on behalf of Simon Slavin Sent: Saturday, May 4, 2019 1:23:44 PM To: SQLite mailing list Subject: Re: [sqlite] Where are the likes of sqlite3_db and sqlite3_stmt defined? On 4 May 2019, at 11:16am, x wrote: > I can’t find

Re: [sqlite] Partial Index on "~" malfunctions when used with likely/unlikely

2019-05-04 Thread Manuel Rigger
This similar test case, that I just found now, demonstrates that this could be a pattern that is used in practice (TRUE can also be computed): CREATE TABLE t0 (c0); CREATE INDEX index_0 ON t0(c0) WHERE c0 NOTNULL; INSERT INTO t0(c0) VALUES (NULL); SELECT * FROM t0 WHERE (c0 OR TRUE); Also here,

Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-04 Thread Luuk
On 4-5-2019 15:21, Petite Abeille wrote: On May 4, 2019, at 12:47, Luuk wrote: As others have noted, it's a question of definition, and which definition do you follow? What about just sticking with the ISO week definition? https://en.wikipedia.org/wiki/ISO_week_date This is the

[sqlite] Partial Index on "~" malfunctions when used with likely/unlikely

2019-05-04 Thread Manuel Rigger
Hi, I discovered a bug, which is demonstrated through the following test case: CREATE TABLE t0(c0); CREATE INDEX index_0 ON t0(c0) WHERE (~c0) NOT NULL; INSERT INTO t0(c0) VALUES (NULL); SELECT * FROM t0 WHERE (LIKELY(~c0) OR TRUE); No row is fetched, although the WHERE clause is always TRUE. I

Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-04 Thread Petite Abeille
> On May 4, 2019, at 12:47, Luuk wrote: > > As others have noted, it's a question of definition, and which definition do > you follow? What about just sticking with the ISO week definition? https://en.wikipedia.org/wiki/ISO_week_date ___

Re: [sqlite] Where are the likes of sqlite3_db and sqlite3_stmt defined?

2019-05-04 Thread Simon Slavin
On 4 May 2019, at 11:16am, x wrote: > I can’t find any definition of them in the amalgamation code nor see any > #included files that are likely to contain them. They're not defined in the way you'd expect. The lines quoted in the documentation are intended to give you the structure

Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-04 Thread Luuk
On 2-5-2019 22:17, Jose Isaias Cabrera wrote: I found this very interesting, 15:52:46.71>sqlite3 SQLite version 3.28.0 2019-04-16 19:49:53 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> SELECT

[sqlite] Where are the likes of sqlite3_db and sqlite3_stmt defined?

2019-05-04 Thread x
I can’t find any definition of them in the amalgamation code nor see any #included files that are likely to contain them. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-04 Thread Tim Streater
On 04 May 2019, at 09:35, Olivier Mascia wrote: >> Le 2 mai 2019 à 22:01, Thomas Kurz a écrit : >> >> I think "week of the month" is not a standard value. As with week of the >> year, is week #1 the week in which the month starts, the first complete week >> within the month, or the first week

Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-04 Thread Olivier Mascia
> Le 2 mai 2019 à 22:01, Thomas Kurz a écrit : > > I think "week of the month" is not a standard value. As with week of the > year, is week #1 the week in which the month starts, the first complete week > within the month, or the first week with at least 4 days? These are very regional