[sqlite] Crash when writing header

2018-02-13 Thread Chris Brody
I was wondering what would happen if there would be an application crash, system crash, or power failure while SQLite is updating the file header? Did I miss an explanation somewhere? -- From: David Raymond Date: Tue, Feb 6, 2018 at 12:04 PM Subject: Re:

Re: [sqlite] Question about threadsafe

2018-02-13 Thread Simon Slavin
On 13 Feb 2018, at 9:14am, Nick wrote: > So I think "threadsafe=2 + more than 1 connection + busy_handler" is a good > way to use. This is the normal way to use SQLite. > Another possible way is "threadsafe=1 and share 1 connection", but if thread > 1 begins a

Re: [sqlite] Question about threadsafe

2018-02-13 Thread Nick
>> is it OK to use "threadsafe=2 and >> 2 connections" in my apps if the 2 threads may write at the same time? >Yes. So I think "threadsafe=2 + more than 1 connection + busy_handler" is a good way to use. Another possible way is "threadsafe=1 and share 1 connection", but if thread 1 begins a

Re: [sqlite] Crash when writing header

2018-02-13 Thread Richard Hipp
On 2/13/18, Chris Brody wrote: > I was wondering what would happen if there would be an application crash, > system crash, or power failure while SQLite is updating the file header? > > Did I miss an explanation somewhere? The content is replicated either in the

[sqlite] More sqlite header questions

2018-02-13 Thread Chris Brody
Thanks to DRH for the quick answer. So I would infer that the sqlite file header would normally be in a consistent state, and only be in an inconsistent or otherwise incorrect state in the following cases: 1. modification (write) is in progress (until the sqlite3 code has a chance to finish the

Re: [sqlite] Help with row values

2018-02-13 Thread Simon Slavin
On 13 Feb 2018, at 5:32pm, x wrote: > Surely it should be 3 in both cases? I agree. Here's verification with a version number: SQLite version 3.19.3 2017-06-27 16:48:08 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME"

[sqlite] Help with row values

2018-02-13 Thread x
sqlite> create table t(a integer primary key); sqlite> insert into t values (1), (3), (5); sqlite> select count(*) from t where a>0; 3 sqlite> select count(*) from t where (a,1)>(0,0); 0 Surely it should be 3 in both cases? If t is created as ‘create table t(a)’ both return 3. Tried it in

Re: [sqlite] Help with row values

2018-02-13 Thread Richard Hipp
On 2/13/18, Simon Slavin wrote: > On 13 Feb 2018, at 5:32pm, x wrote: > >> Surely it should be 3 in both cases? > > I agree. Here's verification with a version number: https://www.sqlite.org/src/tktview/f484b65f3d623059 -- D. Richard Hipp

Re: [sqlite] Proposed registration for application/vnd.sqlite3 and +sqlite3

2018-02-13 Thread Clemens Ladisch
I wrote: > Type name: > > application > > Subtype name: > > vnd.sqlite3 > +suffix > > +sqlite3 ... and they are registered: https://www.iana.org/assignments/media-types/media-types.xhtml https://www.iana.org/assignments/media-type-structured-suffix/media-type-structured-suffix.xhtml

Re: [sqlite] Help with row values

2018-02-13 Thread Richard Hipp
Now fixed on trunk. Thanks for the bug report. -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] More sqlite header questions

2018-02-13 Thread Richard Hipp
On 2/13/18, Chris Brody wrote: > - Does this imply that a SQLite database may be left in some kind of > unrecoverable, corrupted, or otherwise invalid state in case an > application would terminate without calling sqlite3_close() on all > open database connections? No.

Re: [sqlite] Help with row values

2018-02-13 Thread x
Thanks Richard. From: Richard Hipp Sent: 13 February 2018 19:17 To: SQLite mailing list Subject: Re: [sqlite] Help with row values Now fixed on trunk. Thanks for the bug report. -- D. Richard Hipp d...@sqlite.org

Re: [sqlite] More sqlite header questions

2018-02-13 Thread Chris Brody
On Tue, Feb 13, 2018 at 2:03 PM, Simon Slavin wrote: > [...] > There are two possibilities: > > A) The SQLite API was used correctly, including being allowed to close all > files it opened. > B) Any other situation. > > If (A) happened, you can predict things about the

Re: [sqlite] More sqlite header questions

2018-02-13 Thread Simon Slavin
On 13 Feb 2018, at 5:49pm, Chris Brody wrote: > I still have the following questions: Chris, There are two possibilities: A) The SQLite API was used correctly, including being allowed to close all files it opened. B) Any other situation. If (A) happened, you can

Re: [sqlite] More sqlite header questions

2018-02-13 Thread Jens Alfke
> On Feb 13, 2018, at 12:22 PM, Chris Brody wrote: > > I think this is especially important for mobile apps which may be > terminated without notice, especially when using hybrid app frameworks > such as Cordova/PhoneGap. On iOS (can’t speak for Android) apps do get

Re: [sqlite] More sqlite header questions

2018-02-13 Thread Simon Slavin
On 13 Feb 2018, at 8:22pm, Chris Brody wrote: > Thanks Simon for the quick response. You're welcome. > Can you clarify the following: > - Does this imply that a SQLite database may be left in some kind of > unrecoverable, corrupted, or otherwise invalid state in case an

Re: [sqlite] More sqlite header questions

2018-02-13 Thread Richard Hipp
On 2/13/18, Jens Alfke wrote: > > On iOS (can’t speak for Android) apps do get notice that they’re going to be > terminated. I am told that that notification is best-effort and is not guaranteed to occur, nor is it guaranteed to be delivered to the application prior to the

Re: [sqlite] More sqlite header questions

2018-02-13 Thread Simon Slavin
On 13 Feb 2018, at 9:17pm, Richard Hipp wrote: > On 2/13/18, Jens Alfke wrote: > >> On iOS (can’t speak for Android) apps do get notice that they’re going to be >> terminated. > > I am told that that notification is best-effort and is not guaranteed > to

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-13 Thread Nick
>> So I think "threadsafe=2 + more than 1 connection + busy_handler" is a good >> way to use. >This is the normal way to use SQLite. I ran a test and I can still find "database is locked" even if I use busy_handler(threadsafe=2, 2 connections). When thread 1 executing a writing transaction,

Re: [sqlite] Help with row values

2018-02-13 Thread Clemens Ladisch
Dominique Devienne wrote: > in https://www.sqlite.org/src/info/f3112e67cdb27c1a > to fix above ticket, I see queries with order by +a, > but in https://www.sqlite.org/lang_select.html#orderby > I don't see any obvious mention about that +. "Unary plus" does not change the value: sqlite> select

Re: [sqlite] Help with row values

2018-02-13 Thread Dominique Devienne
On Wed, Feb 14, 2018 at 8:44 AM, Clemens Ladisch wrote: > Dominique Devienne wrote: > > in https://www.sqlite.org/src/info/f3112e67cdb27c1a > > to fix above ticket, I see queries with order by +a, > > but in https://www.sqlite.org/lang_select.html#orderby > > I don't see any

Re: [sqlite] Help with row values

2018-02-13 Thread Dominique Devienne
On Tue, Feb 13, 2018 at 7:09 PM, Richard Hipp wrote: > On 2/13/18, Simon Slavin wrote: > > On 13 Feb 2018, at 5:32pm, x wrote: > > > >> Surely it should be 3 in both cases? > > > > I agree. Here's verification with a version