That sounds like a reasonable strategy.
Perform a "SELECT *" on every table and read every single piece of data out.
That will exercise the read paths on the database, which already do pretty good job of detecting corruption.

Then do the same thing with the index data.

The tricky part will be figuring out how to make the engine traverse an index in it's entirety.
I'd expect that you somehow need to trigger methods like:
private Cursor find(Session session, SearchRow first, boolean bigger, SearchRow last) {
    in org.h2.index.PageBtreeIndex
which is probably most easily triggered from
   org.h2.index. IndexCursor
which is created by
  org.h2.table.TableFilter
which is in turn owned by the DML command object
  org.h2.command.dml.Select

Personally, I would probably create a new DML command i.e. something that extends
   org.h2.command.Prepared
a bit like the SQL-Server "DBCC CHECKTABLE" command
http://msdn.microsoft.com/en-us/library/ms174338.aspx <http://msdn.microsoft.com/en-us/library/ms174338.aspx> and copy chunks of code from TableFilter to implement it to make it do a full read of every index on the table.


On 2013-04-09 12:52, Steve McLeod wrote:
Hi Thomas,

I'm thinking of writing a tool that checks if an H2 database has any corruption issues.

Two questions:

1) Is there by any chance something similar already in the source (perhaps in the test suite?)

2) Do you have any tips for a good approach to achieve this? I figure I'll have to at least ensure that every row in every table is readable, and that every index has a number of rows equal to the number of rows in the relevant indexed table.

Regards,

Steve McLeod


--
You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to