Closed glve1027 closed 3 years ago
Hello @glve1027,
"Database disk image is malformed" leaves no doubt on the symptom. But who knows how your app ended up with an invalid database file? You will have to investigate, and grab as much information as possible on how SQLite databases can become corrupt. Starting from SQLITE_CORRUPT looks like a good idea. Please come back when your issue is solved, or if you can tell what GRDB does wrong.
@groue Actually. I had check the Stack Trace. Just had Finished this method
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {}
be initing DatabaseQueue property. and app crashed.😿
@glve1027, you see an SQLite error when the app opens the database. There's nothing GRDB can do about it. As I said above, you have to look for the original cause of database corruption in your app.
@groue okok.
okok
Yeah, exactly as you say: "okok". Are you sure the database file is available? Are you sure your app does not manipulate the database with FileManager
(generally a bad idea)? Did you click on the above link to SQLITE_CORRUPT
, and read (carefully)?
I'm closing this issue. Please reopen if you think something has to be done in this repository.
After I add some log infos on the app.
Code:
private static func makeShared() -> XXXDBAppDatabase? {
do {
var config = Configuration()
config.prepareDatabase { database in
try database.execute(sql: "PRAGMA auto_vacuum = FULL")
}
let currentQueue = try DatabaseQueue(path: XXXDBAppDatabase.dbPathV2, configuration: config)
// Create the AppDatabase
let appDatabase = try XXXDBAppDatabase(currentQueue)
return appDatabase
} catch {
Log(error.localizedDescription)
print(error)
return nil
}
}
Error description is:
PRAGMA auto_vacuum = FULL
Above exception happens when above init method.
I'm not sure if this has anything to do with the ”auto_vacuum = FULL“.
What did you do?
I just get information from Firebase. I can not reproduce it.
What did you expect to happen?
What happened instead?
Environment
GRDB flavor(s): (GRDB, SQLCipher, Custom SQLite build?) GRDB version: "4.14.0" Installation method: CocoaPods Xcode version: Swift version: 4.2 Platform(s) running GRDB: (iOS, macOS, watchOS?) iOS 12/ iOS 14 macOS version running Xcode:
Demo Project
Crash Log
Crashed: com.xxxx.excuteDataQueue EXC_BREAKPOINT 0x00000001afea6af0
Fatal error: 'try!' expression unexpectedly raised an error: SQLite error 11 with statement
SELECT * FROM sqlite_master LIMIT 1
: database disk image is malformed: file /xxx.swift, line 29