Class: Innodb::UndoLog

Inherits:
Object
  • Object
show all
Defined in:
lib/innodb/undo_log.rb

Defined Under Namespace

Classes: UndoRecordCursor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, position) ⇒ UndoLog

Returns a new instance of UndoLog.



6
7
8
9
# File 'lib/innodb/undo_log.rb', line 6

def initialize(page, position)
  @page = page
  @position = position
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



4
5
6
# File 'lib/innodb/undo_log.rb', line 4

def page
  @page
end

#positionObject (readonly)

Returns the value of attribute position.



5
6
7
# File 'lib/innodb/undo_log.rb', line 5

def position
  @position
end

Instance Method Details

#dumpObject



129
130
131
132
133
# File 'lib/innodb/undo_log.rb', line 129

def dump
  puts "header:"
  pp header
  puts
end

#first_undo_record_cursorObject



125
126
127
# File 'lib/innodb/undo_log.rb', line 125

def first_undo_record_cursor
  undo_record_cursor(header[:log_start_offset])
end

#headerObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/innodb/undo_log.rb', line 19

def header
  @header ||= page.cursor(@position).name("header") do |c|
    xid_flag = nil
    {
      :trx_id => c.name("trx_id") { c.get_uint64 },
      :trx_no => c.name("trx_no") { c.get_uint64 },
      :delete_mark_flag => c.name("delete_mark_flag") { (c.get_uint16 != 0) },
      :log_start_offset => c.name("log_start_offset") { c.get_uint16 },
      :xid_flag => c.name("xid_flag") { xid_flag = (c.get_uint8 != 0) },
      :ddl_flag => c.name("ddl_flag") { (c.get_uint8 != 0) },
      :ddl_table_id => c.name("ddl_table_id") { c.get_uint64 },
      :next_log_offset => c.name("next_log_offset") { c.get_uint16 },
      :prev_log_offset => c.name("prev_log_offset") { c.get_uint16 },
      :history_list_node => c.name("history_list_node") {
        Innodb::List.get_node(c)
      },
      :xid => c.name("xid") {
        if xid_flag
          {
            :format => c.name("format") { c.get_uint32 },
            :trid_len => c.name("trid_len") { c.get_uint32 },
            :bqual_len => c.name("bqual_len") { c.get_uint32 },
            :data => c.name("data") { c.get_bytes(128) },
          }
        end
      },
    }
  end
end

#min_undo_recordObject



63
64
65
# File 'lib/innodb/undo_log.rb', line 63

def min_undo_record
  undo_record(header[:log_start_offset])
end

#next_addressObject



53
54
55
# File 'lib/innodb/undo_log.rb', line 53

def next_address
  header[:history_list_node][:next]
end

#prev_addressObject



49
50
51
# File 'lib/innodb/undo_log.rb', line 49

def prev_address
  header[:history_list_node][:prev]
end

#size_headerObject



15
16
17
# File 'lib/innodb/undo_log.rb', line 15

def size_header
  8 + 8 + 2 + 2 + 1 + 1 + 8 + 2 + 2 + Innodb::List::NODE_SIZE + size_xa_header
end

#size_xa_headerObject



11
12
13
# File 'lib/innodb/undo_log.rb', line 11

def size_xa_header
  4 + 4 + 4 + 128
end

#undo_record(offset) ⇒ Object



57
58
59
60
61
# File 'lib/innodb/undo_log.rb', line 57

def undo_record(offset)
  new_undo_record = Innodb::UndoRecord.new(page, offset)
  new_undo_record.undo_log = self
  new_undo_record
end

#undo_record_cursor(offset, direction = :forward) ⇒ Object



121
122
123
# File 'lib/innodb/undo_log.rb', line 121

def undo_record_cursor(offset, direction=:forward)
  UndoRecordCursor.new(self, offset, direction)
end