postgresql的transaction
来源:互联网 发布:java软件编程培训机构 编辑:程序博客网 时间:2024/05/29 16:27
从odb的源码中看出了,其实和其它的数据库一样,也都是三条命令。
// file : odb/pgsql/transaction-impl.cxx
// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC// license : GNU GPL v2; see accompanying LICENSE file
#include <cassert>
#include <libpq-fe.h>
#include <odb/tracer.hxx>
#include <odb/pgsql/database.hxx>
#include <odb/pgsql/connection.hxx>
#include <odb/pgsql/error.hxx>
#include <odb/pgsql/exceptions.hxx>
#include <odb/pgsql/transaction-impl.hxx>
#include <odb/pgsql/auto-handle.hxx>
namespace odb
{
namespace pgsql
{
transaction_impl::
transaction_impl (database_type& db)
: odb::transaction_impl (db)
{
}
transaction_impl::
transaction_impl (connection_ptr c)
: odb::transaction_impl (c->database (), *c), connection_ (c)
{
}
transaction_impl::
~transaction_impl ()
{
}
void transaction_impl::
start ()
{
// Grab a connection if we don't already have one.
//
if (connection_ == 0)
{
connection_ = static_cast<database_type&> (database_).connection ();
odb::transaction_impl::connection_ = connection_.get ();
}
{
odb::tracer* t;
if ((t = connection_->tracer ()) || (t = database_.tracer ()))
t->execute (*connection_, "BEGIN");
}
auto_handle<PGresult> h (PQexec (connection_->handle (), "begin"));
if (!h || PGRES_COMMAND_OK != PQresultStatus (h))
translate_error (*connection_, h);
}
void transaction_impl::
commit ()
{
// Invalidate query results.
//
connection_->invalidate_results ();
{
odb::tracer* t;
if ((t = connection_->tracer ()) || (t = database_.tracer ()))
t->execute (*connection_, "COMMIT");
}
auto_handle<PGresult> h (PQexec (connection_->handle (), "commit"));
if (!h || PGRES_COMMAND_OK != PQresultStatus (h))
translate_error (*connection_, h);
// Release the connection.
//
connection_.reset ();
}
void transaction_impl::
rollback ()
{
// Invalidate query results.
//
connection_->invalidate_results ();
{
odb::tracer* t;
if ((t = connection_->tracer ()) || (t = database_.tracer ()))
t->execute (*connection_, "ROLLBACK");
}
auto_handle<PGresult> h (PQexec (connection_->handle (), "rollback"));
if (!h || PGRES_COMMAND_OK != PQresultStatus (h))
translate_error (*connection_, h);
// Release the connection.
//
connection_.reset ();
}
}
}
0 0
- postgresql的transaction
- 请勿滥用 2PC, 忘记提交prepared transaction对PostgreSQL造成的危害.
- PostgreSQL's read only transaction mode
- PostgreSQL's read only transaction mode
- Compare PostgreSQL and Oracle dead lock detect and transaction
- postgresql错误解决 ERROR:current transaction is aborted
- PostgreSQL错误解决:ERROR: current transaction is aborted, commands ignored until end of transaction blockp
- postgresql ERROR: current transaction is aborted, commands ignored until end of transaction block
- PostgreSQL错误解决:ERROR: current transaction is aborted, commands ignored until end of transaction bloc
- Transaction管理的实现
- Hibernate的Transaction SessionFactory
- Mysql的transaction实现
- TRANSACTION的执行过程
- 关于Hibernate的Transaction
- MySQL的Transaction
- Hibernate 的 Transaction接口
- sql的transaction用法
- Hibernate的transaction嵌套
- GNSS系统
- 【剑指Offer面试编程题】题目1513:二进制中1的个数--九度OJ
- test
- 在eclipse中将android项目生成apk并且给apk签名
- Poj 2182-Lost Cows(Treap||树状数组+二分答案)
- postgresql的transaction
- UE复制内容,粘贴到source insight的时候不会自动换行,而是显示为很长一行
- Unity3D学习之(脚本编辑器实现各种类的操作)
- cts4.0测试
- HDU 1372 Knight Moves(BFS)
- 计算机科学经典著作
- 时间序列分析基础
- fork讲解
- Android HAL基础