TSQlite3Dataset doesn't raise exception when "database disk image is malformed" lazarus / 16-Databases ---------------------------------------------------------------------- swierzbicki · 2014-11-28 09:12 Hello, I have an issue with an SQLite 3 database. This database was corrupted but my function doesn't raise an exception when calling an PRAGMA Intigrity check. Is this expected ? The code bellow : Code: [Select]function TdtmMain.CleanSQLiteDatabase(const ADatabaseName: string): string; var   ASQLiteConnection: TSqlite3Dataset; begin   if not FileExists(ADatabaseName) then     exit;   Result := '';   ASQLiteConnection := TSqlite3Dataset.Create(nil);   try     ASQLiteConnection.FileName := ADatabaseName;     ASQLiteConnection.ExecSQL('BEGIN TRANSACTION;');     try      ASQLiteConnection.ExecSQL('PRAGMA integrity_check;'); //<--- exception should be raised here       ASQLiteConnection.ExecSQL('VACUUM;');       ASQLiteConnection.ExecSQL('REINDEX;');       ASQLiteConnection.ExecSQL('COMMIT;');       Result := '';     except       on e: Exception do       begin         if Assigned(frmSplash) then           frmSplash.lblSynchroError.Caption := e.Message;           ASQLiteConnection.ExecSQL('ROLLBACK');       end;     end;   finally     ASQLiteConnection.Free;   end; end; ---------------------------------------------------------------------- swierzbicki · 2014-12-01 09:40 This is a real problem ! Is it worth to submit this ? ---------------------------------------------------------------------- Never · 2014-12-01 10:55 Are you sure about the exception? PRAGMA integrity_check returns results if errors found and is not able to find all kind of errors ref: [ http://www.sqlite.org/pragma.html#pragma_integrity_check ] ---------------------------------------------------------------------- LuizAmérico · 2014-12-01 15:41 PRAGMA integrity_check returns rows, so you should do ASQLiteConnection.Close; ASQLiteConnection.SQL = 'PRAGMA integrity_check'; ASQLiteConnection.Open; //verify the returned records