Re: [sqlite] Exit value of "PRAGMA integrity_check" in command line

2017-11-22 Thread 林自均
Hi Simon, Thank you for the suggestions. Yes, we already found the reason why the database would corrupt and fixed it. However, we still need to check users' database in our newer version of software in order to write new logs. We don't check this very often. The choice between deleting and

Re: [sqlite] Exit value of "PRAGMA integrity_check" in command line

2017-11-22 Thread Simon Slavin
On 23 Nov 2017, at 3:11am, 林自均 wrote: > It's for logs. If it corrupts, we rename it with a suffix ".corrupt" and > write new logs into a new sqlite file. Does that affect the way I check it? I was interested why you were checking for corruption, so your answer just

Re: [sqlite] Exit value of "PRAGMA integrity_check" in command line

2017-11-22 Thread 林自均
Hi Simon, It's for logs. If it corrupts, we rename it with a suffix ".corrupt" and write new logs into a new sqlite file. Does that affect the way I check it? Best, John Lin Simon Slavin 於 2017年11月23日 週四 上午11:04寫道: > > > On 23 Nov 2017, at 3:00am, 林自均

Re: [sqlite] Exit value of "PRAGMA integrity_check" in command line

2017-11-22 Thread Simon Slavin
On 23 Nov 2017, at 3:00am, 林自均 wrote: > In other word, to check if a sqlite file is corrupted, I have to check the > stdout instead of the exit value. Am I right? Why are you checking for corrupted databases ? What will you do if the database is corrupt ? Simon.

Re: [sqlite] Exit value of "PRAGMA integrity_check" in command line

2017-11-22 Thread 林自均
Hi Richard, Thank you for the explanation! In other word, to check if a sqlite file is corrupted, I have to check the stdout instead of the exit value. Am I right? Best, John Lin Richard Hipp 於 2017年11月23日 週四 上午10:53寫道: > On 11/22/17, 林自均 wrote: > > > >

Re: [sqlite] Exit value of "PRAGMA integrity_check" in command line

2017-11-22 Thread Richard Hipp
On 11/22/17, 林自均 wrote: > > $ sqlite3 other-db.sqlite 'PRAGMA integrity_check' > Error: database disk image is malformed > $ echo $? > 11 > > Is that normal? > Yes. The error is occurring as SQLite is trying to parse the schema, not while running "PRAGMA integrity_chck". --

Re: [sqlite] Exit value of "PRAGMA integrity_check" in command line

2017-11-22 Thread 林自均
Hi Richard, After I update to 3.21.0, the situation doesn't change. $ sqlite3 --version 3.21.0 2017-10-24 18:55:49 1a584e499906b5c87ec7d43d4abce641fdf017c42125b083109bc77c4de48827 For "some-db.sqlite" I mentioned in the previous mail, it exit with 0, like you said. However, if I copy

Re: [sqlite] Exit value of "PRAGMA integrity_check" in command line

2017-11-22 Thread Richard Hipp
On 11/22/17, 林自均 wrote: > > Usually, if the database corrupts, the exit value is non-zero. However, I > recently bumped into a corrupted sqlite file that makes the previous > command exit with zero. > The behavior of PRAGMA integrity_check changed with release 3.21.0. It

[sqlite] Exit value of "PRAGMA integrity_check" in command line

2017-11-22 Thread 林自均
Hi folks, The document of "PRAGMA integrity_check" says: > If the integrity_check pragma finds problems, strings are returned (as multiple rows with a single column per row) which describe the problems. But it doesn't specify the exit value of: $ sqlite some-db.sqlite "PRAGMA integrity_check"