Bug 410091

Summary: Open sqlite database under kmymoney versions >= 5.0
Product: [Applications] kmymoney Reporter: Thomas Baumgart <tbaumgart>
Component: databaseAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: major    
Priority: NOR    
Version: 5.0.5   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.0.6
Attachments: Empty database showing the problem

Description Thomas Baumgart 2019-07-22 06:01:23 UTC
Created attachment 121671 [details]
Empty database showing the problem

SUMMARY
An sqlite database created with a prior version of KMyMoney (e.g. 4.7.2) cannot be opened with recent versions (>= 5.0)

STEPS TO REPRODUCE
1. Open existing database created with older version of KMyMoney

OBSERVED RESULT
An error is displayed, that the database cannot be opened.

EXPECTED RESULT
Database opens without problems

ADDITIONAL INFORMATION
The problem has initially been reported on https://forum.kde.org/viewtopic.php?f=69&t=161485

The database can be opened using e.g. sqlitebrowser and seems to be ok (contains all tables and data items).

The details of the error message contain the following information:

Error in function bool MyMoneyStorageSqlPrivate::alterTable(const MyMoneyDbTable&, int) : Error dropping index from kmmSplits
Driver = QSQLITE, Host = localhost, User = thb, Database = //home/thb/xxx.db
Driver Error: 
Database Error No -1: 
Text:  
Error type 0
Executed: 
Query error No 6: database table is locked Unable to fetch row
Error type 1

It is unsure if this also applies to MySQL databases.
Comment 1 Thomas Baumgart 2019-07-22 06:18:09 UTC
Git commit 48c0b11efdcfa43217fc247443afda0d9b7a61c4 by Thomas Baumgart.
Committed on 22/07/2019 at 06:17.
Pushed by tbaumgart into branch '5.0'.

Finish queries so that they do not block the db layout update process

https://stackoverflow.com/questions/17057420/qt-sqlite-unable-to-fetch-row-database-locked
gave me the necessary hint to find the cause.
FIXED-IN: 5.0.6

M  +2    -0    kmymoney/plugins/sql/mymoneystoragesql_p.h

https://commits.kde.org/kmymoney/48c0b11efdcfa43217fc247443afda0d9b7a61c4
Comment 2 Thomas Baumgart 2019-08-17 15:54:00 UTC
Git commit 457e01f18d985d5e7121477df2dda2525e933d04 by Thomas Baumgart.
Committed on 17/08/2019 at 10:15.
Pushed by tbaumgart into branch '5.0'.

Finish db queries at another spot

Amending commit 48c0b11ef and finish queries at another spot to resolve
a problem I have with the SQLCIPHER version to update a DB of an older
version.

M  +1    -0    kmymoney/plugins/sql/mymoneystoragesql.cpp