MySQL++: transaction.h Source File
transaction.h
Go to the documentation of this file.
/***********************************************************************
Copyright (c) 2006-2009 by Educational Technology Resources, Inc. and
(c) 2008 by AboveNet, Inc. Others may also hold copyrights on code
in this file. See the CREDITS.txt file in the top directory of the
distribution for details.
This file is part of MySQL++.
MySQL++ is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
MySQL++ is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MySQL++; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
***********************************************************************/
#if !defined(MYSQLPP_TRANSACTION_H)
#define MYSQLPP_TRANSACTION_H
#include "common.h"
namespace mysqlpp {
#if !defined(DOXYGEN_IGNORE)
// Make Doxygen ignore this
class MYSQLPP_EXPORT Connection;
#endif
class MYSQLPP_EXPORT Transaction
{
public:
enum IsolationLevel {
read_uncommitted,
read_committed,
repeatable_read,
serializable
};
// the isolation scope will affect.
enum IsolationScope {
this_transaction,
session,
global
};
Transaction(Connection& conn, bool consistent = false);
Transaction(Connection& conn, IsolationLevel level,
IsolationScope scope = this_transaction,
bool consistent = false);
~Transaction();
void commit();
void rollback();
private:
Connection& conn_;
bool finished_;
};
class MYSQLPP_EXPORT NoTransaction
{
public:
NoTransaction(Connection&, bool = false)
{
}
~NoTransaction() { }
void commit() { }
void rollback() { }
};
} // end namespace mysqlpp
#endif // !defined(MYSQLPP_TRANSACTION_H)
mysqlpp::Connection
Manages the connection to the database server.
Definition: connection.h:60
mysqlpp::NoTransaction
Compile-time substitute for Transaction, which purposely does nothing. Use it to instantiate template...
Definition: transaction.h:138
mysqlpp::NoTransaction::rollback
void rollback()
stub to replace Transaction::rollback()
Definition: transaction.h:152
mysqlpp::NoTransaction::commit
void commit()
stub to replace Transaction::commit()
Definition: transaction.h:149
mysqlpp::NoTransaction::NoTransaction
NoTransaction(Connection &, bool=false)
Constructor.
Definition: transaction.h:141
mysqlpp::NoTransaction::~NoTransaction
~NoTransaction()
Destructor.
Definition: transaction.h:146
mysqlpp::Transaction
Helper object for creating exception-safe SQL transactions.
Definition: transaction.h:47
mysqlpp::Transaction::IsolationLevel
IsolationLevel
Transaction isolation levels defined in SQL.
Definition: transaction.h:55
mysqlpp::Transaction::read_uncommitted
@ read_uncommitted
allow "dirty reads" from other transactions
Definition: transaction.h:56
mysqlpp::Transaction::repeatable_read
@ repeatable_read
other transactions do not affect repeated reads in this transaction
Definition: transaction.h:58
mysqlpp::Transaction::read_committed
@ read_committed
only read rows committed by other transactions
Definition: transaction.h:57
mysqlpp::Transaction::IsolationScope
IsolationScope
Isolation level scopes defined in SQL.
Definition: transaction.h:67
mysqlpp::Transaction::session
@ session
change level for all transactions in this session
Definition: transaction.h:69
mysqlpp::Transaction::this_transaction
@ this_transaction
change level for this transaction only
Definition: transaction.h:68
common.h
This file includes top-level definitions for use both internal to the library, and outside it....