Commit b36a26f9 authored by Christian Dávid's avatar Christian Dávid
Browse files

Corrected calculation of the next MyMoneyObject ids in SQL backend

The next MyMoneyObjects' ids were stored in the table kmmFileInfo. But
this data got corrupted in the past several times.

Now the highest id is calculated - so corruptions should not be possible
anymore.

The calculation process is lazy and is only executed when needed as it
is quite expensive (uses regex on some RDBMSs). Unfortunatly the SQL
backend triggers the calculation all the time at the moment - way more
often than needed. Some writeFileInfo() and readFileInfo() calls must
be removed to fix that (future work).

Any calls to writeFileInfo() and readFileInfo() are removed - these
methods cannot be called before the upgrade process is finished!

Also the higest id numbers are not set during the upgrade process.

BUG: 339103
FIXED-IN: 4.8
parent c3109e65
......@@ -2105,59 +2105,59 @@ void MyMoneyDatabaseMgr::loadOnlineJobs(const QMap< QString, onlineJob >& online
Q_UNUSED(onlineJobs);
}
unsigned long MyMoneyDatabaseMgr::accountId(void) const
unsigned long MyMoneyDatabaseMgr::accountId() const
{
return m_sql->getNextAccountId();
return m_sql->getNextAccountId()-1;
}
unsigned long MyMoneyDatabaseMgr::transactionId(void) const
unsigned long MyMoneyDatabaseMgr::transactionId() const
{
return m_sql->getNextTransactionId();
return m_sql->getNextTransactionId()-1;
}
unsigned long MyMoneyDatabaseMgr::payeeId(void) const
unsigned long MyMoneyDatabaseMgr::payeeId() const
{
return m_sql->getNextPayeeId();
return m_sql->getNextPayeeId()-1;
}
unsigned long MyMoneyDatabaseMgr::tagId(void) const
unsigned long MyMoneyDatabaseMgr::tagId() const
{
return m_sql->getNextTagId();
return m_sql->getNextTagId()-1;
}
unsigned long MyMoneyDatabaseMgr::institutionId(void) const
unsigned long MyMoneyDatabaseMgr::institutionId() const
{
return m_sql->getNextInstitutionId();
return m_sql->getNextInstitutionId()-1;
}
unsigned long MyMoneyDatabaseMgr::scheduleId(void) const
unsigned long MyMoneyDatabaseMgr::scheduleId() const
{
return m_sql->getNextScheduleId();
return m_sql->getNextScheduleId()-1;
}
unsigned long MyMoneyDatabaseMgr::securityId(void) const
unsigned long MyMoneyDatabaseMgr::securityId() const
{
return m_sql->getNextSecurityId();
return m_sql->getNextSecurityId()-1;
}
unsigned long MyMoneyDatabaseMgr::reportId(void) const
unsigned long MyMoneyDatabaseMgr::reportId() const
{
return m_sql->getNextReportId();
return m_sql->getNextReportId()-1;
}
unsigned long MyMoneyDatabaseMgr::budgetId(void) const
unsigned long MyMoneyDatabaseMgr::budgetId() const
{
return m_sql->getNextBudgetId();
return m_sql->getNextBudgetId()-1;
}
long unsigned int MyMoneyDatabaseMgr::onlineJobId() const
{
return m_sql->getNextOnlineJobId();
return m_sql->getNextOnlineJobId()-1;
}
long unsigned int MyMoneyDatabaseMgr::payeeIdentifierId() const
{
return m_sql->getNextPayeeIdentifierId();
return m_sql->getNextPayeeIdentifierId()-1;
}
void MyMoneyDatabaseMgr::loadAccountId(const unsigned long id)
......
......@@ -172,10 +172,10 @@ public:
bool writeFile(void);
/**
* MyMoneyStorageSql generalized error routine
*
* @return : error message to be displayed
*
* MyMoneyStorageSql generalized error routine
*
* @return : error message to be displayed
*
*/
const QString& lastError() const {
return (m_error);
......@@ -185,7 +185,6 @@ public:
* MyMoneyStorageSql get highest ID number from the database
*
* @return : highest ID number
*
*/
long unsigned highestNumberFromIdString(QString tableName, QString tableField, int prefixLength);
......@@ -195,6 +194,7 @@ public:
* from the database is available in memory to enable it to be written.
*/
virtual void fillStorage();
/**
* The following functions correspond to the identically named (usually) functions
* within the Storage Manager, and are called to update the database
......@@ -411,6 +411,9 @@ private:
void readBudgets(void);
/** @} */
template<long unsigned MyMoneyStorageSql::* cache>
long unsigned int getNextId(const QString& table, const QString& id, const int prefixLength) const;
void deleteTransaction(const QString& id);
void deleteTagSplitsList(const QString& txId, const QList<int>& splitIdList);
void deleteSchedule(const QString& id);
......@@ -507,7 +510,8 @@ private:
long unsigned m_onlineJobs;
long unsigned m_payeeIdentifier;
// next id to use (for future archive)
// Cache for next id to use
// value 0 means data is not available and has to be loaded from the database
long unsigned m_hiIdInstitutions;
long unsigned m_hiIdPayees;
long unsigned m_hiIdTags;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment