I had several cases of corrupted databases in the last few days which all
look similar but not exactly the same:

sqlite> pragma integrity_check;
*** in database main ***
On tree page 45127 cell 9: Rowid 3 out of order (previous was 76)
Corruption detected in cell 9 on page 45127
Fragmentation of 12 bytes reported as 0 on page 45127
On tree page 45394 cell 1: Rowid 3 out of order (previous was 3)
On tree page 45394 cell 2: Rowid 3 out of order (previous was 3)
On tree page 45394 cell 3: Rowid 3 out of order (previous was 3)
...
On tree page 45394 cell 60: Rowid 3 out of order (previous was 3)
On tree page 45394 cell 61: Rowid 3 out of order (previous was 3)
On tree page 45394 cell 61: Rowid 3 out of order (min less than parent min
of 3)

Corruption detected in cell 61 on page 45394
Multiple uses for byte 292 of page 45394
On tree page 45124 cell 17: 2nd reference to page 45435
On tree page 45124 cell 17: Child page depth differs
On tree page 45124 cell 18: Child page depth differs
Page 45395 is never used
Error: database disk image is malformed

===========

sqlite> pragma integrity_check;
*** in database main ***
On tree page 41236 cell 14: 2nd reference to page 41424
On tree page 41236 cell 14: Child page depth differs
Page 41474 is never used
sqlite> select * from RecentlyObjects;
{some records are displayed}
Error: database disk image is malformed
sqlite>

===========

In all cases, the affected tables which are now corrupted, are frequently
changed by the following sql statements:
DELETE FROM table1;
INSERT INTO table1 SELECT * FROM table2;

I have tried to reproduce the error by means of a test programm which
stresses the database by issuing those statement in a loop.
Unfortunately, I have not been successful so far.
Probably, there is some other statement which is also relevant, and I do
not yet know.




2012/11/19 sqdev sqdev <sqdev...@gmail.com>

> Hello,
>
> I'm using ADO.NET-Provider for SQLite (System.Data.SQLite, Version 1.0.80).
> My database is password-protected. The password is passed in the
> connection string.
>
> Sporadically, I get the following exception:
>
> Exception: The database disk image is malformed
> malformed database schema (VALUE1) - near "VALUE2": syntax error
>
> VALUE1 seems to be a value my application has recently added (or tried to
> add) by means of an INSERT INTO statement issued by a SQLiteCommand.
> VALUE2 might also be such a value, but I'm not sure.
> VALUE1 and VALUE2 differ each time the problem occurrs.
>
> Once this exception has occurred, it's impossible to open the database
> file.
> Opening the database in Visual Studio Server Explorer produces the
> following output:
> ---
> SQLite error (1): near "08": syntax error
> SQLite error (11): database corruption at line 93674 of [036395c0a8]
> SQLite error (1): near "08": syntax error
> SQLite error (11): database corruption at line 93674 of [036395c0a8]
> SQLite error (1): near "08": syntax error
> SQLite error (11): database corruption at line 93674 of [036395c0a8]
> SQLite error (1): near "08": syntax error
> SQLite error (11): database corruption at line 93674 of [036395c0a8]
> SQLite error (1): near "08": syntax error
> SQLite error (11): database corruption at line 93674 of [036395c0a8]
> SQLite error (1): near "08": syntax error
> SQLite error (11): database corruption at line 93674 of [036395c0a8]
> SQLite error (11): malformed database schema (001) - near "08": syntax
> error
> ---
>
> I suspect the SQLITE_MASTER table has been overwritten by the data which
> should have been inserted into another table by the INSERT INTO statement
> mentioned above.
> I cannot verify that though, as I'm not able to open the database file any
> more.
> For the same reason, I cannot issue "PRAGMA integrity_check".
>
> The application issues DDL and DML statements.
> Sometimes, I also get the following error, but I don't know if it has to
> do anything with the database corruption problem.
> sqlite error (17): statement aborts at 21: [SELECT * [FROM MY_TABLE]]
> database schema has changed
> No exception is thrown for this error though. I get it in the
> SQLiteConnection.Trace event only.
>
> Now my questions are:
> - What could have caused the database schema and database file to become
> corrupt?
> - Is there any chance to open the corrupt database file again? Most tools
> (including SQLite3-CLI) fail to open even non-corrupted files, because they
> do not support the encryption algorithm used by System.Data.SQLite, which
> is RSA I think.
> - Is it possible to decrypt a corrupted database file if it cannot be
> opened by System.Data.SQLite any more?
>
> Thank you in advance for any help.
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to