On 1/13/17 2:51 PM, Adam Smith wrote:
Hey all,
   can 'pragma integrity_check' ever modify the file? For instance in case
of a journal file laying around (which was journal file of the same schema
db but a bit different data)?

The following is what I think happened:

a.db and b.db are two sqlite dbs of size ~5mb which have same schema and
little difference in data.
the process writing to a.db is terminated or power loss or something so
a-journal.db left behind.
ls
a.db
a-journal.db
b.db
sqlite3 b.db 'pragma integrity_check'    # b.db is healthy
ok
rm a.db
mv b.db a.db                                      # rename b.db as a.db
sqlite3 a.db 'pragma integrity_check'   # this is I think when integrity
check modifies a.db and corrupts it
failure....
ls
a.db
sqlite3 a.db 'pragma integrity_check'
failure...


a.db is corrupted

Is this possible? If so how do we delete all temp files like -journal file?
Thanks in advance

That is (close to) one of the listed ways to corrupt a database file.

While sqlite mostly keeps all the data in a single file, there are situations where auxiliary files are temporarily created, and those MUST be kept related.

That says when you bypass sqlite and directly manipulate the database file, you need to understand the temporary auxiliary files and process those too, or make sure that you only are working with files that are in a clean state, so it is a single file.

--
Richard Damon

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to