bool DatabaseMysql::BeginTransaction() { if (!mMysql) return false; // don't use queued execution if it has not been initialized if (!m_threadBody) { if (tranThread==ZThread::ThreadImpl::current()) return false; // huh? this thread already started transaction mMutex.acquire(); if (!_TransactionCmd("START TRANSACTION")) { mMutex.release(); // can't start transaction return false; } return true; // transaction started } tranThread = ZThread::ThreadImpl::current(); // owner of this transaction TransactionQueues::iterator i = m_tranQueues.find(tranThread); if (i != m_tranQueues.end() && i->second != NULL) // If for thread exists queue and also contains transaction // delete that transaction (not allow trans in trans) delete i->second; m_tranQueues[tranThread] = new SqlTransaction(); return true; }
bool DatabaseMysql::RollbackTransaction() { if (!mMysql) return false; // don't use queued execution if it has not been initialized if (!m_threadBody) { if (tranThread != ACE_Based::Thread::current()) return false; bool _res = _TransactionCmd("ROLLBACK"); tranThread = NULL; mMutex.release(); return _res; } tranThread = ACE_Based::Thread::current(); TransactionQueues::iterator i = m_tranQueues.find(tranThread); if (i != m_tranQueues.end() && i->second != NULL) { delete i->second; i->second = NULL; } return true; }
bool DatabaseMysql::CommitTransaction() { if (!mMysql) return false; // don't use queued execution if it has not been initialized if (!m_threadBody) { if (tranThread != ACE_Based::Thread::current()) return false; bool _res = _TransactionCmd("COMMIT"); tranThread = NULL; mMutex.release(); return _res; } tranThread = ACE_Based::Thread::current(); TransactionQueues::iterator i = m_tranQueues.find(tranThread); if (i != m_tranQueues.end() && i->second != NULL) { m_threadBody->Delay(i->second); i->second = NULL; return true; } else return false; }
bool MySQLConnection::RollbackTransaction() { return _TransactionCmd("ROLLBACK"); }
bool MySQLConnection::CommitTransaction() { return _TransactionCmd("COMMIT"); }
bool MySQLConnection::BeginTransaction() { return _TransactionCmd("START TRANSACTION"); }
bool MySQLConnection::transactionStart() { return _TransactionCmd("START TRANSACTION"); }