--- a/metadataengine/server/src/mdssqldbmaintenance.cpp Wed Sep 01 12:24:24 2010 +0100
+++ b/metadataengine/server/src/mdssqldbmaintenance.cpp Tue Sep 14 22:10:25 2010 +0300
@@ -188,7 +188,6 @@
}
}
CleanupStack::PopAndDestroy( &col2propQuery );
- emptyRowData.Reset();
CleanupStack::PopAndDestroy( &emptyRowData );
@@ -227,3 +226,49 @@
CleanupStack::PopAndDestroy( &emptyRowData );
}
+TBool CMdSSqlDbMaintenance::CheckForCorruptionL()
+ {
+ // Check the MDS default namespace main table for validity
+ // This table should always contain at least 1 default system folder object
+ _LIT( KValidateData, "SELECT COUNT(*) FROM Object%u;" );
+
+ RBuf commonClauseOne;
+ User::LeaveIfError( commonClauseOne.Create( KValidateData.iTypeLength + KMaxUintValueLength ) );
+ CleanupClosePushL( commonClauseOne );
+ commonClauseOne.Format( KValidateData, KDefaultNamespaceDefId );
+
+ RRowData emptyRowData;
+ CleanupClosePushL( emptyRowData );
+
+ RMdsStatement validationQuery;
+ CleanupClosePushL( validationQuery );
+
+ CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL();
+
+ TInt test( KErrNone );
+ TUint32 count( 0 );
+ TRAP( test, connection.ExecuteQueryL( commonClauseOne, validationQuery, emptyRowData ) );
+ if( test == KErrNone )
+ {
+ emptyRowData.AppendL( TColumn( count ) );
+ TRAP( test, connection.NextRowL(validationQuery, emptyRowData));
+ if(test == KErrNone)
+ {
+ emptyRowData.Column(0).Get( count );
+
+ if(count <= 0)
+ {
+ test = KErrCorrupt;
+ }
+ }
+ }
+
+ CleanupStack::PopAndDestroy( &validationQuery );
+
+ CleanupStack::PopAndDestroy( &emptyRowData );
+
+ CleanupStack::PopAndDestroy( &commonClauseOne );
+
+ return ( test == KErrNone );
+ }
+