Class: Innodb::Page::UndoLog

Inherits:
Innodb::Page show all
Defined in:
lib/innodb/page/undo_log.rb

Defined Under Namespace

Classes: PageHeader, SegmentHeader

Constant Summary collapse

UNDO_PAGE_TYPES =
{
  1 => :insert,
  2 => :update,
}.freeze
UNDO_SEGMENT_STATES =
{
  1 => :active,
  2 => :cached,
  3 => :to_free,
  4 => :to_purge,
  5 => :prepared,
}.freeze

Constants inherited from Innodb::Page

PAGE_TYPE, PAGE_TYPE_BY_VALUE, UNDEFINED_PAGE_NUMBER

Instance Attribute Summary

Attributes inherited from Innodb::Page

#space

Instance Method Summary collapse

Methods inherited from Innodb::Page

#checksum_crc32, #checksum_crc32?, #checksum_innodb, #checksum_innodb?, #checksum_invalid?, #checksum_type, #checksum_valid?, #corrupt?, #cursor, #default_page_size?, #each_page_body_byte_as_uint8, #each_page_header_byte_as_uint8, #each_region, #extent_descriptor?, #fil_header, #fil_trailer, handle, #in_doublewrite_buffer?, #initialize, #inspect, #inspect_header_fields, maybe_undefined, #misplaced?, #misplaced_offset?, #misplaced_space?, #name, page_type_by_value, parse, #pos_fil_header, #pos_fil_trailer, #pos_page_body, #pos_partial_page_header, register_specialization, #size, #size_fil_header, #size_fil_trailer, #size_page_body, #size_partial_page_header, specialization_for, specialization_for?, #torn?, undefined?

Constructor Details

This class inherits a constructor from Innodb::Page

Instance Method Details

#dumpObject

Dump the contents of a page for debugging purposes.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/innodb/page/undo_log.rb', line 92

def dump
  super

  puts "undo page header:"
  pp undo_page_header
  puts

  puts "undo segment header:"
  pp undo_segment_header
  puts

  puts "last undo log:"
  undo_log(undo_segment_header[:last_log_offset]).dump unless undo_segment_header[:last_log_offset].zero?
  puts
end

#next_addressObject



72
73
74
# File 'lib/innodb/page/undo_log.rb', line 72

def next_address
  undo_page_header[:page_list_node][:next]
end

#pos_undo_logsObject



40
41
42
# File 'lib/innodb/page/undo_log.rb', line 40

def pos_undo_logs
  pos_undo_segment_header + size_undo_segment_header
end

#pos_undo_page_headerObject



24
25
26
# File 'lib/innodb/page/undo_log.rb', line 24

def pos_undo_page_header
  pos_page_body
end

#pos_undo_segment_headerObject



32
33
34
# File 'lib/innodb/page/undo_log.rb', line 32

def pos_undo_segment_header
  pos_undo_page_header + size_undo_page_header
end

#prev_addressObject



68
69
70
# File 'lib/innodb/page/undo_log.rb', line 68

def prev_address
  undo_page_header[:page_list_node][:prev]
end

#size_undo_page_headerObject



28
29
30
# File 'lib/innodb/page/undo_log.rb', line 28

def size_undo_page_header
  2 + 2 + 2 + Innodb::List::NODE_SIZE
end

#size_undo_segment_headerObject



36
37
38
# File 'lib/innodb/page/undo_log.rb', line 36

def size_undo_segment_header
  2 + 2 + Innodb::FsegEntry::SIZE + Innodb::List::BASE_NODE_SIZE
end

#undo_log(pos) ⇒ Object



87
88
89
# File 'lib/innodb/page/undo_log.rb', line 87

def undo_log(pos)
  Innodb::UndoLog.new(self, pos)
end

#undo_page_headerObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/innodb/page/undo_log.rb', line 57

def undo_page_header
  @undo_page_header ||= cursor(pos_undo_page_header).name("undo_page_header") do |c|
    PageHeader.new(
      type: c.name("type") { UNDO_PAGE_TYPES[c.read_uint16] },
      latest_log_record_offset: c.name("latest_log_record_offset") { c.read_uint16 },
      free_offset: c.name("free_offset") { c.read_uint16 },
      page_list_node: c.name("page_list") { Innodb::List.get_node(c) }
    )
  end
end

#undo_segment_headerObject



76
77
78
79
80
81
82
83
84
85
# File 'lib/innodb/page/undo_log.rb', line 76

def undo_segment_header
  @undo_segment_header ||= cursor(pos_undo_segment_header).name("undo_segment_header") do |c|
    SegmentHeader.new(
      state: c.name("state") { UNDO_SEGMENT_STATES[c.read_uint16] },
      last_log_offset: c.name("last_log_offset") { c.read_uint16 },
      fseg: c.name("fseg") { Innodb::FsegEntry.get_inode(@space, c) },
      page_list: c.name("page_list") { Innodb::List::UndoPage.new(@space, Innodb::List.get_base_node(c)) }
    )
  end
end