On 25 Nov 2010, at 5:25pm, Tito Ciuro wrote:

> 1) SELECT on sqlite_master. All SQLite3 databases contain it, so it would 
> fail right away is it wasn't a valid database.
> 2) Issue a "PRAGMA integrity_check" statement, if (1) succeeds.
> 
> However, I'm wondering whether (1) is redundant. If the integrity check 
> detects right away that the file is not a SQLite3 database, then we're good. 
> But if the integrity check reads the whole file before failing, perhaps 
> running (1) would not be such a bad after all.
> 
> Also, if there is a need to know whether a database is corrupted, an 
> optimization seems to be to issue "PRAGMA integrity_check (1)" statement, 
> which would bail out at the first sign of trouble. As stated in the docs: 
> http://www.sqlite.org/pragma.html

I believe that if Nick's going to do (2) anyway, (1) is redundant.  In my own 
case I couldn't do (2) because some of the databases I was dealing with would 
have made it take too long.  And my hardware were extremely trustworthy anyway: 
I was really just checking that the files were the right files, and someone 
hadn't (for example) renamed a journal file as the database file WHICH IS 
SOMETHING SOMEONE ACTUALLY DID TO ME ONCE ARGHHHHH !

And I agree Nick only needs to see the first error from 'PRAGMA 
integrity_check' so he can use 1 as a parameter.

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

Reply via email to