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, CLogManager *log_manager)
 
 MvccTrx (MvccTrxKit &trx_kit, 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, bool readonly) override
 当访问到某条数据时,使用此函数来判断是否可见,或者是否有访问冲突 更多...
 
RC start_if_need () override
 
RC commit () override
 
RC rollback () override
 
RC redo (Db *db, const CLogRecord &log_record) 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, bool readonly)=0
 
virtual RC start_if_need ()=0
 
virtual RC commit ()=0
 
virtual RC rollback ()=0
 
virtual RC redo (Db *db, const CLogRecord &log_record)
 
virtual int32_t id () const =0
 

Private 类型

using OperationSet = std::unordered_set< Operation, OperationHasher, OperationEqualer >
 

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_
 
CLogManagerlog_manager_ = nullptr
 
int32_t trx_id_ = -1
 
bool started_ = false
 
bool recovering_ = false
 
OperationSet operations_
 

静态 Private 属性

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

详细描述

多版本并发事务

TODO 没有垃圾回收

成员函数说明

◆ commit()

RC MvccTrx::commit ( )
overridevirtual

实现了 Trx.

◆ delete_record()

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

在删除之前,第一次获取record时,就已经对record做了对应的检查,并且保证不会有其它的事务来访问这条数据

实现了 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 CLogRecord log_record 
)
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,
bool  readonly 
)
overridevirtual

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

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

实现了 Trx.


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