module Innodb

A set of classes for parsing and working with InnoDB data files.

A class representing InnoDB’s data dictionary, which contains metadata about tables, columns, and indexes.

A single field in an InnoDB record (within an INDEX page). This class provides essential information to parse records, including the length of the fixed-width and variable-width portion of the field.

An InnoDB file segment entry, which appears in a few places, such as the FSEG header of INDEX pages, and in the TRX_SYS pages.

The global history of record versions implemented through undo logs.

A single history list; this is a more intelligent wrapper around the basic Innodb::List::History which is provided elsewhere.

An InnoDB index B-tree, given an Innodb::Space and a root page number.

An abstract InnoDB “free list” or FLST (renamed to just “list” here as it frequently is used for structures that aren’t free lists). This class must be sub-classed to provide an appropriate object_from_address method.

An InnoDB transaction log file.

An InnoDB transaction log block.

Group of InnoDB logs files that make up the redo log.

Representation of the log group as a seekable stream of log records.

An InnoDB transaction log block.

A Log Sequence Number and its byte offset into the log group.

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.

A specialized class for FSP_HDR (filespace header) and XDES (extent descriptor) page types. Each tablespace always has an FSP_HDR page as its first page (page 0), and has repeating XDES pages every 16,384 pages after that (page 16384, 32768, …). The FSP_HDR and XDES page structure is completely identical, with the exception that the FSP header structure is zero-filled on XDES pages, but populated on FSP_HDR pages.

The basic structure of FSP_HDR and XDES pages is: FIL header, FSP header, an array of 256 XDES entries, empty (unused) space, and FIL trailer.

A specialized class for handling INDEX pages, which contain a portion of the data from exactly one B+tree. These are typically the most common type of page in any database.

The basic structure of an INDEX page is: FIL header, INDEX header, FSEG header, fixed-width system records (infimum and supremum), user records (the actual data) which grow ascending by offset, free space, the page directory which grows descending by offset, and the FIL trailer.

This is horribly incomplete and broken. InnoDB compression does not currently work in innodb_ruby. Patches are welcome! (Hint hint, nudge nudge, Facebook developers!)

A specialized class for handling INODE pages, which contain index FSEG (file segment) information. This allows all extents and individual pages assigned to each index to be found.

Another layer of indirection for pages of type SYS, as they have multiple uses within InnoDB. We’ll override the self.handle method and check the page offset to decide which type of SYS page this is.

A specialized class for TRX_SYS pages, which contain various information about the transaction system within InnoDB. Only one TRX_SYS page exists in any given InnoDB installation, and it is page 5 of the system tablespace (space 0), most commonly named “ibdata1”.

The basic structure of a TRX_SYS page is: FIL header, TRX_SYS header, empty space, master binary log information, empty space, local binary log information, empty space, doublewrite information (repeated twice), empty space, and FIL trailer.

A class to describe record layouts for InnoDB indexes. Designed to be usable in two different ways: statically built and dynamically built. Note that in both cases, the order that statements are encountered is critical. Columns must be added to the key and row structures in the correct order.

STATIC USAGE

Static building is useful for building a custom describer for any index and looks like the following:

To describe the SQL syntax:

CREATE TABLE my_table (
  id BIGINT NOT NULL,
  name VARCHAR(100) NOT NULL,
  age INT UNSIGNED,
  PRIMARY KEY (id)
);

The clustered key would require a class like:

class MyTableClusteredDescriber < Innodb::RecordDescriber
  type :clustered
  key "id", :BIGINT, :UNSIGNED, :NOT_NULL
  row "name", "VARCHAR(100)", :NOT_NULL
  row "age", :INT, :UNSIGNED
end

It can then be instantiated as usual:

my_table_clustered = MyTableClusteredDescriber.new

All statically-defined type, key, and row information will be copied into the instance when it is initialized. Once initialized, the instance can be additionally used dynamically, as per below. (A dynamic class is just the same as a static class that is empty.)

Note that since InnoDB works in terms of indexes individually, a new class must be created for each index.

DYNAMIC USAGE

If a record describer needs to be built based on runtime information, such as index descriptions from a live data dictionary, instances can be built dynamically. For the same table above, this would require:

my_table_clustered = Innodb::RecordDescriber.new
my_table_clustered.type = :clustered
my_table_clustered.key "id", :BIGINT, :UNSIGNED, :NOT_NULL
my_table_clustered.row "name", "VARCHAR(100)", :NOT_NULL
my_table_clustered.row "age", :INT, :UNSIGNED

An InnoDB space file, which can be either a multi-table ibdataN file or a single-table “innodb_file_per_table” .ibd file.

Collect stats globally within innodb_ruby for comparison purposes and for correctness checking.

A class representing an entire InnoDB system, having a system tablespace and any number of attached single-table tablespaces.

A single undo log record.

An InnoDB “extent descriptor entry” or “XDES”. These structures are used in the XDES entry array contained in FSP_HDR and XDES pages.

Note the distinction between XDES entries and XDES pages.

Constants

VERSION

Public Class Methods

debug=(value) click to toggle source
# File lib/innodb.rb, line 12
def self.debug=(value)
  @debug = value
end
debug?() click to toggle source
# File lib/innodb.rb, line 8
def self.debug?
  @debug == true
end