Re: [sqlite] Trigger Performance

2018-06-11 Thread Keith Medcalf
data DB (16 columns), the inserts were generated from >.dump in the shell, about 45MB of input data >so > >BEGIN; >lots of inserts >COMMIT; > >Run on a laptop i7 with SSD (not that should make any difference to >the relative performance) >If I could get your relativ

Re: [sqlite] Trigger Performance

2018-06-10 Thread Keith Medcalf
Interesting. That is adding 30% or so to process the trigger. When I do (this is to a "memory" database): SQLite version 3.25.0 2018-06-11 01:30:03 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite>

Re: [sqlite] sqlite.org website is now HTTPS-only

2018-06-10 Thread Keith Medcalf
e: [sqlite] sqlite.org website is now HTTPS-only > >On 10 Jun 2018, at 11:25pm, Keith Medcalf >wrote: > >> Transport security increases the level of security since it >prevents your ISP or other malicious poo-heads from tampering with >the datastream during transport. This

Re: [sqlite] sqlite.org website is now HTTPS-only

2018-06-10 Thread Keith Medcalf
On Sunday, 10 June, 2018 14:27, George wrote: >I don't feel safer running HTTPS everywhere as Google wants with a >trust store full of certificates for companies, governments and >corporations I have never personally met or even trust by name nor >can I if I so desire disable when I want to.

Re: [sqlite] Idea: defining table-valued functions directly in SQL

2018-06-09 Thread Keith Medcalf
>boun...@mailinglists.sqlite.org] On Behalf Of Keith Medcalf >Sent: Saturday, 9 June, 2018 22:06 >To: SQLite mailing list >Subject: Re: [sqlite] Idea: defining table-valued functions directly >in SQL > > >Do you have an appropriate index defined on both the parent and chil

Re: [sqlite] Idea: defining table-valued functions directly in SQL

2018-06-09 Thread Keith Medcalf
Do you have an appropriate index defined on both the parent and child keys? .lint fkey-indexes at a command shell prompt will tell you ... --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original Message-

Re: [sqlite] Idea: defining table-valued functions directly in SQL

2018-06-09 Thread Keith Medcalf
create table templog ( datestamp text collate nocase primary key, centTemp REAL not null, fahrTemp REAL ); create trigger TempLogInsert after insert on templog begin update templog set fahrtemp = new.centTemp/9*5+32 where datestamp == new.datestamp; end; create trigger tempLogUpdate

Re: [sqlite] Selecting multiple similar columnname.

2018-06-09 Thread Keith Medcalf
No. GPS time is maintained as WEEKS since the GPS epoch and an offset into the week (TOW -- time of week). There is an additional field that is the "offset from UT1" (currently 11 seconds I believe). The receiver uses the information to calculate UT1. There is, I believe, a flag that says

Re: [sqlite] ROWID....

2018-06-09 Thread Keith Medcalf
SQLite does not have unsigned integers. All integers are 64-bit signed entities, but may be stored in shorter integers on disk if the value fits. This is an internal optimization and not visible externally. --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot

Re: [sqlite] Reset the cursor

2018-06-07 Thread Keith Medcalf
. >-Original Message- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Igor Korot >Sent: Thursday, 7 June, 2018 20:19 >To: SQLite mailing list >Subject: Re: [sqlite] Reset the cursor > >Hi, Keith, > >On Tue, Jun 5, 2018 at

Re: [sqlite] sqlite.org website is now HTTPS-only

2018-06-07 Thread Keith Medcalf
Just tell wget --no-check-certificate in the command line. wget does not use a certificate repository and you need to obtain and specify the expected root manually. It will be no less secure than it was before (when using HTTP) except that now it will use Transport encryption. Certificate

Re: [sqlite] Size of the SQLite library

2018-06-06 Thread Keith Medcalf
Have you tried the link at the end of every message? --- 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- >boun...@mailinglists.sqlite.org] On Behalf Of

[sqlite] sqlite3BtreeBeginTrans commit breaks sessions modules ...

2018-06-06 Thread Keith Medcalf
sqlite3BtreeBeginTrans() now has an extra parameter. sessions do not like this. --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. ___ sqlite-users mailing list

