[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] Fw: address@hidden : Re: [sqlite] checking 'PRAGMA inte

From: Nathaniel Smith
Subject: [Monotone-devel] Fw: address@hidden : Re: [sqlite] checking 'PRAGMA integrity_check']
Date: Wed, 10 May 2006 23:49:50 -0700
User-agent: Mutt/1.5.11

So this is recorded in our own list archives, here's some info on how
to write a test that we should add..,

-- Nathaniel

  /* Tell the world that we're going to be the grim
   * reaper of innocent orphaned children.
-- Linux kernel 2.4.5, main.c
--- Begin Message --- Subject: Re: [sqlite] checking 'PRAGMA integrity_check' Date: Wed, 10 May 2006 07:24:07 -0400
Nathaniel Smith <address@hidden> wrote:
> So, my question is -- what is a simple way to reliably corrupt a
> sqlite db so that "PRAGMA integrity_check" will fail?

For the SQLite regression tests, we open the database
file separately using fopen() and then write bad stuff
into the middle of the file.

Here is a recipe for generating some corruption that
PRAGMA integrity_check will detect but which will not
cause lasting damage to the database - the damage
can be repaired by running REINDEX - and will not cause

   1.  Create a new table:  CREATE TABLE test1(x UNIQUE);
       The UNIQUE argument is important because we want
       an index for this test.

   2.  Look at the SQLITE_MASTER table to find the ROOTPAGE
       for this table.  Use fopen() to make a copy of this
       page, taking care to remember that SQLite page numbers
       begin with 1, not 0.

   3.  Insert one small row into the test table:
       INSERT INTO test1 VALUES(1);  Commit this change.

   4.  Overwrite the rootpage of the test table with the
       copy of that page that was saved in step 2.  This
       effectively deletes the entry you just inserted but
       without updating the index - so that the index and
       the table are now out of sync.

D. Richard Hipp   <address@hidden>

--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]