digiKam
Digikam::BdEngineBackend Class Reference
+ Inheritance diagram for Digikam::BdEngineBackend:

Classes

class  QueryState
 

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 (const QString &backendName, DbEngineLocking *const locking)
 
 BdEngineBackend (const QString &backendName, DbEngineLocking *const locking, BdEngineBackendPrivate &dd)
 
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)
 
DbEngineAction getDBAction (const QString &actionName) const
 
DbEngineSqlQuery getQuery ()
 
QueryState handleQueryResult (DbEngineSqlQuery &query, QList< QVariant > *const values, QVariant *const lastInsertId)
 
bool isCompatible (const DbEngineParameters &parameters)
 
bool isInTransaction () const
 
bool isOpen () const
 
bool isReady () const
 
QString lastError ()
 
QSqlError lastSQLError ()
 
int maximumBoundValues () const
 
bool open (const DbEngineParameters &parameters)
 
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)
 
 ~BdEngineBackend () override
 

Protected Attributes

BdEngineBackendPrivate *const d_ptr
 

Member Enumeration Documentation

◆ DbType

Enumerator
SQLite 
MySQL 

◆ QueryOperationStatus

Enumerator
ExecuteNormal 
Wait 
AbortQueries 

◆ QueryStateEnum

Enumerator
NoErrors 

No errors occurred while executing the query.

SQLError 

An SQLError has occurred while executing the query.

ConnectionError 

An connection error has occurred while executing the query.

◆ Status

Enumerator
Unavailable 

The database is not available, because it has not been opened yet or because of an error condition.

Open 

The database is open. It has not been verified that the schema is up to date. This status is sufficient for use in a context where it can be assumed that the necessary schema check has been carried out by a master process.

OpenSchemaChecked 

The database is open, and it has been verified that the schema is up to date, or the schema has been updated.

Constructor & Destructor Documentation

◆ BdEngineBackend() [1/2]

Digikam::BdEngineBackend::BdEngineBackend ( const QString &  backendName,
DbEngineLocking *const  locking 
)
explicit

Creates a database backend. The backend name is an arbitrary string that shall be unique for this backend object. It will be used to create unique connection names per backend and thread.

References d_ptr, and Digikam::BdEngineBackendPrivate::init().

◆ BdEngineBackend() [2/2]

Digikam::BdEngineBackend::BdEngineBackend ( const QString &  backendName,
DbEngineLocking *const  locking,
BdEngineBackendPrivate dd 
)

◆ ~BdEngineBackend()

Digikam::BdEngineBackend::~BdEngineBackend ( )
override

References close().

Member Function Documentation

◆ beginTransaction()

BdEngineBackend::QueryState Digikam::BdEngineBackend::beginTransaction ( )

◆ close()

void Digikam::BdEngineBackend::close ( )

Close the database connection. Shall only be called from the thread that called open().

References Unavailable.

Referenced by Digikam::CoreDbCopyManager::copyDatabases(), and ~BdEngineBackend().

◆ commitTransaction()

BdEngineBackend::QueryState Digikam::BdEngineBackend::commitTransaction ( )

Commit the current database transaction

References ConnectionError, lastError(), NoErrors, SQLError, and transactionErrorHandling().

Referenced by execDBAction(), and Digikam::CoreDbTransaction::~CoreDbTransaction().

◆ configElement()

DbEngineConfigSettings Digikam::BdEngineBackend::configElement ( ) const

Return config read from XML, corresponding to this backend's database type.

References Digikam::DbEngineConfig::element().

Referenced by getDBAction().

◆ connectionErrorHandling()

bool Digikam::BdEngineBackend::connectionErrorHandling ( int  retries)

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 open().

◆ copyQuery()

DbEngineSqlQuery Digikam::BdEngineBackend::copyQuery ( const DbEngineSqlQuery old)

Creates a faithful copy of the passed query, with the current db connection.

References getQuery(), Digikam::DbEngineSqlQuery::lastQuery(), Digikam::DbEngineSqlQuery::prepare(), and value.

Referenced by queryErrorHandling().

◆ databaseType()

BdEngineBackend::DbType Digikam::BdEngineBackend::databaseType ( ) const

Return the database type.

Referenced by Digikam::FaceDb::integrityCheck().

◆ exec()

bool Digikam::BdEngineBackend::exec ( DbEngineSqlQuery query)

Calls exec/execBatch on the query, and handles debug output if something went wrong

