Class Innodb::DataDictionary
In: lib/innodb/data_dictionary.rb
Parent: Object

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

Methods

Classes and Modules

Class Innodb::DataDictionary::SYS_COLUMNS_PRIMARY
Class Innodb::DataDictionary::SYS_FIELDS_PRIMARY
Class Innodb::DataDictionary::SYS_INDEXES_PRIMARY
Class Innodb::DataDictionary::SYS_TABLES_ID
Class Innodb::DataDictionary::SYS_TABLES_PRIMARY

Constants

DATA_DICTIONARY_RECORD_DESCRIBERS = { :SYS_TABLES => { :PRIMARY => SYS_TABLES_PRIMARY, :ID => SYS_TABLES_ID   A hash of hashes of table name and index name to describer class.
MYSQL_TYPE = { # :DECIMAL => { :value => 0, :type => :DECIMAL }, :TINY => { :value => 1, :type => :TINYINT }, :SHORT => { :value => 2, :type => :SMALLINT }, :LONG => { :value => 3, :type => :INT }, :FLOAT => { :value => 4, :type => :FLOAT }, :DOUBLE => { :value => 5, :type => :DOUBLE }, # :NULL => { :value => 6, :type => nil }, :TIMESTAMP => { :value => 7, :type => :TIMESTAMP }, :LONGLONG => { :value => 8, :type => :BIGINT }, :INT24 => { :value => 9, :type => :MEDIUMINT }, # :DATE => { :value => 10, :type => :DATE }, :TIME => { :value => 11, :type => :TIME }, :DATETIME => { :value => 12, :type => :DATETIME }, :YEAR => { :value => 13, :type => :YEAR }, :NEWDATE => { :value => 14, :type => :DATE }, :VARCHAR => { :value => 15, :type => :VARCHAR }, :BIT => { :value => 16, :type => :BIT }, :NEWDECIMAL => { :value => 246, :type => :CHAR }, # :ENUM => { :value => 247, :type => :ENUM }, # :SET => { :value => 248, :type => :SET }, :TINY_BLOB => { :value => 249, :type => :TINYBLOB }, :MEDIUM_BLOB => { :value => 250, :type => :MEDIUMBLOB }, :LONG_BLOB => { :value => 251, :type => :LONGBLOB }, :BLOB => { :value => 252, :type => :BLOB }, # :VAR_STRING => { :value => 253, :type => :VARCHAR }, :STRING => { :value => 254, :type => :CHAR }, :GEOMETRY => { :value => 255, :type => :GEOMETRY }, }   A hash of MySQL‘s internal type system to the stored values for those types, and the "external" SQL type.
MYSQL_TYPE_BY_VALUE = MYSQL_TYPE.inject({}) { |h, (k, v)| h[v[:value]] = k;   A hash of MYSQL_TYPE keys by value :value key.
COLUMN_MTYPE = { :VARCHAR => 1, :CHAR => 2, :FIXBINARY => 3, :BINARY => 4, :BLOB => 5, :INT => 6, :SYS_CHILD => 7, :SYS => 8, :FLOAT => 9, :DOUBLE => 10, :DECIMAL => 11, :VARMYSQL => 12, :MYSQL => 13, }   A hash of InnoDB‘s internal type system to the values stored for each type.
COLUMN_MTYPE_BY_VALUE = COLUMN_MTYPE.inject({}) { |h, (k, v)| h[v] = k;   A hash of COLUMN_MTYPE keys by value.
COLUMN_PRTYPE_FLAG = { :NOT_NULL => 256, :UNSIGNED => 512, :BINARY => 1024, :LONG_TRUE_VARCHAR => 4096, }   A hash of InnoDB "precise type" bitwise flags.
COLUMN_PRTYPE_FLAG_BY_VALUE = COLUMN_PRTYPE_FLAG.inject({}) { |h, (k, v)| h[v] = k;   A hash of COLUMN_PRTYPE keys by value.
COLUMN_PRTYPE_MYSQL_TYPE_MASK = 0xFF   The bitmask to extract the MySQL internal type from the InnoDB "precise type".
INDEX_TYPE_FLAG = { :CLUSTERED => 1, :UNIQUE => 2, :UNIVERSAL => 4, :IBUF => 8, :CORRUPT => 16, :FTS => 32, }   A hash of InnoDB‘s index type flags.
INDEX_TYPE_FLAG_BY_VALUE = INDEX_TYPE_FLAG.inject({}) { |h, (k, v)| h[v] = k;   A hash of INDEX_TYPE_FLAG keys by value.

Attributes

system_space  [R] 

Public Class methods

Return a full data type given an mtype and prtype, such as ["VARCHAR(10)", :NOT_NULL] or [:INT, :UNSIGNED].

Return the "external" SQL type string (such as "VARCHAR" or "INT") given the stored mtype and prtype from the InnoDB data dictionary. Note that not all types are extractable into fully defined SQL types due to the lossy nature of the MySQL-to-InnoDB interface regarding types.

Public Instance methods

Produce a Innodb::RecordDescriber-compatible column description given a type (:key, :row) and data dictionary SYS_COLUMNS record.

Return the name of the clustered index (usually "PRIMARY", but not always) for a given table name.

Lookup a column by table name and column name.

Return an Innodb::Index object initialized to the internal data dictionary index with an appropriate record describer so that records can be recursed.

A helper method to reach inside the system space and retrieve the data dictionary index locations from the data dictionary header.

Iterate through the records in the SYS_COLUMNS data dictionary table.

Iterate through all columns in a table by table name.

Iterate through Innodb::RecordDescriber-compatible column descriptions for a given index by table name and index name.

Iterate through all columns not in an index by table name and index name. This is useful when building index descriptions for secondary indexes.

Iterate through all data dictionary indexes, yielding the table name, index name, and the index itself as an Innodb::Index.

Iterate through all data dictionary indexes, yielding the table name, index name, and root page number.

Iterate through the records in the SYS_FIELDS data dictionary table.

Iterate through all fields in an index by index name.

Iterate through the records in the SYS_INDEXES dictionary table.

Iterate through all indexes in a table by table name.

Iterate through records from a data dictionary index yielding each record as a Innodb::Record object.

Iterate through the records in the SYS_TABLES data dictionary table.

Lookup an index by index ID.

Lookup an index by table name and index name.

A helper to iterate the method provided and return the first record where the record‘s field matches the provided value.

A helper to iterate the method provided and return the first record where the record‘s fields f1 and f2 match the provided values v1 and v2.

Return an Innodb::RecordDescriber object describing the records in a given index by index ID.

Return an Innodb::RecordDescriber object describing records for a given index by table name and index name.

Lookup a table by table ID.

Lookup a table by table name.

Lookup a table by space ID.

[Validate]