![]() |
digiKam
|
#include <dbenginebackend_p.h>
Classes | |
class | AbstractUnlocker |
class | AbstractWaitingUnlocker |
class | BusyWaiter |
class | ErrorLocker |
Public Attributes | |
QString | backendName |
QWaitCondition | busyWaitCondVar |
QMutex | busyWaitMutex |
int | currentValidity = 0 |
DbEngineErrorHandler * | errorHandler = nullptr |
QWaitCondition | errorLockCondVar |
QMutex | errorLockMutex |
BdEngineBackend::QueryOperationStatus | errorLockOperationStatus = BdEngineBackend::ExecuteNormal |
bool | isInTransaction = false |
DbEngineLocking * | lock = nullptr |
BdEngineBackend::QueryOperationStatus | operationStatus = BdEngineBackend::ExecuteNormal |
DbEngineParameters | parameters |
BdEngineBackend *const | q = nullptr |
BdEngineBackend::Status | status = BdEngineBackend::Unavailable |
QThreadStorage< DbEngineThreadData * > | threadDataStorage |
Friends | |
class | AbstractUnlocker |
|
explicit |
|
override |
References threadDataStorage.
bool Digikam::BdEngineBackendPrivate::checkOperationStatus | ( | ) |
bool Digikam::BdEngineBackendPrivate::checkRetrySQLiteLockError | ( | int | retries | ) |
void Digikam::BdEngineBackendPrivate::closeDatabaseForThread | ( | ) |
References threadDataStorage.
Referenced by handleWithErrorHandler(), and resetDatabaseForThread().
|
overridevirtual |
Implements Digikam::DbEngineErrorAnswer.
References Digikam::BdEngineBackend::AbortQueries, lock, Digikam::DbEngineLocking::mutex, and queryOperationWakeAll().
|
overridevirtual |
called by DbEngineErrorHandler, implementing DbEngineErrorAnswer.
Implements Digikam::DbEngineErrorAnswer.
References Digikam::BdEngineBackend::ExecuteNormal, lock, Digikam::DbEngineLocking::mutex, and queryOperationWakeAll().
QString Digikam::BdEngineBackendPrivate::connectionName | ( | ) |
References backendName.
Referenced by Digikam::DbEngineThreadData::closeDatabase(), and createDatabaseConnection().
QSqlDatabase Digikam::BdEngineBackendPrivate::createDatabaseConnection | ( | ) |
References connectionName(), Digikam::DbEngineParameters::connectOptions, Digikam::DbEngineParameters::databaseNameCore, Digikam::DbEngineParameters::databaseType, Digikam::DbEngineParameters::hostName, Digikam::DbEngineParameters::isSQLite(), parameters, Digikam::DbEngineParameters::password, Digikam::DbEngineParameters::port, and Digikam::DbEngineParameters::userName.
Referenced by databaseForThread().
QSqlError Digikam::BdEngineBackendPrivate::databaseErrorForThread | ( | ) |
References threadDataStorage.
QSqlDatabase Digikam::BdEngineBackendPrivate::databaseForThread | ( | ) |
"A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread is not supported." => one QSqlDatabase object per thread. The main class' open/close methods only interact with the "firstDatabase" object. When another thread requests a DB, a new connection is opened and closed at finishing of the thread.
References Digikam::DbEngineThreadData::closeDatabase(), Digikam::DbEngineThreadData::connectionName, createDatabaseConnection(), currentValidity, threadDataStorage, and Digikam::DbEngineThreadData::valid.
Referenced by handleWithErrorHandler(), and resetDatabaseForThread().
void Digikam::BdEngineBackendPrivate::debugOutputFailedQuery | ( | const QSqlQuery & | query | ) | const |
void Digikam::BdEngineBackendPrivate::debugOutputFailedTransaction | ( | const QSqlError & | error | ) | const |
bool Digikam::BdEngineBackendPrivate::decrementTransactionCount | ( | ) |
References threadDataStorage.
bool Digikam::BdEngineBackendPrivate::handleWithErrorHandler | ( | const DbEngineSqlQuery *const | query | ) |
Returns true if the query shall be retried.
References Digikam::BdEngineBackend::AbortQueries, closeDatabaseForThread(), databaseForThread(), errorHandler, errorLockOperationStatus, Digikam::BdEngineBackend::ExecuteNormal, isConnectionError(), Digikam::DbEngineSqlQuery::lastQuery(), needToConsultUserForError(), operationStatus, setQueryOperationFlag(), Digikam::BdEngineBackend::Wait, and Digikam::BdEngineBackendPrivate::ErrorLocker::wait().
bool Digikam::BdEngineBackendPrivate::incrementTransactionCount | ( | ) |
References threadDataStorage.
void Digikam::BdEngineBackendPrivate::init | ( | const QString & | connectionName, |
DbEngineLocking *const | locking | ||
) |
References backendName, and lock.
Referenced by Digikam::BdEngineBackend::BdEngineBackend(), and Digikam::BdEngineBackend::BdEngineBackend().
bool Digikam::BdEngineBackendPrivate::isConnectionError | ( | const DbEngineSqlQuery & | query | ) | const |
References Digikam::DbEngineParameters::isSQLite(), and parameters.
Referenced by handleWithErrorHandler(), and needToHandleWithErrorHandler().
bool Digikam::BdEngineBackendPrivate::isInMainThread | ( | ) | const |
bool Digikam::BdEngineBackendPrivate::isInUIThread | ( | ) | const |
Referenced by checkRetrySQLiteLockError().
bool Digikam::BdEngineBackendPrivate::isSQLiteLockError | ( | const DbEngineSqlQuery & | query | ) | const |
References Digikam::DbEngineParameters::isSQLite(), and parameters.
bool Digikam::BdEngineBackendPrivate::isSQLiteLockTransactionError | ( | const QSqlError & | lastError | ) | const |
References Digikam::DbEngineParameters::isSQLite(), and parameters.
bool Digikam::BdEngineBackendPrivate::needToConsultUserForError | ( | const DbEngineSqlQuery & | query | ) | const |
Referenced by handleWithErrorHandler(), and needToHandleWithErrorHandler().
bool Digikam::BdEngineBackendPrivate::needToHandleWithErrorHandler | ( | const DbEngineSqlQuery & | query | ) | const |
References isConnectionError(), and needToConsultUserForError().
void Digikam::BdEngineBackendPrivate::queryOperationWakeAll | ( | BdEngineBackend::QueryOperationStatus | status | ) |
Set the wait flag to queryStatus and wake all waiting threads. Typically, call wakeAll with status ExecuteNormal or AbortQueries.
References errorLockCondVar, errorLockMutex, errorLockOperationStatus, operationStatus, and status.
Referenced by connectionErrorAbortQueries(), and connectionErrorContinueQueries().
bool Digikam::BdEngineBackendPrivate::reconnectOnError | ( | ) | const |
References Digikam::DbEngineParameters::isMySQL(), and parameters.
bool Digikam::BdEngineBackendPrivate::resetDatabaseForThread | ( | ) |
References closeDatabaseForThread(), databaseForThread(), and threadDataStorage.
void Digikam::BdEngineBackendPrivate::setDatabaseErrorForThread | ( | const QSqlError & | lastError | ) |
References threadDataStorage.
void Digikam::BdEngineBackendPrivate::setQueryOperationFlag | ( | BdEngineBackend::QueryOperationStatus | status | ) |
Set the wait flag to queryStatus. Typically, call this with Wait.
References errorLockMutex, errorLockOperationStatus, operationStatus, and status.
Referenced by handleWithErrorHandler().
|
virtual |
Reimplemented in Digikam::CoreDbBackendPrivate.
References busyWaitCondVar.
|
friend |
QString Digikam::BdEngineBackendPrivate::backendName |
Referenced by connectionName(), and init().
QWaitCondition Digikam::BdEngineBackendPrivate::busyWaitCondVar |
Referenced by transactionFinished().
QMutex Digikam::BdEngineBackendPrivate::busyWaitMutex |
int Digikam::BdEngineBackendPrivate::currentValidity = 0 |
This compares to DbEngineThreadData's valid. If currentValidity is increased and > valid, the db is marked as invalid
Referenced by databaseForThread().
DbEngineErrorHandler* Digikam::BdEngineBackendPrivate::errorHandler = nullptr |
Referenced by handleWithErrorHandler().
QWaitCondition Digikam::BdEngineBackendPrivate::errorLockCondVar |
Referenced by queryOperationWakeAll().
QMutex Digikam::BdEngineBackendPrivate::errorLockMutex |
Referenced by queryOperationWakeAll(), and setQueryOperationFlag().
BdEngineBackend::QueryOperationStatus Digikam::BdEngineBackendPrivate::errorLockOperationStatus = BdEngineBackend::ExecuteNormal |
Referenced by handleWithErrorHandler(), queryOperationWakeAll(), and setQueryOperationFlag().
bool Digikam::BdEngineBackendPrivate::isInTransaction = false |
DbEngineLocking* Digikam::BdEngineBackendPrivate::lock = nullptr |
BdEngineBackend::QueryOperationStatus Digikam::BdEngineBackendPrivate::operationStatus = BdEngineBackend::ExecuteNormal |
Referenced by checkOperationStatus(), handleWithErrorHandler(), queryOperationWakeAll(), and setQueryOperationFlag().
DbEngineParameters Digikam::BdEngineBackendPrivate::parameters |
BdEngineBackend* const Digikam::BdEngineBackendPrivate::q = nullptr |
BdEngineBackend::Status Digikam::BdEngineBackendPrivate::status = BdEngineBackend::Unavailable |
Referenced by queryOperationWakeAll(), and setQueryOperationFlag().
QThreadStorage<DbEngineThreadData*> Digikam::BdEngineBackendPrivate::threadDataStorage |