MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
Public 成员函数 | Private 类型 | Private 成员函数 | Private 属性 | 静态 Private 属性 | 所有成员列表
MvccTrx类 参考

多版本并发事务TODO 没有垃圾回收 更多...

#include <mvcc_trx.h>

类 MvccTrx 继承关系图:
Trx

Public 成员函数

 MvccTrx (MvccTrxKit &trx_kit, LogHandler &log_handler)
 构造函数 更多...
 
 MvccTrx (MvccTrxKit &trx_kit, LogHandler &log_handler, int32_t trx_id)
 
RC insert_record (Table *table, Record &record) override
 
RC delete_record (Table *table, Record &record) override
 
RC visit_record (Table *table, Record &record, ReadWriteMode mode) override
 当访问到某条数据时,使用此函数来判断是否可见,或者是否有访问冲突 更多...
 
RC start_if_need () override
 
RC commit () override
 
RC rollback () override
 
RC redo (Db *db, const LogEntry &log_entry) override
 
int32_t id () const override
 
virtual RC insert_record (Table *table, Record &record)=0
 
virtual RC delete_record (Table *table, Record &record)=0
 
virtual RC visit_record (Table *table, Record &record, ReadWriteMode mode)=0
 
virtual RC start_if_need ()=0
 
virtual RC commit ()=0
 
virtual RC rollback ()=0
 
virtual RC redo (Db *db, const LogEntry &log_entry)=0
 
virtual int32_t id () const =0
 

Private 类型

using OperationSet = vector< Operation >
 

Private 成员函数

RC commit_with_trx_id (int32_t commit_id)
 
void trx_fields (Table *table, Field &begin_xid_field, Field &end_xid_field) const
 获取指定表上的事务使用的字段 更多...
 

Private 属性

MvccTrxKittrx_kit_
 
MvccTrxLogHandler log_handler_
 
int32_t trx_id_ = -1
 
bool started_ = false
 
bool recovering_ = false
 
OperationSet operations_
 

静态 Private 属性

static const int32_t MAX_TRX_ID = numeric_limits<int32_t>::max()
 

详细描述

多版本并发事务

TODO 没有垃圾回收

构造及析构函数说明

◆ MvccTrx()

MvccTrx::MvccTrx ( MvccTrxKit trx_kit,
LogHandler log_handler 
)

构造函数

注解
外部不应该直接调用该构造函数,而应该使用TrxKit::create_trx()来创建事务, 创建事务时,TrxKit会有一些内部信息需要记录

成员函数说明

◆ commit()

RC MvccTrx::commit ( )
overridevirtual

实现了 Trx.

◆ delete_record()

RC MvccTrx::delete_record ( Table table,
Record record 
)
overridevirtual

实现了 Trx.

◆ id()

int32_t MvccTrx::id ( ) const
inlineoverridevirtual

实现了 Trx.

◆ insert_record()

RC MvccTrx::insert_record ( Table table,
Record record 
)
overridevirtual

实现了 Trx.

◆ redo()

RC MvccTrx::redo ( Db db,
const LogEntry log_entry 
)
overridevirtual

实现了 Trx.

◆ rollback()

RC MvccTrx::rollback ( )
overridevirtual

实现了 Trx.

◆ start_if_need()

RC MvccTrx::start_if_need ( )
overridevirtual

实现了 Trx.

◆ trx_fields()

void MvccTrx::trx_fields ( Table table,
Field begin_xid_field,
Field end_xid_field 
) const
private

获取指定表上的事务使用的字段

参数
table指定的表
begin_xid_field返回处理begin_xid的字段
end_xid_field返回处理end_xid的字段

◆ visit_record()

RC MvccTrx::visit_record ( Table table,
Record record,
ReadWriteMode  mode 
)
overridevirtual

当访问到某条数据时,使用此函数来判断是否可见,或者是否有访问冲突

参数
table要访问的数据属于哪张表
record要访问哪条数据
mode是否只读访问
返回
RC - SUCCESS 成功
  • RECORD_INVISIBLE 此数据对当前事务不可见,应该跳过
  • LOCKED_CONCURRENCY_CONFLICT 与其它事务有冲突

实现了 Trx.


该类的文档由以下文件生成: