You can't replace it with a select, no. There are plenty of different ways in 
which a database can be corrupt. When you run a select query you'll only find 
ones that are fatal errors, and only in places that deal with your query.

The type of corruption you seem to have there is fatal, but there are plenty of 
ways for a database to be corrupt and yet still give results back from a select 
query. Quick_check and integrity_check look for all these different types of 
corruption.

-----Original Message-----
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Junyoung Park
Sent: Thursday, January 04, 2018 12:56 AM
To: sqlite-users@mailinglists.sqlite.org
Subject: [sqlite] Can i check database corruption by select statement instead 
of quick_check?

Hi,

I am currently testing to check database corrupted / malformed.
Database size :1G
table num : 1
index num : 1

The database can be malformed or normal.

When I executing quick_check against a normal database, it takes about
3 minutes from the time of the first execution since opening.
If database is malformed, it will be checked faster than 3 minutes
based on what part of the file is malformed.

On the other hands, when i execute the "select max (rowid) from
table_name" command on the database when it is malformed or normal,
get results according to the situation and get results within about 1
second.

================== TEST CASE ================
* malformed DB checking by select statement *
sqlite> select max(rowid) from test_t;
Run Time: real 0.003 user 0.000000 sys 0.000000
Error: database disk image is malformed

* normal DB checking by select statement *
sqlite> select max(rowid) from test_t;
4644298
Run Time: real 0.074 user 0.000000 sys 0.000000

* malformed DB checking by "quick_check" *
sqlite> pragma quick_check;
Run Time: real 0.000 user 0.000000 sys 0.000000
Error: database disk image is malformed

* normal DB checking by "quick_check" *
sqlite> pragma quick_check;
ok
Run Time: real 201.368 user 1.350000 sys 1.570000
===============================================

The main point of the question is that if the "quick_check" is slow
according to the size of the database,
in order to confirm the checking of malformed of the DB I would like
to ask if I can replace it with the above select statement instead of
"integrity_check" or "quick_check".

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

Reply via email to