digiKam
|
Public Types | |
enum | DbType { SQLite , MySQL } |
enum | QueryOperationStatus { ExecuteNormal , Wait , AbortQueries } |
enum | QueryStateEnum { NoErrors , SQLError , ConnectionError } |
enum | Status { Unavailable , Open , OpenSchemaChecked } |
Public Member Functions | |
BdEngineBackend::QueryState | beginTransaction () |
void | close () |
BdEngineBackend::QueryState | commitTransaction () |
DbEngineConfigSettings | configElement () const |
bool | connectionErrorHandling (int retries) |
DbEngineSqlQuery | copyQuery (const DbEngineSqlQuery &old) |
DbType | databaseType () const |
bool | exec (DbEngineSqlQuery &query) |
bool | execBatch (DbEngineSqlQuery &query) |
QueryState | execDBAction (const DbEngineAction &action, const QMap< QString, QVariant > &bindingMap, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execDBAction (const DbEngineAction &action, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execDBAction (const QString &action, const QMap< QString, QVariant > &bindingMap, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execDBAction (const QString &action, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QSqlQuery | execDBActionQuery (const DbEngineAction &action, const QMap< QString, QVariant > &bindingMap) |
QSqlQuery | execDBActionQuery (const QString &action, const QMap< QString, QVariant > &bindingMap) |
QueryState | execDirectSql (const QString &query) |
QueryState | execDirectSqlWithResult (const QString &query, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
DbEngineSqlQuery | execQuery (const QString &sql) |
DbEngineSqlQuery | execQuery (const QString &sql, const QList< QVariant > &boundValues) |
DbEngineSqlQuery | execQuery (const QString &sql, const QMap< QString, QVariant > &bindingMap) |
DbEngineSqlQuery | execQuery (const QString &sql, const QVariant &boundValue1) |
DbEngineSqlQuery | execQuery (const QString &sql, const QVariant &boundValue1, const QVariant &boundValue2) |
DbEngineSqlQuery | execQuery (const QString &sql, const QVariant &boundValue1, const QVariant &boundValue2, const QVariant &boundValue3) |
DbEngineSqlQuery | execQuery (const QString &sql, const QVariant &boundValue1, const QVariant &boundValue2, const QVariant &boundValue3, const QVariant &boundValue4) |
void | execQuery (DbEngineSqlQuery &preparedQuery, const QList< QVariant > &boundValues) |
void | execQuery (DbEngineSqlQuery &preparedQuery, const QVariant &boundValue1) |
void | execQuery (DbEngineSqlQuery &preparedQuery, const QVariant &boundValue1, const QVariant &boundValue2) |
void | execQuery (DbEngineSqlQuery &preparedQuery, const QVariant &boundValue1, const QVariant &boundValue2, const QVariant &boundValue3) |
void | execQuery (DbEngineSqlQuery &preparedQuery, const QVariant &boundValue1, const QVariant &boundValue2, const QVariant &boundValue3, const QVariant &boundValue4) |
QueryState | execSql (const QString &sql, const QList< QVariant > &boundValues, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (const QString &sql, const QMap< QString, QVariant > &bindingMap, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (const QString &sql, const QVariant &boundValue1, const QVariant &boundValue2, const QVariant &boundValue3, const QVariant &boundValue4, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (const QString &sql, const QVariant &boundValue1, const QVariant &boundValue2, const QVariant &boundValue3, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (const QString &sql, const QVariant &boundValue1, const QVariant &boundValue2, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (const QString &sql, const QVariant &boundValue1, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (const QString &sql, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (DbEngineSqlQuery &preparedQuery, const QList< QVariant > &boundValues, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (DbEngineSqlQuery &preparedQuery, const QVariant &boundValue1, const QVariant &boundValue2, const QVariant &boundValue3, const QVariant &boundValue4, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (DbEngineSqlQuery &preparedQuery, const QVariant &boundValue1, const QVariant &boundValue2, const QVariant &boundValue3, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (DbEngineSqlQuery &preparedQuery, const QVariant &boundValue1, const QVariant &boundValue2, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (DbEngineSqlQuery &preparedQuery, const QVariant &boundValue1, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execSql (DbEngineSqlQuery &preparedQuery, QList< QVariant > *const values=nullptr, QVariant *const lastInsertId=nullptr) |
QueryState | execUpsertDBAction (const DbEngineAction &action, const QVariant &id, const QStringList &fieldNames, const QList< QVariant > &values) |
QueryState | execUpsertDBAction (const QString &action, const QVariant &id, const QStringList &fieldNames, const QList< QVariant > &values) |
FaceDbBackend (DbEngineLocking *const locking, const QString &backendName=QLatin1String("faceDatabase-")) | |
DbEngineAction | getDBAction (const QString &actionName) const |
DbEngineSqlQuery | getQuery () |
QueryState | handleQueryResult (DbEngineSqlQuery &query, QList< QVariant > *const values, QVariant *const lastInsertId) |
bool | initSchema (FaceDbSchemaUpdater *const updater) |
bool | isCompatible (const DbEngineParameters ¶meters) |
bool | isInTransaction () const |
bool | isOpen () const |
bool | isReady () const |
QString | lastError () |
QSqlError | lastSQLError () |
int | maximumBoundValues () const |
bool | open (const DbEngineParameters ¶meters) |
DbEngineSqlQuery | prepareQuery (const QString &sql) |
bool | queryErrorHandling (DbEngineSqlQuery &query, int retries) |
QList< QVariant > | readToList (DbEngineSqlQuery &query) |
void | rollbackTransaction () |
void | setDbEngineErrorHandler (DbEngineErrorHandler *const handler) |
void | setForeignKeyChecks (bool check) |
Status | status () const |
QStringList | tables () |
bool | transactionErrorHandling (const QSqlError &lastError, int retries) |
~FaceDbBackend () override | |
Protected Attributes | |
BdEngineBackendPrivate *const | d_ptr |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
explicit |
|
override |
|
inherited |
Begin a database transaction
References Digikam::BdEngineBackend::ConnectionError, Digikam::BdEngineBackend::NoErrors, Digikam::BdEngineBackend::SQLError, and Digikam::BdEngineBackend::transactionErrorHandling().
Referenced by Digikam::CoreDbTransaction::CoreDbTransaction(), and Digikam::BdEngineBackend::execDBAction().
|
inherited |
Close the database connection. Shall only be called from the thread that called open().
References Digikam::BdEngineBackend::Unavailable.
Referenced by Digikam::CoreDbCopyManager::copyDatabases(), and Digikam::BdEngineBackend::~BdEngineBackend().
|
inherited |
Commit the current database transaction
References Digikam::BdEngineBackend::ConnectionError, Digikam::BdEngineBackend::lastError(), Digikam::BdEngineBackend::NoErrors, Digikam::BdEngineBackend::SQLError, and Digikam::BdEngineBackend::transactionErrorHandling().
Referenced by Digikam::BdEngineBackend::execDBAction(), and Digikam::CoreDbTransaction::~CoreDbTransaction().
|
inherited |
Return config read from XML, corresponding to this backend's database type.
References Digikam::DbEngineConfig::element().
Referenced by Digikam::BdEngineBackend::getDBAction().
|
inherited |
Called when an attempted connection to the database failed. If it returns true, retry; if it returns false, bail out. Pass the number of connection retries to help with some decisions.
Referenced by Digikam::BdEngineBackend::open().
|
inherited |
Creates a faithful copy of the passed query, with the current db connection.
References Digikam::BdEngineBackend::getQuery(), Digikam::DbEngineSqlQuery::lastQuery(), Digikam::DbEngineSqlQuery::prepare(), and value.
Referenced by Digikam::BdEngineBackend::queryErrorHandling().
|
inherited |
Return the database type.
Referenced by Digikam::FaceDb::integrityCheck().
|
inherited |
Calls exec/execBatch on the query, and handles debug output if something went wrong
References Digikam::BdEngineBackend::queryErrorHandling().
Referenced by Digikam::BdEngineBackend::execQuery(), and Digikam::BdEngineBackend::execSql().
|
inherited |
References Digikam::BdEngineBackend::queryErrorHandling().
|
inherited |
Performs the database action on the current database. Queries by the specified parameters can have named parameters which are substituted with values from the bindingMap parameter. The result values (if any) are stored within the values list.
References Digikam::BdEngineBackend::beginTransaction(), Digikam::BdEngineBackend::commitTransaction(), Digikam::DbEngineAction::dbActionElements, Digikam::BdEngineBackend::execDirectSql(), Digikam::BdEngineBackend::execDirectSqlWithResult(), Digikam::BdEngineBackend::execSql(), Digikam::DbEngineActionElement::mode, Digikam::DbEngineAction::mode, Digikam::DbEngineAction::name, Digikam::BdEngineBackend::NoErrors, Digikam::BdEngineBackend::SQLError, and Digikam::DbEngineActionElement::statement.
|
inherited |
Performs the database action on the current database. Queries by the specified parameters mustn't have named parameters. The result values (if any) are stored within the values list.
Referenced by Digikam::CoreDbPrivilegesChecker::checkPriv(), Digikam::CoreDbCopyManager::copyDatabases(), Digikam::BdEngineBackend::execDBAction(), Digikam::BdEngineBackend::execUpsertDBAction(), Digikam::FaceDb::integrityCheck(), Digikam::ItemLister::listTag(), Digikam::FaceDb::setSetting(), Digikam::FaceDb::setting(), and Digikam::FaceDb::vacuum().
|
inherited |
|
inherited |
|
inherited |
Performs the database action on the current database. Queries by the specified parameters can have named parameters which are substituted with values from the bindingMap parameter. The result values (if any) are stored within the values list. This method returns the last query, which is used to handle special cases.
References Digikam::DbEngineAction::dbActionElements, Digikam::BdEngineBackend::execQuery(), Digikam::DbEngineActionElement::mode, Digikam::DbEngineAction::name, and Digikam::DbEngineActionElement::statement.
Referenced by Digikam::BdEngineBackend::execDBActionQuery().
|
inherited |
|
inherited |
Calls exec on the query, and handles debug output if something went wrong. The query is not prepared, which can be fail in certain situations (e.g. trigger statements on QMYSQL).
References Digikam::BdEngineBackend::getQuery(), Digikam::BdEngineBackend::NoErrors, Digikam::BdEngineBackend::queryErrorHandling(), and Digikam::BdEngineBackend::SQLError.
Referenced by Digikam::CoreDbCopyManager::copyDatabases(), and Digikam::BdEngineBackend::execDBAction().
|
inherited |
Calls exec on the query, and handles debug output if something went wrong. The query is not prepared, which can be fail in certain situations (e.g. trigger statements on QMYSQL).
References Digikam::BdEngineBackend::getQuery(), Digikam::BdEngineBackend::handleQueryResult(), Digikam::BdEngineBackend::NoErrors, Digikam::BdEngineBackend::queryErrorHandling(), and Digikam::BdEngineBackend::SQLError.
Referenced by Digikam::BdEngineBackend::execDBAction().
|
inherited |
Executes the statement and returns the query object. Methods are provided for up to four bound values (positional binding), or for a list of bound values.
References Digikam::BdEngineBackend::exec(), and Digikam::BdEngineBackend::prepareQuery().
Referenced by Digikam::BdEngineBackend::execDBActionQuery(), Digikam::BdEngineBackend::execQuery(), Digikam::BdEngineBackend::execSql(), Digikam::FaceDb::getClosestNeighborsTreeDb(), Digikam::FaceDb::insertFaceVector(), Digikam::FaceDb::insertToTreeDb(), Digikam::FaceDb::reconstructTree(), and Digikam::FaceDb::trainData().
|
inherited |
|
inherited |
Method which accept a hashmap with key, values which are used for named binding
References Digikam::BdEngineBackend::exec(), Digikam::DbEngineActionType::getActionValue(), Digikam::DbEngineActionType::isValue(), Digikam::BdEngineBackend::prepareQuery(), value, and Digikam::DbEngineActionType::value().
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
References Digikam::BdEngineBackend::exec().
|
inherited |
Binds the values and executes the prepared query.
References Digikam::BdEngineBackend::exec().
|
inherited |
References Digikam::BdEngineBackend::exec().
|
inherited |
References Digikam::BdEngineBackend::exec().
|
inherited |
References Digikam::BdEngineBackend::exec().
|
inherited |
|
inherited |
Method which accepts a map for named binding. For special cases it's also possible to add a DbEngineActionType which wraps another data object (also lists or maps) which can be used as field entry or as value (where it's prepared with positional binding). See more on DbEngineActionType class. If the wrapped data object is an instance of list, then the elements are separated by comma. If the wrapped data object is an instance of map, then the elements are inserted in the following way: key1=value1, key2=value2,...,keyN=valueN.
References Digikam::BdEngineBackend::execQuery(), and Digikam::BdEngineBackend::handleQueryResult().
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
Executes the SQL statement, and write the returned data into the values list. If you are not interested in the returned data, set values to 0. Methods are provided for up to four bound values (positional binding), or for a list of bound values. If you want the last inserted id (and your query is suitable), set lastInsertId to the address of a QVariant. Additionally, methods are provided for prepared statements.
References Digikam::BdEngineBackend::execQuery(), and Digikam::BdEngineBackend::handleQueryResult().
Referenced by Digikam::FaceDb::addIdentity(), Digikam::FaceDb::clearDNNTraining(), Digikam::FaceDb::clearIdentities(), Digikam::FaceDb::clearTreeDb(), Digikam::FaceDb::deleteIdentity(), Digikam::BdEngineBackend::execDBAction(), Digikam::FaceDb::getNumberOfIdentities(), Digikam::FaceDb::identities(), Digikam::FaceDb::identityIds(), Digikam::ItemLister::listAreaRange(), Digikam::ItemLister::listDateRange(), Digikam::ItemLister::listFaces(), Digikam::ItemLister::listImageTagPropertySearch(), Digikam::ItemLister::listPAlbum(), Digikam::ItemLister::listSearch(), Digikam::HaarIface::retrieveSignatureFromDB(), Digikam::BdEngineBackend::setForeignKeyChecks(), and Digikam::FaceDb::updateIdentity().
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
Performs a special DBAction that is usually needed to "INSERT or UPDATE" entries in a table. The corresponding DBAction must contain exactly the named parameters :id, :fieldValueList, :fieldList and :valueList. You pass the value to be bound to the ":id" field, then two lists of the same size: The first containing the field names, the second one containing the values as QVariants ready for binding.
References Digikam::BdEngineBackend::execDBAction(), Digikam::DbEngineActionType::fieldEntry(), and Digikam::DbEngineActionType::value().
Referenced by Digikam::BdEngineBackend::execUpsertDBAction().
|
inherited |
|
inherited |
Returns a database action with name, specified in actionName, for the current database.
References Digikam::BdEngineBackend::configElement(), Digikam::DbEngineAction::name, and Digikam::DbEngineConfigSettings::sqlStatements.
Referenced by Digikam::CoreDbCopyManager::copyDatabases(), Digikam::BdEngineBackend::execDBAction(), Digikam::BdEngineBackend::execDBActionQuery(), Digikam::BdEngineBackend::execUpsertDBAction(), Digikam::FaceDb::integrityCheck(), Digikam::ItemLister::listTag(), Digikam::FaceDb::setSetting(), Digikam::FaceDb::setting(), and Digikam::FaceDb::vacuum().
|
inherited |
Creates an empty query object waiting for the statement
Referenced by Digikam::BdEngineBackend::copyQuery(), Digikam::BdEngineBackend::execDirectSql(), Digikam::BdEngineBackend::execDirectSqlWithResult(), and Digikam::BdEngineBackend::prepareQuery().
|
inherited |
Checks if there was a connection error. If so BdEngineBackend::ConnectionError is returned. If not, the values are extracted from the query and inserted in the values list, the last insertion id is taken from the query and BdEngineBackend::NoErrors is returned.
References Digikam::BdEngineBackend::ConnectionError, Digikam::BdEngineBackend::NoErrors, Digikam::BdEngineBackend::readToList(), and Digikam::BdEngineBackend::SQLError.
Referenced by Digikam::BdEngineBackend::execDirectSqlWithResult(), and Digikam::BdEngineBackend::execSql().
bool Digikam::FaceDbBackend::initSchema | ( | FaceDbSchemaUpdater *const | updater | ) |
Initialize the database schema to the current version, carry out upgrades if necessary. Shall only be called from the thread that called open().
References Digikam::BdEngineBackend::OpenSchemaChecked, Digikam::BdEngineBackend::Unavailable, and Digikam::FaceDbSchemaUpdater::update().
|
inherited |
Checks if the parameters can be used for this database backend.
References Digikam::DbEngineParameters::databaseType.
|
inherited |
Returns if the database is in a different thread in a transaction. Note that a transaction does not require holding CoreDbAccess. Note that this does not give information about other processes locking the database.
|
inlineinherited |
|
inlineinherited |
|
inherited |
Returns a description of the last error that occurred on this database. Use CoreDbAccess::lastError for errors presented to the user. This error will be included in that message. It may be empty.
Referenced by Digikam::BdEngineBackend::commitTransaction(), Digikam::ItemLister::listImageTagPropertySearch(), Digikam::ItemLister::listSearch(), and Digikam::BdEngineBackend::transactionErrorHandling().
|
inherited |
Returns the last error that occurred on this database. Use CoreDbAccess::lastError for errors presented to the user. It may be empty.
Referenced by Digikam::CoreDbPrivilegesChecker::checkPriv().
|
inherited |
Returns the maximum number of bound parameters allowed per query. This value depends on the database engine.
Referenced by Digikam::ItemLister::listPAlbum().
|
inherited |
Open the database connection.
References Digikam::BdEngineBackend::connectionErrorHandling(), and Digikam::BdEngineBackend::Open.
Referenced by Digikam::CoreDbPrivilegesChecker::checkPrivileges(), and Digikam::CoreDbCopyManager::copyDatabases().
|
inherited |
Creates a query object prepared with the statement, waiting for bound values
References Digikam::BdEngineBackend::getQuery(), Digikam::DbEngineSqlQuery::prepare(), and Digikam::BdEngineBackend::queryErrorHandling().
Referenced by Digikam::BdEngineBackend::execQuery(), and Digikam::HaarIface::Private::rebuildSignatureCache().
|
inherited |
Called with a failed query. Handles certain known errors and debug output. If it returns true, reexecute the query; if it returns false, return it as failed. Pass the number of retries already done for this query to help with some decisions.
References Digikam::BdEngineBackend::copyQuery().
Referenced by Digikam::BdEngineBackend::exec(), Digikam::BdEngineBackend::execBatch(), Digikam::BdEngineBackend::execDirectSql(), Digikam::BdEngineBackend::execDirectSqlWithResult(), and Digikam::BdEngineBackend::prepareQuery().
|
inherited |
Reads data of returned result set into a list which is returned. The read process is column wise, which means all data elements of a row is read, then the resultset is switched to the next row.
Referenced by Digikam::BdEngineBackend::handleQueryResult().
|
inherited |
Rollback the current database transaction
|
inherited |
Add a DbEngineErrorHandler. This object must be created in the main thread. If a database error occurs, this object can handle problem solving and user interaction.
|
inherited |
Enables or disables FOREIGN_KEY_CHECKS for the database. This function depends on the database engine.
References Digikam::BdEngineBackend::execSql().
|
inherited |
Returns the current status of the database backend
|
inherited |
Returns a list with the names of tables in the database.
|
inherited |
References Digikam::BdEngineBackend::lastError().
Referenced by Digikam::BdEngineBackend::beginTransaction(), and Digikam::BdEngineBackend::commitTransaction().
|
protectedinherited |
Referenced by Digikam::BdEngineBackend::BdEngineBackend().