db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@gmail.com>
Subject Re: SYSCS_UTIL.SYSCS_CHECK_TABLE
Date Sat, 28 Nov 2015 15:41:30 GMT
On 11/26/15 6:49 AM, 5tu@informatik.uni-hamburg.de wrote:
> Hello,
>
> I would like to test the consistency check function but I have 
> difficulties inserting certain inconsistencies into the database for 
> proper testing.
>
> I found a Testscript which uses T_ConsistencyChecker.class and managed 
> to run it but so far it only tests the following cases:
> - Base tables and all associated indexes contain the same number of rows.
> - The values and row locations in each index match those of the base 
> table.
>
> According to the documentation, there are two other cases:
> - Base tables are internally consistent.
> - All BTREE indexes are internally consistent.
>
> Is it possible to manipulate the base tables and/or the btree indexes 
> in a way to cause inconsistencies, so I can run this function to find 
> them?
> What would be the error messages of these cases?
>
> Thank you,
> Tu
>
>
You might start out by using a text editor in order to insert some 
garbage into the datafiles which hold the base table and the index. 
Those files are located in the seg0 directory of the database. A script 
like the following will tell you which datafiles correspond to which 
base tables and indexes:

connect 'jdbc:derby:memory:db;create=true';

create table t1( a int );
create index t1_idx on t1( a );
create table t2( a int primary key );

create function toHex( conglomerateNumber bigint )
returns varchar( 10 )
language java parameter style java no sql
external name 'java.lang.Long.toHexString';

select s.schemaName, t.tableName,
        'c' || toHex( c.conglomerateNumber ) || '.dat' dataFile,
        c.isIndex, c.isConstraint
from sys.systables t, sys.sysconglomerates c, sys.sysschemas s
where t.tablename not like 'SYS%'
and t.tableid = c.tableid
and t.schemaid = s.schemaid
order by tableName, dataFile;


I see the following interesting exceptions being raised by 
org.apache.derby.iapi.db.ConsistencyChecker:

SQLState.LANG_INCONSISTENT_ROW_LOCATION (X0XC2)
SQLState.LANG_INDEX_COLUMN_NOT_EQUAL (X0XC1)
SQLState.LANG_INDEX_ROW_COUNT_MISMATCH (X0Y55)

Hope this helps,
-Rick


Mime
View raw message