On May 5, 2009, at 4:09 PM, Jacob Siegel wrote: > > Hi, > > > I have found what I believe to be a bug in SQLite. It is > reproducible > fairly easily (though the database file is not small). > > Essentially, with a non-corrupt database, and auto_vaccum enabled, > I can > run a series of delete statements (through the command line tool) > that cause > the database to become corrupt every time. I'm not sure if this is > the > right forum for the issue report, and I'm not certain where to put the > database file (as it is ~200MB), however if someone here knows how > to report > the issue correctly, I would much appreciate it.
Thank you for sending me the database file that is giving you problems. This is not a bug in SQLite. It is reporting "database disk image is malformed" errors because, in fact, the original database disk (the one you sent me) is malformed. You can see this by running "PRAGMA integrity_check" on the file to get this output: *** in database main *** Page 118797 is never used Page 153960 is never used Page 161000 is never used Page 168034 is never used Page 168035 is never used Page 175070 is never used Page 182111 is never used The corruption here seems relatively harmless. Unused pages are what they say: pages which are never used. Most of the time this causes no more trouble than taking up some extra space on disk. You can always repair such corruption by running VACUUM. But you have auto_vacuum turned on. The way auto_vacuum works is that every time you delete enough information to completely free one page, the newly freed page is swapped with the last page in the database and then the database file is truncated. The error message you are getting is when the file tries to shrink below 182111 pages, and thus tries to swap a newly freed page with unused page number 182111. SQLite looks at page 182111 to see what "kind" of page it is so that it can relink some pointer in order to swap it down to a lower page number. But, because page 182111 is unused, SQLite cannot figure out what kind of page it is. So SQLite does the right thing: It reports database corruption. To repeat: Unused pages are entirely harmless as long as you do not have auto_vacuum enabled. The VACUUM command uses a very different process and could not care less about unused pages. In fact, the VACUUM command will do an excellent job of removing unused pages from the database file. D. Richard Hipp d...@hwaci.com _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users