Class Innodb::Page
In: lib/innodb/page.rb
Parent: Object

A generic class for any type of page, which handles reading the common FIL header and trailer, and can handle (via parse) dispatching to a more specialized class depending on page type (which comes from the FIL header). A page being handled by Innodb::Page indicates that its type is not currently handled by any more specialized class.

Methods

Classes and Modules

Class Innodb::Page::Blob
Class Innodb::Page::FspHdrXdes
Class Innodb::Page::IbufBitmap
Class Innodb::Page::Index
Class Innodb::Page::Inode
Class Innodb::Page::Sys
Class Innodb::Page::SysDataDictionaryHeader
Class Innodb::Page::SysIbufHeader
Class Innodb::Page::SysRsegHeader
Class Innodb::Page::TrxSys
Class Innodb::Page::UndoLog

Constants

SPECIALIZED_CLASSES = {}   A hash of page types to specialized classes to handle them. Normally subclasses will register themselves in this list.
PAGE_TYPE = { :ALLOCATED => { :value => 0, :description => "Freshly allocated", :usage => "page type field has not been initialized", }, :UNDO_LOG => { :value => 2, :description => "Undo log", :usage => "stores previous values of modified records", }, :INODE => { :value => 3, :description => "File segment inode", :usage => "bookkeeping for file segments", }, :IBUF_FREE_LIST => { :value => 4, :description => "Insert buffer free list", :usage => "bookkeeping for insert buffer free space management", }, :IBUF_BITMAP => { :value => 5, :description => "Insert buffer bitmap", :usage => "bookkeeping for insert buffer writes to be merged", }, :SYS => { :value => 6, :description => "System internal", :usage => "used for various purposes in the system tablespace", }, :TRX_SYS => { :value => 7, :description => "Transaction system header", :usage => "bookkeeping for the transaction system in system tablespace", }, :FSP_HDR => { :value => 8, :description => "File space header", :usage => "header page (page 0) for each tablespace file", }, :XDES => { :value => 9, :description => "Extent descriptor", :usage => "header page for subsequent blocks of 16,384 pages", }, :BLOB => { :value => 10, :description => "Uncompressed BLOB", :usage => "externally-stored uncompressed BLOB column data", }, :ZBLOB => { :value => 11, :description => "First compressed BLOB", :usage => "externally-stored compressed BLOB column data, first page", }, :ZBLOB2 => { :value => 12, :description => "Subsequent compressed BLOB", :usage => "externally-stored compressed BLOB column data, subsequent page", }, :INDEX => { :value => 17855, :description => "B+Tree index", :usage => "table and index data stored in B+Tree structure", }, }   InnoDB Page Type constants from include/fil0fil.h.
PAGE_TYPE_BY_VALUE = PAGE_TYPE.inject({}) { |h, (k, v)| h[v[:value]] = k;

Attributes

space  [R] 

Public Class methods

Allow the specialized class to do something that isn‘t ‘new’ with this page.

A helper to convert "undefined" values stored in previous and next pointers in the page header to nil.

Initialize a page by passing in a buffer containing the raw page contents. The buffer size should match the space‘s page size.

Load a page as a generic page in order to make the "fil" header accessible, and then attempt to hand off the page to a specialized class to be re-parsed if possible. If there is no specialized class for this type of page, return the generic object.

This could be optimized to reach into the page buffer and efficiently extract the page type in order to avoid throwing away a generic Innodb::Page object when parsing every specialized page, but this is a bit cleaner, and we‘re not particularly performance sensitive.

Public Instance methods

A helper function to return the checksum from the "fil" header, for easier access.

Calculate the checksum of the page using the CRC32c algorithm.

Calculate the checksum of the page using InnoDB‘s algorithm.

Is the page checksum incorrect?

A helper function to return the checksum from the "fil" trailer, for easier access.

Is the page checksum correct?

Is the page corrupt, either due to data corruption, tearing, or in the wrong place?

If no block is passed, return an BufferCursor object positioned at a specific offset. If a block is passed, create a cursor at the provided offset and yield it to the provided block one time, and then return the return value of the block.

Dump the contents of a page for debugging purposes.

Iterate each byte of the page body, except for the FIL header and the FIL trailer.

Iterate each byte of the FIL header.

Return the "fil" header from the page, which is common for all page types.

Return the "fil" trailer from the page, which is common for all page types.

Is the page in the doublewrite buffer?

Implement a custom inspect method to avoid irb printing the contents of the page buffer, since it‘s very large and mostly not interesting.

A helper function to return the LSN from the page header, for easier access.

A helper function to return the low 32 bits of the LSN from the page header for use in comparing to the low 32 bits stored in the trailer.

A helper function to return the low 32 bits of the LSN as stored in the page trailer.

Is the page misplaced in the wrong file or by offset in the file?

Is the page number stored in the header different from the page number which was supposed to be read?

Is the space ID stored in the header different from that of the space provided when initializing this page?

Return a simple string to uniquely identify this page within the space. Be careful not to call anything which would instantiate a BufferCursor so that we can use this method in cursor initialization.

A helper function to return the page number of the logical next page (from the doubly-linked list from page to page) from the "fil" header, for easier access.

A helper function to return the page offset from the "fil" header, for easier access.

Return the byte offset of the start of the "fil" header, which is at the beginning of the page. Included here primarily for completeness.

Return the byte offset of the start of the "fil" trailer, which is at the end of the page.

Return the position of the "body" of the page, which starts after the FIL header.

The start of the checksummed portion of the file header.

A helper function to return the page number of the logical previous page (from the doubly-linked list from page to page) from the "fil" header, for easier access.

Return the page size, to eventually be able to deal with non-16kB pages.

Return the size of the "fil" header, in bytes.

Return the size of the "fil" trailer, in bytes.

Return the size of the page body, excluding the header and trailer.

The size of the portion of the fil header that is included in the checksum. Exclude the following:

  :checksum   (offset 4, size 4)
  :flush_lsn  (offset 26, size 8)
  :space_id   (offset 34, size 4)

A helper function to return the space ID from the "fil" header, for easier access.

Is the LSN stored in the header different from the one stored in the trailer?

A helper function to return the page type from the "fil" header, for easier access.

[Validate]