References queryErrorHandling().

Referenced by execQuery(), and execSql().

◆ execBatch()

bool Digikam::BdEngineBackend::execBatch ( DbEngineSqlQuery query)

References queryErrorHandling().

◆ execDBAction() [1/4]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execDBAction ( const DbEngineAction action,
const QMap< QString, QVariant > &  bindingMap,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

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 beginTransaction(), commitTransaction(), Digikam::DbEngineAction::dbActionElements, execDirectSql(), execDirectSqlWithResult(), execSql(), Digikam::DbEngineActionElement::mode, Digikam::DbEngineAction::mode, Digikam::DbEngineAction::name, NoErrors, SQLError, and Digikam::DbEngineActionElement::statement.

◆ execDBAction() [2/4]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execDBAction ( const DbEngineAction action,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

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(), execDBAction(), execUpsertDBAction(), Digikam::FaceDb::integrityCheck(), Digikam::ItemLister::listTag(), Digikam::FaceDb::setSetting(), Digikam::FaceDb::setting(), and Digikam::FaceDb::vacuum().

◆ execDBAction() [3/4]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execDBAction ( const QString &  action,
const QMap< QString, QVariant > &  bindingMap,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execDBAction(), and getDBAction().

◆ execDBAction() [4/4]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execDBAction ( const QString &  action,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execDBAction(), and getDBAction().

◆ execDBActionQuery() [1/2]

QSqlQuery Digikam::BdEngineBackend::execDBActionQuery ( const DbEngineAction action,
const QMap< QString, QVariant > &  bindingMap 
)

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, execQuery(), Digikam::DbEngineActionElement::mode, Digikam::DbEngineAction::name, and Digikam::DbEngineActionElement::statement.

Referenced by execDBActionQuery().

◆ execDBActionQuery() [2/2]

QSqlQuery Digikam::BdEngineBackend::execDBActionQuery ( const QString &  action,
const QMap< QString, QVariant > &  bindingMap 
)

◆ execDirectSql()

BdEngineBackend::QueryState Digikam::BdEngineBackend::execDirectSql ( const QString &  query)

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 getQuery(), NoErrors, queryErrorHandling(), and SQLError.

Referenced by Digikam::CoreDbCopyManager::copyDatabases(), and execDBAction().

◆ execDirectSqlWithResult()

BdEngineBackend::QueryState Digikam::BdEngineBackend::execDirectSqlWithResult ( const QString &  query,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

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 getQuery(), handleQueryResult(), NoErrors, queryErrorHandling(), and SQLError.

Referenced by execDBAction().

◆ execQuery() [1/12]

DbEngineSqlQuery Digikam::BdEngineBackend::execQuery ( const QString &  sql)

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 exec(), and prepareQuery().

Referenced by execDBActionQuery(), execQuery(), execSql(), Digikam::FaceDb::getClosestNeighborsTreeDb(), Digikam::FaceDb::insertFaceVector(), Digikam::FaceDb::insertToTreeDb(), Digikam::FaceDb::reconstructTree(), and Digikam::FaceDb::trainData().

◆ execQuery() [2/12]

DbEngineSqlQuery Digikam::BdEngineBackend::execQuery ( const QString &  sql,
const QList< QVariant > &  boundValues 
)

References execQuery(), and prepareQuery().

◆ execQuery() [3/12]

DbEngineSqlQuery Digikam::BdEngineBackend::execQuery ( const QString &  sql,
const QMap< QString, QVariant > &  bindingMap 
)

Method which accept a hashmap with key, values which are used for named binding

References exec(), Digikam::DbEngineActionType::getActionValue(), Digikam::DbEngineActionType::isValue(), prepareQuery(), value, and Digikam::DbEngineActionType::value().

◆ execQuery() [4/12]

DbEngineSqlQuery Digikam::BdEngineBackend::execQuery ( const QString &  sql,
const QVariant &  boundValue1 
)

References execQuery(), and prepareQuery().

◆ execQuery() [5/12]

DbEngineSqlQuery Digikam::BdEngineBackend::execQuery ( const QString &  sql,
const QVariant &  boundValue1,
const QVariant &  boundValue2 
)

References execQuery(), and prepareQuery().

◆ execQuery() [6/12]

DbEngineSqlQuery Digikam::BdEngineBackend::execQuery ( const QString &  sql,
const QVariant &  boundValue1,
const QVariant &  boundValue2,
const QVariant &  boundValue3 
)

References execQuery(), and prepareQuery().

◆ execQuery() [7/12]

DbEngineSqlQuery Digikam::BdEngineBackend::execQuery ( const QString &  sql,
const QVariant &  boundValue1,
const QVariant &  boundValue2,
const QVariant &  boundValue3,
const QVariant &  boundValue4 
)

References execQuery(), and prepareQuery().

◆ execQuery() [8/12]

void Digikam::BdEngineBackend::execQuery ( DbEngineSqlQuery preparedQuery,
const QList< QVariant > &  boundValues 
)

References exec().

◆ execQuery() [9/12]

void Digikam::BdEngineBackend::execQuery ( DbEngineSqlQuery preparedQuery,
const QVariant &  boundValue1 
)

Binds the values and executes the prepared query.

References exec().

◆ execQuery() [10/12]

void Digikam::BdEngineBackend::execQuery ( DbEngineSqlQuery preparedQuery,
const QVariant &  boundValue1,
const QVariant &  boundValue2 
)

References exec().

◆ execQuery() [11/12]

void Digikam::BdEngineBackend::execQuery ( DbEngineSqlQuery preparedQuery,
const QVariant &  boundValue1,
const QVariant &  boundValue2,
const QVariant &  boundValue3 
)

References exec().

◆ execQuery() [12/12]

void Digikam::BdEngineBackend::execQuery ( DbEngineSqlQuery preparedQuery,
const QVariant &  boundValue1,
const QVariant &  boundValue2,
const QVariant &  boundValue3,
const QVariant &  boundValue4 
)

References exec().

◆ execSql() [1/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( const QString &  sql,
const QList< QVariant > &  boundValues,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execQuery(), and handleQueryResult().

◆ execSql() [2/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( const QString &  sql,
const QMap< QString, QVariant > &  bindingMap,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

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 execQuery(), and handleQueryResult().

◆ execSql() [3/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::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 
)

References execQuery(), and handleQueryResult().

◆ execSql() [4/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( const QString &  sql,
const QVariant &  boundValue1,
const QVariant &  boundValue2,
const QVariant &  boundValue3,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execQuery(), and handleQueryResult().

◆ execSql() [5/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( const QString &  sql,
const QVariant &  boundValue1,
const QVariant &  boundValue2,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execQuery(), and handleQueryResult().

◆ execSql() [6/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( const QString &  sql,
const QVariant &  boundValue1,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execQuery(), and handleQueryResult().

◆ execSql() [7/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( const QString &  sql,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

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 execQuery(), and handleQueryResult().

Referenced by Digikam::FaceDb::addIdentity(), Digikam::FaceDb::clearDNNTraining(), Digikam::FaceDb::clearIdentities(), Digikam::FaceDb::clearTreeDb(), Digikam::FaceDb::deleteIdentity(), 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(), setForeignKeyChecks(), and Digikam::FaceDb::updateIdentity().

◆ execSql() [8/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( DbEngineSqlQuery preparedQuery,
const QList< QVariant > &  boundValues,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execQuery(), and handleQueryResult().

◆ execSql() [9/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( DbEngineSqlQuery preparedQuery,
const QVariant &  boundValue1,
const QVariant &  boundValue2,
const QVariant &  boundValue3,
const QVariant &  boundValue4,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execQuery(), and handleQueryResult().

◆ execSql() [10/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( DbEngineSqlQuery preparedQuery,
const QVariant &  boundValue1,
const QVariant &  boundValue2,
const QVariant &  boundValue3,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execQuery(), and handleQueryResult().

◆ execSql() [11/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( DbEngineSqlQuery preparedQuery,
const QVariant &  boundValue1,
const QVariant &  boundValue2,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execQuery(), and handleQueryResult().

◆ execSql() [12/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( DbEngineSqlQuery preparedQuery,
const QVariant &  boundValue1,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References execQuery(), and handleQueryResult().

◆ execSql() [13/13]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execSql ( DbEngineSqlQuery preparedQuery,
QList< QVariant > *const  values = nullptr,
QVariant *const  lastInsertId = nullptr 
)

References exec(), and handleQueryResult().

◆ execUpsertDBAction() [1/2]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execUpsertDBAction ( const DbEngineAction action,
const QVariant &  id,
const QStringList &  fieldNames,
const QList< QVariant > &  values 
)

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 execDBAction(), Digikam::DbEngineActionType::fieldEntry(), and Digikam::DbEngineActionType::value().

Referenced by execUpsertDBAction().

◆ execUpsertDBAction() [2/2]

BdEngineBackend::QueryState Digikam::BdEngineBackend::execUpsertDBAction ( const QString &  action,
const QVariant &  id,
const QStringList &  fieldNames,
const QList< QVariant > &  values 
)

◆ getDBAction()

◆ getQuery()

DbEngineSqlQuery Digikam::BdEngineBackend::getQuery ( )

Creates an empty query object waiting for the statement

Referenced by copyQuery(), execDirectSql(), execDirectSqlWithResult(), and prepareQuery().

◆ handleQueryResult()

BdEngineBackend::QueryState Digikam::BdEngineBackend::handleQueryResult ( DbEngineSqlQuery query,
QList< QVariant > *const  values,
QVariant *const  lastInsertId 
)

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 ConnectionError, NoErrors, readToList(), and SQLError.

Referenced by execDirectSqlWithResult(), and execSql().

◆ isCompatible()

bool Digikam::BdEngineBackend::isCompatible ( const DbEngineParameters parameters)

Checks if the parameters can be used for this database backend.

References Digikam::DbEngineParameters::databaseType.

◆ isInTransaction()

bool Digikam::BdEngineBackend::isInTransaction ( ) const

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.

◆ isOpen()

bool Digikam::BdEngineBackend::isOpen ( ) const
inline

◆ isReady()

bool Digikam::BdEngineBackend::isReady ( ) const
inline

◆ lastError()

QString Digikam::BdEngineBackend::lastError ( )

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 commitTransaction(), Digikam::ItemLister::listImageTagPropertySearch(), Digikam::ItemLister::listSearch(), and transactionErrorHandling().

◆ lastSQLError()

QSqlError Digikam::BdEngineBackend::lastSQLError ( )

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().

◆ maximumBoundValues()

int Digikam::BdEngineBackend::maximumBoundValues ( ) const

Returns the maximum number of bound parameters allowed per query. This value depends on the database engine.

Referenced by Digikam::ItemLister::listPAlbum().

◆ open()

bool Digikam::BdEngineBackend::open ( const DbEngineParameters parameters)

Open the database connection.

Returns
true on success

References connectionErrorHandling(), and Open.

Referenced by Digikam::CoreDbPrivilegesChecker::checkPrivileges(), and Digikam::CoreDbCopyManager::copyDatabases().

◆ prepareQuery()

DbEngineSqlQuery Digikam::BdEngineBackend::prepareQuery ( const QString &  sql)

Creates a query object prepared with the statement, waiting for bound values

References getQuery(), Digikam::DbEngineSqlQuery::prepare(), and queryErrorHandling().

Referenced by execQuery(), and Digikam::HaarIface::Private::rebuildSignatureCache().

◆ queryErrorHandling()

bool Digikam::BdEngineBackend::queryErrorHandling ( DbEngineSqlQuery query,
int  retries 
)

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 copyQuery().

Referenced by exec(), execBatch(), execDirectSql(), execDirectSqlWithResult(), and prepareQuery().

◆ readToList()

QList< QVariant > Digikam::BdEngineBackend::readToList ( DbEngineSqlQuery query)

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 handleQueryResult().

◆ rollbackTransaction()

void Digikam::BdEngineBackend::rollbackTransaction ( )

Rollback the current database transaction

◆ setDbEngineErrorHandler()

void Digikam::BdEngineBackend::setDbEngineErrorHandler ( DbEngineErrorHandler *const  handler)

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.

◆ setForeignKeyChecks()

void Digikam::BdEngineBackend::setForeignKeyChecks ( bool  check)

Enables or disables FOREIGN_KEY_CHECKS for the database. This function depends on the database engine.

References execSql().

◆ status()

BdEngineBackend::Status Digikam::BdEngineBackend::status ( ) const

Returns the current status of the database backend

◆ tables()

QStringList Digikam::BdEngineBackend::tables ( )

Returns a list with the names of tables in the database.

◆ transactionErrorHandling()

bool Digikam::BdEngineBackend::transactionErrorHandling ( const QSqlError &  lastError,
int  retries 
)

References lastError().

Referenced by beginTransaction(), and commitTransaction().

Member Data Documentation

◆ d_ptr

BdEngineBackendPrivate* const Digikam::BdEngineBackend::d_ptr
protected

Referenced by BdEngineBackend().


The documentation for this class was generated from the following files: