#include <locker_qsql.hpp>
|
ErrCode | init (const std::string &mutex_name, const size_t timeout) |
|
ErrCode | db_create_locks_table () const |
|
ErrCode | db_get_locks_num (const std::string &name, const LockType <, unsigned int &locks_num) const |
|
ErrCode | db_clear_invalid_locks () |
|
ErrCode | db_init (const hds::db::ContextQSql &context) |
|
ErrCode | db_close (const hds::db::ContextQSql &context) |
|
ErrCode | db_lock_tables (const TLDVec &tld_vec) |
|
ErrCode | db_release_tables_locks () |
|
ErrCode | db_get_lock (const std::string &lock_name, const size_t timeout=3) const |
|
ErrCode | db_release_lock (const std::string &lock_name) const |
|
ErrCode | db_set_item_value (const std::string &table_name, const std::string &field_name, const std::string &key_name, const DbIndex &key_id, const std::string &value) |
|
ErrCode | db_get_item_value (const std::string &table_name, const std::string &field_name, const std::string &key_name, const DbIndex &key_id, std::string &value) const |
|
time_t | db_table_creation_time (const std::string &table_name, ErrCode *prc=NULL) const |
|
time_t | db_table_modification_time (const std::string &table_name, ErrCode *prc=NULL) const |
|
quint64 | db_table_size (const std::string &table_name, ErrCode *prc=NULL) const |
|
size_t | db_table_rows_num (const std::string &table_name, ErrCode *prc=NULL) const |
|
ErrCode | db_transaction_begin () const |
|
ErrCode | db_transaction_commit () |
|
ErrCode | db_transaction_rollback () |
|
QString | get_db_name_hash (const hds::db::ContextQSql &context) const |
|
hds::db::LockerQSql::LockerQSql |
( |
const QSqlDatabase & |
db, |
|
|
const std::string & |
name = "hds_db_locker" , |
|
|
const size_t |
timeout = 1 |
|
) |
| |
Construct locker with provided database mutex name.
If name is not empty then access to locks is blocked for any SQL connection until the object is destroyed. After initialization lastError() may return: EC_LOCKED_WRITE if access to locks timed out, EC_UNDEFINED on internal SQL error, EC_NO_ERROR on success.
- Parameters
-
db | Qt SQL database interface. Has to be initialized, just copied inside. |
name | Name of the locker (database mutex name). |
timeout | (s) waiting timeout. |
hds::db::LockerQSql::LockerQSql |
( |
const ContextQSql & |
dbc, |
|
|
const std::string & |
name = "hds_db_locker" , |
|
|
const size_t |
timeout = 1 |
|
) |
| |
Construct locker with provided database mutex name.
If name is not empty then access to locks is blocked for any SQL connection until the object is destroyed. New database connection is created. After initialization lastError() may return: EC_LOCKED_WRITE if access to locks timed out, EC_UNDEFINED on internal SQL error, EC_NO_ERROR on success.
- Parameters
-
dbc | Database context. |
mutex_name | Name of the locker (database mutex name). |
timeout | (s) waiting timeout. |
virtual hds::db::LockerQSql::~LockerQSql |
( |
| ) |
|
|
virtual |
Unlock access to locks and destroy object.
ErrCode hds::db::LockerQSql::db_clear_invalid_locks |
( |
| ) |
|
|
protected |
Clear locks with ids of not connected clients.
- Returns
- EC_NO_ERROR if ok, corresponednt error code otherwise.
ErrCode hds::db::LockerQSql::db_create_locks_table |
( |
| ) |
const |
|
protected |
Creates table of locks.
- Returns
- EC_NO_ERROR if ok, corresponednt error code otherwise.
ErrCode hds::db::LockerQSql::db_get_locks_num |
( |
const std::string & |
name, |
|
|
const LockType & |
lt, |
|
|
unsigned int & |
locks_num |
|
) |
| const |
|
protected |
Get number of locks with provided name and type.
- Parameters
-
name | Name of lock. |
lt | Type of locks to be counted. |
locks_num | Resulted number of locks in database. |
- Returns
- EC_NO_ERROR if ok, correspondent error code otherwise.
ErrCode hds::db::LockerQSql::init |
( |
const std::string & |
mutex_name, |
|
|
const size_t |
timeout |
|
) |
| |
|
protected |
Initialize locker.
- Parameters
-
mutex_name | Name of the tatabase mutex. |
timeout | (s) waiting timeout. |
- Returns
- EC_LOCKED_WRITE if access to locks timed out, EC_UNDEFINED on internal SQL error, EC_NO_ERROR on success.
virtual ErrCode hds::db::LockerQSql::lastError |
( |
| ) |
const |
|
virtual |
Get list of database locks. lastError() will return:
EC_UNDEFINED on internal error, EC_NO_ERROR on success.
- Parameters
-
locks | Resulted list of locks. |
Implements hds::db::Locker.
Try to obtain a lock with provided name. lastError() may return:
EC_LOCKED_READ if can't obtain lock because provided name locked for reading, EC_LOCKED_WRITE if can't obtain lock because provided name locked for writing, EC_UNDEFINED on internal SQL error, EC_NO_ERROR if lock is obtained successfully.
- Parameters
-
lock_descr | Description of the lock. |
- Returns
- Uniq index of lock obtained on success. Has no means on error.
Implements hds::db::Locker.
virtual void hds::db::LockerQSql::release |
( |
const DbIndex & |
id | ) |
|
|
virtual |
Tries to release lock with provided id. lastError() may return:
EC_UNDEFINED on internal SQL error, EC_NO_ERROR on success.
- Parameters
-
id | Uniq index of lock to be released. |
Implements hds::db::Locker.
virtual size_t hds::db::LockerQSql::releaseAll |
( |
| ) |
|
|
virtual |
Tries to release all locks. lastError() may return:
EC_UNDEFINED on internal SQL error, EC_NO_ERROR on success.
- Returns
- number of locks released.
Implements hds::db::Locker.
The documentation for this class was generated from the following file:
- /net/opt/univers/ubp-i-15.3-centos7-x64.urij/include/hds_db/qsql/locker_qsql.hpp