David Costa wrote:
>
> Hello, I am working on an SQLite integrity library for PEAR, the PHP official
>  extensions. two questions:
>
> a) I am using Pragma integrity check  to perform a quality check before the
> backup and I just tried to corrupt a database manually by  by deleting random
>  lines from the db file. In some cases  the pragma check returnes an error
> e.g.
>
> "stdClass Object ( [integrity_check] => *** in database main *** List of tree
> roots: invalid page number 4 Unused space at byte 8 of page 3 ) *** in
> database main *** List of tree roots: invalid page number 4 Unused space at
> byte 8 of page 3"
>
> This is fine, but in other database where I did removed random lines, it
> returns OK

I'm not sure what you mean by "removed random lines".  If you are writing
random text into the middle of the file, you might be writting it into
places where the integrity check cannot find it, such as in an unused page,
or part of a page that is unallocated, or the data section of entry.

>
> What is a quick and effective way to corrupt a database and reproduce a
> similar error on pragma integrity check ?
>

VACUUM the database so that it has no unused pages.  Then change the value
of the first byte of a page.

>
> b) in another case of manual corruption the errors comes up at the connection
> stage and we don't even reach the pragma error message "database disk image
> is malformed" on connection.
>

That means that the database is too sick to even read the SQLITE_MASTER
table.


-- D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to