Re: [sqlite] Size of the SQLite library

2018-06-06 Thread Keith Medcalf
On Wednesday, 6 June, 2018 10:24, Bob Friesenhahn wrote: > The build strategy for the Python APSW extension is an > example of unwanted dependency and loss of control. > Building of software from source code should always be > under the complete control of the person who is performing > the

Re: [sqlite] Reset the cursor

2018-06-05 Thread Keith Medcalf
Most of them. In particular those that return (as in SELECT) data work either way. Those that set things can only be used as a pragma. Note that the table name is passed differently (in the case of pragma's expecting an identifier). It is an identifier in the case of a pragma statement,

Re: [sqlite] Reset the cursor

2018-06-05 Thread Keith Medcalf
et, reset at 5 ! sqlite3_reset returns 0 Loop 2, After Reset ! Loop 3, No Reset, Got SQLITE_DONE ! sqlite3_reset returns 0 --- 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-use

Re: [sqlite] Reset the cursor

2018-06-05 Thread Keith Medcalf
>>> --- >>> 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- >>>>b

Re: [sqlite] Reset the cursor

2018-06-04 Thread Keith Medcalf
2:15 >To: SQLite mailing list >Subject: Re: [sqlite] Reset the cursor > >Keith, > >On Mon, Jun 4, 2018 at 12:59 PM, Keith Medcalf >wrote: >> >> Yes, if it is 3.6.23.1 or earlier or the sqlite3 library was >compiled with SQLITE_OMIT_AUTORESET you will get an SQLITE_

Re: [sqlite] Reset the cursor

2018-06-04 Thread Keith Medcalf
continue; >> } >> printf("Error during stepping %d\n", rc); >> rc = sqlite3_reset(stmt); >> printf("sqlite3_reset returns %d\n", rc); >> break; >> } >> } >> >> 2018-06-04 11:32:

Re: [sqlite] Reset the cursor

2018-06-04 Thread Keith Medcalf
-- 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- >boun...@mailinglists.sqlite.org] On Behalf Of Keith Medcalf >Sent: Monday, 4 June, 2018 11:25 >

Re: [sqlite] Reset the cursor

2018-06-04 Thread Keith Medcalf
om: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Keith Medcalf >Sent: Monday, 4 June, 2018 11:06 >To: SQLite mailing list >Subject: Re: [sqlite] Reset the cursor > > >>Currently running w/MSVC 2010 under Win 8.1. > >>I also presu

Re: [sqlite] Reset the cursor

2018-06-04 Thread Keith Medcalf
>Currently running w/MSVC 2010 under Win 8.1. >I also presume you are testing under the latest SQLite source? Yes, I believe so ... SQLite 3.24.0 2018-06-02 19:14:58 1ecb3aa13de5c8dc611b814ff34010de0bd90aae73d88aa37a59c4627be4alt2 Using GCC (MinGW-w64 8.1.0) on Windows 10 Pro for Workstations

Re: [sqlite] Reset the cursor

2018-06-04 Thread Keith Medcalf
Works just fine for me ... #include "sqlite3.h" #include void main(int argc, char** argv) { sqlite3* db = 0; sqlite3_stmt* stmt = 0; char* rest = 0; int rc = 0; int value = 0; sqlite3_open(":memory:", ); rc = sqlite3_prepare_v2(db, "select value from generate_series

Re: [sqlite] [EXTERNAL] Re: random rows

