Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The database disk image is malformed sqlite

I have migrated my .net 2.0 projects to .net 4.0. With this I had to upgrade system.data.sqlite libraries to the latest versions available 1.0.81.

Right now when I try to query large tables using select * from table I get The database disk image is malformed error. This only happens on tables with lots of records, small tables return records.

Please note if I go back to .net 2.0 and system.data.sqlite 1.0.66 the same DB file works perfecly.

Any Ideas?

like image 278
rpcm Avatar asked May 19 '26 20:05

rpcm


1 Answers

Also encountered a similar problem recently. Even after updating all AColumn values in ATable table to a new value e.g 2 using the following query

UPDATE ATable SET AColumn = 2;

the following select distinct query

SELECT DISTINCT AColumn from ATable;

returned old values e.g. 1,2,3, and

SELECT * FROM ATable WHERE AColumn = 1

resulted in a "The database disk image is malformed sqlite" error.

ATable had an index on AColumn and all the queries going through that index returned wrong result. Running integrity check using the following PRAGMA proved that some indexes were corrupt.

PRAGMA integrity_check;

IDX_AColumn was missing a lot of rows and the index also contained wrong number of entries. Luckily data in all the tables was intact, only a few indexes were corrupt. Reindexing the corrupt indexes solved problem.

REINDEX ATable; http://www.sqlite.org/lang_reindex.html

If a lot of indexes are corrupt you can reindex all of then at the same time using command:

REINDEX;
like image 78
Faisal Mansoor Avatar answered May 22 '26 18:05

Faisal Mansoor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!