2018-06-01 Thread Keith Medcalf
Good idea but if there is no AUTOINCREMENT you can simply get the min/max directly: I think the following works (and for both + and - rowid's) NB: The MaxRowID is not needed with Rows(MinRowID, NumRows) as (select min(RowID) as MinRowID, max(RowID) -

Re: [sqlite] [EXTERNAL] Re: random rows

2018-06-01 Thread Keith Medcalf
Good idea but if there is no AUTOINCREMENT you can simply get the min/max directly: I think the following might work (and should work for both + and - rowid's) with Rows(MinRowID, MaxRowID, NumRows) as (select min(RowID) as MinRowID,

Re: [sqlite] SQL Date Import

2018-06-01 Thread Keith Medcalf
Yes, and the database will store the data as entered/bound if it cannot be converted to the requested storage type (column affinity). This is VERY IMPORTANT for you to understand fully and completely including all the rules for storage class and affinity conversions and how they are

Re: [sqlite] Size of the SQLite library

2018-05-31 Thread Keith Medcalf
>On Thursday, 31 May, 2018 10:19, Dominique Devienne said: >Given where the conversation is going, let me point out that many do >not care one bit about the lib's size :) >I'd much rather have an SQLite with tons of features, than forego >those in the name saving a few bytes, to save a few

Re: [sqlite] [EXTERNAL] Re: database locked on select

2018-05-30 Thread Keith Medcalf
In this case it makes no real difference. The select on the connection will start a "read" transaction and the update on that connection will upgrade the transaction to a "write" transaction. The transaction will complete when both the select and the update(s) are complete and the select

Re: [sqlite] database locked on select

2018-05-27 Thread Keith Medcalf
or 1 thread...or 6000 threads...makes no difference whatever. Unless you changed the default from SERIALIZED to something that does not apply. --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original

Re: [sqlite] Function to use to convert a text float to a float for use in ORDER BY

2018-05-17 Thread Keith Medcalf
Why not encode (speak / say) what you want to do directly, rather than prayerfully relying on implementation details -- select col1, col2 from mytable order by cast(body_size as float); --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated

Re: [sqlite] Is this really the best way to do this?

2018-05-17 Thread Keith Medcalf
>Sent: Thursday, 17 May, 2018 02:41 >To: General Discussion of SQLite Database >Subject: Re: [sqlite] Is this really the best way to do this? > >On Wed, May 16, 2018 at 8:33 PM Keith Medcalf <kmedc...@dessus.com> >wrote: > >> >> SELECT coalsce((select action &

Re: [sqlite] Is this really the best way to do this?

2018-05-16 Thread Keith Medcalf
SELECT coalsce((select action from blocked where mail='...'), 'OK') as action; --- 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

Re: [sqlite] unique constraint

2018-05-15 Thread Keith Medcalf
>OK, at the risk of exposing my lack of edification, I'm wondering if >someone can explain why this simple test of unique column constraints >doesn't work. At least it doesn't work as I expected it would (i.e. >that >the second insert would yield a unique constraint violation). > >create table t

Re: [sqlite] Weird query plan when sorting by a joined column

2018-05-15 Thread Keith Medcalf
There is no LEFT join visible to anyone except someone who is in love with LEFT joins without knowing what one is. Your query is misformed. You proper query ought to be: select * from base b join derived d using (id) order by id; There is no b.id nor d.id in the output row. It is a

Re: [sqlite] Multi threaded readers on memory sqlite cannot scale

2018-05-14 Thread Keith Medcalf
tions >is through shared cache. > >2018-05-15 0:27 GMT+02:00, Keith Medcalf <kmedc...@dessus.com>: >> >>>2018-05-13 12:50 GMT+02:00, Techno Magos : >> >>>> Hello >> >>>> I do not have clear examples to post on this but would like to

Re: [sqlite] Multi threaded readers on memory sqlite cannot scale

2018-05-14 Thread Keith Medcalf
>2018-05-13 12:50 GMT+02:00, Techno Magos : >> Hello >> I do not have clear examples to post on this but would like to >> report findings around multi threaded read access (single process) in a >> large system that uses sqlite. >> This may be a known issue/restriction of memory sqlite

Re: [sqlite] Multi threaded readers on memory sqlite cannot scale

2018-05-13 Thread Keith Medcalf
>2. Running the same example on sqlite *file *(multi threaded mode; >WAL journal) scales almost linearly; so 6 threads provide nearly 6xN >throughput. Single threaded throughput is a bit slower (around 15- >20%) than single threaded in-memory access (expected). So, there is some "part" of the

Re: [sqlite] Multi threaded readers on memory sqlite cannot scale

2018-05-13 Thread Keith Medcalf
Say Hi to Gene! https://en.wikipedia.org/wiki/Amdahl%27s_law So I believe what you are saying is something like this: If I take a child and have it count as fast as it can then it can count to X in an hour. However, I take the same child but have it count as fast as it can at five minute

Re: [sqlite] OR statement in LIKE

2018-05-10 Thread Keith Medcalf
You could probably use the one in Sqlite3 as well, rather than a third party one ... https://www.sqlite.org/src/artifact/a68d25c659bd2d89 --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original Message-

Re: [sqlite] 3.24 draft - upsert

2018-05-09 Thread Keith Medcalf
This is a baby implementation of the master file merge from the early part of the last century (after the stone knives but somewhat before bearskins). Take two tables, one mounted on tape drive A, with output to tape drive B, updated from a transaction file on tape drive C. Start Friday

Re: [sqlite] [sqlite-dev] Timeout Not Working for Me

2018-04-27 Thread Keith Medcalf
I have never run into this issue myself. However, you do not specify the version or Platform (Windows , Linux (plus distribution), Other (Apple iOS, MVS, BSD, etc). Nor the version of CPython nor from whence it came (preloaded? version? Downloaded and installed yourself? Built

Re: [sqlite] Sqlite query to get the offset of an entry in the list.

2018-04-27 Thread Keith Medcalf
Again, requiring that both "id" and "name" are candidate keys. In which case, since there has to be unique indexes to enforce that, one might use the more straightforward: select count(*) from table where name <= (select name from table where id=?) order by name; --- The fact that there's

Re: [sqlite] Sqlite query to get the offset of an entry in the list.

2018-04-27 Thread Keith Medcalf
The constraint, obviously, being that "id" and "name" are each candidate keys ... --- 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] Sqlite query to get the offset of an entry in the list.

2018-04-27 Thread Keith Medcalf
create table data (id integer primary key, name text); insert into data (name) values ('AAA'), ('ZZZ'), ('BBB'), ('WWW'), ('CCC'); select * from data; 1|AAA 2|ZZZ 3|BBB 4|WWW 5|CCC select * from data order by name; 1|AAA 3|BBB 5|CCC 4|WWW 2|ZZZ create table temp.ranked as select * from data

Re: [sqlite] copmile SQLite with extension?

2018-04-26 Thread Keith Medcalf
Yes. Simply append the extension to the sqlite3.c source code. When you do this you need to have the symbol SQLITE_CORE defined so that the extension calls the sqlite3* entrypoints directly rather than through the indirection table. The main sqlite3.c source should take care of this for

Re: [sqlite] SQLite3 - Search on text field with \0 binary data

2018-04-19 Thread Keith Medcalf
ticipated traffic volume. >-Original Message- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of J Decker >Sent: Thursday, 19 April, 2018 16:41 >To: SQLite mailing list >Subject: Re: [sqlite] SQLite3 - Search on text field with \0 b

Re: [sqlite] SQLite3 - Search on text field with \0 binary data

2018-04-19 Thread Keith Medcalf
Actually, nothing in the C or C++ world will "go past" the NULL byte since the very definition of a C string is a "bunch-o-bytes that are non-zero followed by one that is". If you want to embed non UTF8 text you should be using a BLOB not TEXT. Text means "an array of non-zero characters

Re: [sqlite] Are you getting spam when you post to sqlite-users ?

2018-04-19 Thread Keith Medcalf
Richard, The ARIN PPML has the same spammer harvesting their list to get subscriber email addresses and replying with the same type of "spam" ... --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original

Re: [sqlite] Are you getting spam when you post to sqlite-users ?

2018-04-18 Thread Keith Medcalf
I block by domain as in *.dognuts *.spammers *.dating *.evildoers for basically every johhny-cum-lately domain (ie, that has not existed since before 1995) -- one strike and the whole TLD is fileterd (as in packet routed to the null0 interface). Then tere is the checks on SPF, protocol

[sqlite] Documentation Typo : https://sqlite.org/optoverview.html section 15

2018-04-12 Thread Keith Medcalf
https://sqlite.org/optoverview.html 15, the push down optimization. The BETWEEN clause is in error? SELECT x, y, b FROM t2 JOIN (SELECT DISTINCT a, b FROM t1 WHERE b BETWEEN 10 AND 20) WHERE b BETWEEN 10 AND 10; should probably be BETWEEN 10 AND 20; --- The fact that there's a Highway

Re: [sqlite] SELECT with CASE

2018-04-12 Thread Keith Medcalf
The Query Planner should decide in the case of the MIN containing query that the best solution is to traverse TheDate in order and return the first hit. This may entail the creation of the necessary index if it does not exist and so the two plans should be more or less identical. However, if

Re: [sqlite] SELECT with CASE

2018-04-12 Thread Keith Medcalf
hod does not work? >It can't be done with the CASE expression at all? > >2018-04-12 17:26 GMT+02:00 Keith Medcalf <kmedc...@dessus.com>: >> >> Then Richard is correct (of course) ... which is a perfect >translation of the problem statement into SQL. >> >>

Re: [sqlite] SELECT with CASE

2018-04-12 Thread Keith Medcalf
ite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Keith Medcalf >Sent: Thursday, 12 April, 2018 09:26 >To: SQLite mailing list >Subject: Re: [sqlite] SELECT with CASE > > >Then Richard is correct (of course) ... which is a perfect >translation of the problem statement into

Re: [sqlite] SELECT with CASE

2018-04-12 Thread Keith Medcalf
t;Yes, this is what I am asking. > >2018-04-12 17:17 GMT+02:00 Keith Medcalf <kmedc...@dessus.com>: >> >> The question you asked was: >> >> "Then how can I get only that date from the Dates table - which is >> equal to the current date?" >> >

Re: [sqlite] SELECT with CASE

2018-04-12 Thread Keith Medcalf
ys a lot about anticipated traffic volume. >-Original Message- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Csányi Pál >Sent: Thursday, 12 April, 2018 09:10 >To: SQLite mailing list >Subject: Re: [sqlite] SELECT with CASE >

Re: [sqlite] SELECT with CASE

2018-04-12 Thread Keith Medcalf
select TheDate from Dates where TheDate == date('now'); --- 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- >boun...@mailinglists.sqlite.org] On Behalf Of

Re: [sqlite] Access to sqlite3_api_routines outside of a loadable extension context

2018-04-05 Thread Keith Medcalf
You write the code as if it were a loadable extension. If you compile "inline" (ie, appended to the amalgamation) the headers will detect the SQLITE_CORE symbol being defined and generate direct calls rather than indirect calls. There is really no need to change the code from the code you

Re: [sqlite] json question

2018-03-27 Thread Keith Medcalf
-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Ian Zimmerman >Sent: Tuesday, 27 March, 2018 21:22 >To: sqlite-users@mailinglists.sqlite.org >Subject: Re: [sqlite] json question > >On 2018-03-27 19:26, Keith Medcalf wrote: > >> Actually, it i

Re: [sqlite] json question

2018-03-27 Thread Keith Medcalf
>The point of JSON support in SQLite, IMHO, is that it allows for >hierarchical data structures, not something that is easy to do in a >relational table-based DBMS like SQLite otherwise. Actually, it is very simple and straightforward to implement hierarchical structures using Relational

Re: [sqlite] SQLITE_CONFIG_MULTITHREAD needed for connection pool?

2018-03-27 Thread Keith Medcalf
You never *need* to change SQLITE_CONFIG_MULTITHREAD. The default mode is "serialized", which means that if you "accidentally" violate the serial entrance requirements of a connection (by accessing it simultaneously on multiple threads) that all hell will not break loose. This is achieved by

Re: [sqlite] How to build SQLite with enabled SQLITE_ENABLE_ICU option using MinGW?

2018-03-25 Thread Keith Medcalf
You have to build it first, or use a pre-built version. MinGW does not appear to be a supported compiler on Windows. --- 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

Re: [sqlite] Determine sort order of query

2018-03-25 Thread Keith Medcalf
LE t1 USING INDEX b >0|1|1|SCAN TABLE t2 >0|0|0|USE TEMP B-TREE FOR RIGHT PART OF ORDER BY > >After all, it’s attaching an entire table to each row in t1 in an >order that’s already been worked out. > >From: Keith Medcalf<mailto:kmedc...@dessus.com> >Sent: 24 March 2018 20

Re: [sqlite] Determine sort order of query

2018-03-24 Thread Keith Medcalf
Hint: Index entries must be unique. They are made unique by having the rowid in the index (how else would you find the row from the index)? if you asked for the data in an order that can be produced by an index without a sort, then you will get the output without a sort. select * from t1,

Re: [sqlite] Determine sort order of query

2018-03-24 Thread Keith Medcalf
That index will not result in the ordering you asked for. --- 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- >boun...@mailinglists.sqlite.org] On Behalf

Re: [sqlite] sqlite3rebaser_* function declaration error

2018-03-23 Thread Keith Medcalf
Sent: Friday, 23 March, 2018 18:20 >To: SQLite mailing list >Subject: Re: [sqlite] sqlite3rebaser_* function declaration error > >Please try again with the latest and let me know whether or not the >problem is fixed. Thanks. > >On 3/23/18, Keith Medcalf <kmedc...@dessus.com&

[sqlite] sqlite3rebaser_* function declaration error

2018-03-23 Thread Keith Medcalf
The forward references do not contain the SQLITE_API preface, yet the function declarations do. This means that if you define SQLITE_API as static (ie, for inclusion in APSW) then the rebaser functions cause the compiler to toss a bunch of errors: D:\Source\apsw\sqlite3.c:185554:16: error:

Re: [sqlite] Bug? INSERT OR REPLACE not equivalent to DELETE followed by INSERT

2018-03-22 Thread Keith Medcalf
Yes. Here is a stored procedure written in Python that implements a "stored procedure" (that is, it is a procedure and it is indeed stored) that does an "upsert" operation. You pass it the db connection object, the name of the table, a dictionary of the PrimaryKey fields, and a dictionary of

Re: [sqlite] How to optimise a somewhat-recursive query?

2018-03-21 Thread Keith Medcalf
a lot about anticipated traffic volume. >-Original Message- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Keith Medcalf >Sent: Wednesday, 21 March, 2018 12:31 >To: SQLite mailing list >Subject: Re: [sqlite] How to optimise a somewh

Re: [sqlite] How to optimise a somewhat-recursive query?

2018-03-21 Thread Keith Medcalf
Or just try it with the superfluous outer join keyword (LEFT) removed since you are really just doing an inner (equi) join and the outer join data is just discarded (by your WHERE clause constraints) after it is generated anyway ... --- The fact that there's a Highway to Hell but only a

Re: [sqlite] UPSERT

2018-03-19 Thread Keith Medcalf
If you have multiple candidate keys for a single row that match more than one row (or the alternate candidate keys match different rows), your application should explode immediately! There is no need to "decide" which row is the correct one to update, you are already in a fatal error

Re: [sqlite] pragma foreign_key_check

2018-03-17 Thread Keith Medcalf
Right you are Clemens: SQLite version 3.23.0 2018-03-16 07:48:43 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> PRAGMA foreign_keys=OFF; sqlite> BEGIN TRANSACTION; sqlite> CREATE TABLE t (id int primary

Re: [sqlite] pragma foreign_key_check

2018-03-17 Thread Keith Medcalf
Nor does there appear to be "column names" ... and this with the current tip of the trunk. SQLite version 3.23.0 2018-03-16 07:48:43 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> PRAGMA

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-17 Thread Keith Medcalf
PAR is Parameters (calendar start and end) RES is Results from what I see anyway ... --- 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] Bug? INSERT OR REPLACE not equivalent to DELETE followed by INSERT

2018-03-16 Thread Keith Medcalf
is possible? > >CREATE TRIGGER users_after_insert AFTER INSERT ON users >BEGIN >CASE WHEN (SELECT count(*) FROM user_extras WHERE user_id = >new.id)) = >0 THEN >INSERT INTO user_extras (user_id) VALUES (new.id) >END; >END; > >Thanks. > >Peter

Re: [sqlite] How many AUTOINCREMENT tables are in your schema?

2018-03-16 Thread Keith Medcalf
Typically none, though in very rare cases there may be one or two out of a dozen or so tables. Generally speaking, I have found no particular advantage in most circumstances to having "integer primary key" with the "AUTOINCREMENT" property (that is, guaranteed ascending unique assignment

Re: [sqlite] Bug? INSERT OR REPLACE not equivalent to DELETE followed by INSERT

2018-03-12 Thread Keith Medcalf
On this page, 7th paragrph: https://www.sqlite.org/lang_createtrigger.html See that: An ON CONFLICT clause may be specified as part of an UPDATE or INSERT action within the body of the trigger. However if an ON CONFLICT clause is specified as part of the statement causing the trigger to

Re: [sqlite] Bug? INSERT OR REPLACE not equivalent to DELETE followed by INSERT

2018-03-12 Thread Keith Medcalf
The parent is still being deleted and inserted, however, the trigger now uses the REPLACE conflict resolution method rather than the IGNORE resolution method and that resolution method causes the deletion and insertion of a new child record. --- The fact that there's a Highway to Hell but

Re: [sqlite] How to get the entry from sqlite db without primary key or rowid order?

2018-03-09 Thread Keith Medcalf
Sets of things inherently have no order. Since you have not specified an order (as in an order by clause), any ordering you perceive is simply a figment of your imagination and does not, in reality, exist. You can always add another column and put your order in it so that you can sort by

Re: [sqlite] pragma table_info(tbl)

2018-03-02 Thread Keith Medcalf
-- Catalog Views using sqlite_master for SysObjects (Object Names) -- and the various pragma_(ObjectName) tables to retrieve schema data -- all TEXT columns in views have "collate nocase" attached to the output -- columns to ensure that where conditions on retrievals are not case sensitive --

Re: [sqlite] Dealing with SQLITE_BUSY

2018-02-22 Thread Keith Medcalf
Yes. See https://sqlite.org/lang_transaction.html From that page: "Transactions can be deferred, immediate, or exclusive. The default transaction behavior is deferred. Deferred means that no locks are acquired on the database until the database is first accessed. Thus with a deferred

Re: [sqlite] printf() problem padding multi-byte UTF-8 code points

2018-02-19 Thread Keith Medcalf
Should not your application just retrieve the UTF-8 text and format it for display to the user? User <-> Software formatting (and input/output diddling of any type) should only be done ONCE (on INPUT from the user or on OUTPUT to the user) as close to the User as possible and should *NEVER

Re: [sqlite] Question about threadsafe

2018-02-16 Thread Keith Medcalf
THREADSAFE is about entrance requirements and has nothing whatsoever to do with reading/writing or transactions. --- 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

Re: [sqlite] Question about threadsafe

2018-02-16 Thread Keith Medcalf
Yes. If you are starting a transaction in which you know you are going to write use BEGIN IMMEDIATE. Plain BEGIN (BEGIN DEFERRED) starts a READ transaction and only attempts to upgrade to a write transaction when you try to write. Since a read transaction in WAL works with a version of the

Re: [sqlite] Question about threadsafe

2018-02-13 Thread Keith Medcalf
THREADSAFE has NOTHING to do with transactions. Repeat, there is no value to which you can set the THREADSAFE constant which has any effect whatsoever on transactions. Transactions are commenced ON A CONNECTION with either (a) implicitly as required if you do not do it yourself (known as

Re: [sqlite] Question about threadsafe

2018-02-12 Thread Keith Medcalf
THREADSAFE is about re-entrancy control. It has nothing to do with connections or transactions or how many/which threads can make sqlite3 calls (except in the case of THREADSAFE=0). TRANSACTIONS are an attribute of a CONNECTION. All operations on a CONNECTION (and statements

Re: [sqlite] Different kind of constraint

2018-02-10 Thread Keith Medcalf
Is FileType case sensitive? --- 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- >boun...@mailinglists.sqlite.org] On Behalf Of Stephen Chrzanowski >Sent:

Re: [sqlite] [EXTERNAL] Question about threadsafe

2018-02-07 Thread Keith Medcalf
How did you start your processes? ie, is each process doing an sqlite3_open() or are you forking and passing the same pointer to multiple processes? What filesystem is the file located on? Is it a local filesystem or a network filesystem? Threadsafe is for protection against multiple

Re: [sqlite] question about covering index

2018-02-06 Thread Keith Medcalf
ndex > >Wow, I had no idea that the order of the columns in the index effects >how >they're used. Must. Study. More. > >On Tue, Feb 6, 2018 at 5:15 PM, Keith Medcalf <kmedc...@dessus.com> >wrote: > >> >> That said, however, the performance increase will be

Re: [sqlite] question about covering index

2018-02-06 Thread Keith Medcalf
ge- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Keith Medcalf >Sent: Tuesday, 6 February, 2018 18:07 >To: SQLite mailing list >Subject: Re: [sqlite] question about covering index > > >Because your fields are backwards? > >x

Re: [sqlite] question about covering index

2018-02-06 Thread Keith Medcalf
Because your fields are backwards? x should come before _id (x is a row selector, _id is a grouping selector), and the y cannot be used to sort (obviously) but can be used to avoid the table lookup to feed the results into the temp b-tree sorter. sqlite> CREATE TABLE foo (_id integer primary

Re: [sqlite] Auto Index Warnings; key on deterministic functions

2018-02-05 Thread Keith Medcalf
That is because you do not have an index on the tableB child key of the relation (fk). This is required. see the lint command in a command line shell near you. You do realize that a LEFT JOIN b is syntactic sugar for a LEFT OUTER JOIN b which means, in English, include all the rows of a

Re: [sqlite] "ORDER BY ?" sqlite3_bind_int OK, but does weird things

2018-01-29 Thread Keith Medcalf
No. Column name and table referents (identifiers) must be specified explicitly (as part of the command) and MUST NOT be bound parameters. You are asking to sort by the value 1 for all rows, which means that the output is in "visitation order" since the ORDER BY value is the same for all rows

Re: [sqlite] UTF8 and NUL

2018-01-26 Thread Keith Medcalf
I do not understand this at all. If the definition of a C-String is a "bunch-a-non-zero-byes-terminated-by-a-zero-byte", then how is it possible to have a zero/null byte "embedded" within a C-Style String? Similarly, if a C-Style-Wide-String is defined as a

Re: [sqlite] UTF8 and NUL

2018-01-26 Thread Keith Medcalf
Actually, EOF (0xFF) *is* part of a text file, and is the byte in an ASCII byte-stream that indicates end-of-file. In the "old days" the bytes following the last-byte in a stream and the end of a storage block (sector/cluster/track/cylinder, what have you) were padded with 0xFF so you knew

Re: [sqlite] Can this be done with SQLite

2018-01-22 Thread Keith Medcalf
rom temp.rotate where oldkey=x.key); drop table temp.rotate; commit; --- 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: Keith Medcalf [mailto:kmedc...@dessus.com] >Sent: Monday, 22 January

Re: [sqlite] Can this be done with SQLite

2018-01-22 Thread Keith Medcalf
>From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Cecil Westerhof >Sent: Monday, 22 January, 2018 17:19 >To: SQLite mailing list >Subject: Re: [sqlite] Can this be done with SQLite > >2018-01-23 1:02 GMT+01:00 Keith Medcalf <kmedc...@dessus.co

Re: [sqlite] Can this be done with SQLite

2018-01-22 Thread Keith Medcalf
Part of the problem is going to be that you have not defined the problem sufficiently for a "solution" to be proposed. Based on your somewhat silly example one can deduce the following constraints: With respect to "key": - this is TEXT (UTF-8 or something else)? - you specify

Re: [sqlite] .DUMP displays floats differently from SELECT

2018-01-22 Thread Keith Medcalf
When you use a "select" from the shell to output a value converted to text, it outputs the value "doctored up" (coddled) for display to humans rather than display the true (as in actual) floating point value. This is because "most people" do not understand how computers (binary floating point

Re: [sqlite] [EXTERNAL] get stmt row count

2018-01-20 Thread Keith Medcalf
; >From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org> on >behalf of Keith Medcalf <kmedc...@dessus.com> >Sent: Saturday, January 20, 2018 5:10:20 PM >To: SQLite mailing list >Subject: Re: [sqlite] [EXTERNAL] get stmt row coun

Re: [sqlite] [EXTERNAL] get stmt row count

2018-01-20 Thread Keith Medcalf
t;way of checking if the db file has been modified since the RowIDs >query has been run? I’m sure I read something about a db related >integer that was incremented after every update or vacuum but can’t >find the post. > > > > > > >From: sql

<    4   5   6   7   8   9   10   11   12   13   >