Class: Innodb::DataDictionary

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

Overview

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

Defined Under Namespace

Classes: SYS_COLUMNS_PRIMARY, SYS_FIELDS_PRIMARY, SYS_INDEXES_PRIMARY, SYS_TABLES_ID, SYS_TABLES_PRIMARY

Constant Summary collapse

DATA_DICTIONARY_RECORD_DESCRIBERS =

A hash of hashes of table name and index name to describer class.

{
  :SYS_TABLES  => {
    :PRIMARY => SYS_TABLES_PRIMARY,
    :ID      => SYS_TABLES_ID
  },
  :SYS_COLUMNS => { :PRIMARY => SYS_COLUMNS_PRIMARY },
  :SYS_INDEXES => { :PRIMARY => SYS_INDEXES_PRIMARY },
  :SYS_FIELDS  => { :PRIMARY => SYS_FIELDS_PRIMARY },
}
MYSQL_TYPE =

A hash of MySQL’s internal type system to the stored values for those types, and the “external” SQL 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    },
}
MYSQL_TYPE_BY_VALUE =

A hash of MYSQL_TYPE keys by value :value key.

MYSQL_TYPE.inject({}) { |h, (k, v)| h[v[:value]] = k; h }
COLUMN_MTYPE =

A hash of InnoDB’s internal type system to the values stored for each type.

{
  :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,
}
COLUMN_MTYPE_BY_VALUE =

A hash of COLUMN_MTYPE keys by value.

COLUMN_MTYPE.inject({}) { |h, (k, v)| h[v] = k; h }
COLUMN_PRTYPE_FLAG =

A hash of InnoDB “precise type” bitwise flags.

{
  :NOT_NULL          => 256,
  :UNSIGNED          => 512,
  :BINARY            => 1024,
  :LONG_TRUE_VARCHAR => 4096,
}
COLUMN_PRTYPE_FLAG_BY_VALUE =

A hash of COLUMN_PRTYPE keys by value.

COLUMN_PRTYPE_FLAG.inject({}) { |h, (k, v)| h[v] = k; h }
COLUMN_PRTYPE_MYSQL_TYPE_MASK =

The bitmask to extract the MySQL internal type from the InnoDB “precise type”.

0xFF
INDEX_TYPE_FLAG =

A hash of InnoDB’s index type flags.

{
  :CLUSTERED => 1,
  :UNIQUE    => 2,
  :UNIVERSAL => 4,
  :IBUF      => 8,
  :CORRUPT   => 16,
  :FTS       => 32,
}
INDEX_TYPE_FLAG_BY_VALUE =

A hash of INDEX_TYPE_FLAG keys by value.

INDEX_TYPE_FLAG.inject({}) { |h, (k, v)| h[v] = k; h }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(system_space) ⇒ DataDictionary

Returns a new instance of DataDictionary.



221
222
223
# File 'lib/innodb/data_dictionary.rb', line 221

def initialize(system_space)
  @system_space = system_space
end

Instance Attribute Details

#system_spaceObject (readonly)

Returns the value of attribute system_space.



219
220
221
# File 'lib/innodb/data_dictionary.rb', line 219

def system_space
  @system_space
end

Class Method Details

.mtype_prtype_to_data_type(mtype, prtype, len, prec) ⇒ Object

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



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/innodb/data_dictionary.rb', line 199

def self.mtype_prtype_to_data_type(mtype, prtype, len, prec)
  data_type = []

  if type = mtype_prtype_to_type_string(mtype, prtype, len, prec)
    data_type << type
  else
    raise "Unsupported type (mtype #{mtype}, prtype #{prtype})"
  end

  if prtype & COLUMN_PRTYPE_FLAG[:NOT_NULL] != 0
    data_type << :NOT_NULL
  end

  if prtype & COLUMN_PRTYPE_FLAG[:UNSIGNED] != 0
    data_type << :UNSIGNED
  end

  data_type
end

.mtype_prtype_to_type_string(mtype, prtype, len, prec) ⇒ Object

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.



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/innodb/data_dictionary.rb', line 159

def self.mtype_prtype_to_type_string(mtype, prtype, len, prec)
  mysql_type = prtype & COLUMN_PRTYPE_MYSQL_TYPE_MASK
  internal_type = MYSQL_TYPE_BY_VALUE[mysql_type]
  external_type = MYSQL_TYPE[internal_type][:type]

  case external_type
  when :VARCHAR
    # One-argument: length.
    "%s(%i)" % [external_type, len]
  when :FLOAT, :DOUBLE
    # Two-argument: length and precision.
    "%s(%i,%i)" % [external_type, len, prec]
  when :CHAR
    if COLUMN_MTYPE_BY_VALUE[mtype] == :MYSQL
      # When the mtype is :MYSQL, the column is actually
      # stored as VARCHAR despite being a CHAR. This is
      # done for CHAR columns having multi-byte character
      # sets in order to limit size. Note that such data
      # are still space-padded to at least len.
      "VARCHAR(%i)" % [len]
    else
      "CHAR(%i)" % [len]
    end
  when :DECIMAL
    # The DECIMAL type is designated as DECIMAL(M,D)
    # however the M and D definitions are not stored
    # in the InnoDB data dictionary. We need to define
    # the column as something which will extract the
    # raw bytes in order to read the column, but we
    # can't figure out the right decimal type. The
    # len stored here is actually the on-disk storage
    # size.
    "CHAR(%i)" % [len]
  else
    external_type
  end
end

Instance Method Details

#_make_column_description(type, record) ⇒ Object

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



593
594
595
596
597
598
599
600
601
602
603
604
# File 'lib/innodb/data_dictionary.rb', line 593

def _make_column_description(type, record)
  {
    :type => type,
    :name => record["NAME"],
    :description => self.class.mtype_prtype_to_data_type(
      record["MTYPE"],
      record["PRTYPE"],
      record["LEN"],
      record["PREC"]
    )
  }
end

#clustered_index_name_by_table_name(table_name) ⇒ Object

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



579
580
581
582
583
584
585
586
587
588
589
# File 'lib/innodb/data_dictionary.rb', line 579

def clustered_index_name_by_table_name(table_name)
  unless table_record = table_by_name(table_name)
    raise "Table #{table_name} not found"
  end

  if index_record = object_by_two_fields(:each_index,
                                         "TABLE_ID", table_record["ID"],
                                         "TYPE", 3)
    index_record["NAME"]
  end
end

#column_by_name(table_name, column_name) ⇒ Object

Lookup a column by table name and column name.



415
416
417
418
419
420
421
422
423
# File 'lib/innodb/data_dictionary.rb', line 415

def column_by_name(table_name, column_name)
  unless table = table_by_name(table_name)
    return nil
  end

  object_by_two_fields(:each_column,
                       "TABLE_ID", table["ID"],
                       "NAME", column_name)
end

#data_dictionary_index(table_name, index_name) ⇒ Object

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



270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/innodb/data_dictionary.rb', line 270

def data_dictionary_index(table_name, index_name)
  unless table_entry = data_dictionary_indexes[table_name]
    raise "Unknown data dictionary table #{table_name}"
  end

  unless index_root_page = table_entry[index_name]
    raise "Unknown data dictionary index #{table_name}.#{index_name}"
  end

  # If we have a record describer for this index, load it.
  record_describer = data_dictionary_index_describer(table_name, index_name)

  system_space.index(index_root_page, record_describer)
end

#data_dictionary_index?(table_name, index_name) ⇒ Boolean

Returns:

  • (Boolean)


256
257
258
259
# File 'lib/innodb/data_dictionary.rb', line 256

def data_dictionary_index?(table_name, index_name)
  return unless data_dictionary_table?(table_name)
  DATA_DICTIONARY_RECORD_DESCRIBERS[table_name.to_sym].include?(index_name.to_sym)
end

#data_dictionary_index_describer(table_name, index_name) ⇒ Object



261
262
263
264
265
# File 'lib/innodb/data_dictionary.rb', line 261

def data_dictionary_index_describer(table_name, index_name)
  return unless data_dictionary_index?(table_name, index_name)

  DATA_DICTIONARY_RECORD_DESCRIBERS[table_name.to_sym][index_name.to_sym].new
end

#data_dictionary_index_idsObject



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/innodb/data_dictionary.rb', line 232

def data_dictionary_index_ids
  if @data_dictionary_index_ids
    return @data_dictionary_index_ids
  end

  @data_dictionary_index_ids = {}
  data_dictionary_indexes.each do |table, indexes|
    indexes.each do |index, root_page_number|
      if root_page = system_space.page(root_page_number)
        @data_dictionary_index_ids[root_page.index_id] = {
          :table => table,
          :index => index
        }
      end
    end
  end

  @data_dictionary_index_ids
end

#data_dictionary_indexesObject

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



228
229
230
# File 'lib/innodb/data_dictionary.rb', line 228

def data_dictionary_indexes
  system_space.data_dictionary_page.data_dictionary_header[:indexes]
end

#data_dictionary_table?(table_name) ⇒ Boolean

Returns:

  • (Boolean)


252
253
254
# File 'lib/innodb/data_dictionary.rb', line 252

def data_dictionary_table?(table_name)
  DATA_DICTIONARY_RECORD_DESCRIBERS.include?(table_name.to_sym)
end

#each_columnObject

Iterate through the records in the SYS_COLUMNS data dictionary table.



346
347
348
349
350
351
352
353
354
355
356
# File 'lib/innodb/data_dictionary.rb', line 346

def each_column
  unless block_given?
    return enum_for(:each_column)
  end

  each_record_from_data_dictionary_index(:SYS_COLUMNS, :PRIMARY) do |record|
    yield record.fields
  end

  nil
end

#each_column_by_table_id(table_id) ⇒ Object

Iterate through all columns in a table by table ID.



516
517
518
519
520
521
522
523
524
525
526
# File 'lib/innodb/data_dictionary.rb', line 516

def each_column_by_table_id(table_id)
  unless block_given?
    return enum_for(:each_column_by_table_id, table_id)
  end

  each_column do |record|
    yield record if record["TABLE_ID"] == table_id
  end

  nil
end

#each_column_by_table_name(table_name) ⇒ Object

Iterate through all columns in a table by table name.



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
# File 'lib/innodb/data_dictionary.rb', line 529

def each_column_by_table_name(table_name)
  unless block_given?
    return enum_for(:each_column_by_table_name, table_name)
  end

  unless table = table_by_name(table_name)
    raise "Table #{table_name} not found"
  end

  each_column_by_table_id(table["ID"]) do |record|
    yield record
  end

  nil
end

#each_column_description_by_index_name(table_name, index_name) ⇒ Object

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



608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/innodb/data_dictionary.rb', line 608

def each_column_description_by_index_name(table_name, index_name)
  unless block_given?
    return enum_for(:each_column_description_by_index_name, table_name, index_name)
  end

  unless index = index_by_name(table_name, index_name)
    raise "Index #{index_name} for table #{table_name} not found"
  end

  columns_in_index = {}
  each_column_in_index_by_name(table_name, index_name) do |record|
    columns_in_index[record["NAME"]] = 1
    yield _make_column_description(:key, record)
  end

  if index["TYPE"] & INDEX_TYPE_FLAG[:CLUSTERED] != 0
    each_column_by_table_name(table_name) do |record|
      unless columns_in_index.include?(record["NAME"])
        yield _make_column_description(:row, record)
      end
    end
  else
    clustered_index_name = clustered_index_name_by_table_name(table_name)

    each_column_in_index_by_name(table_name, clustered_index_name) do |record|
      yield _make_column_description(:row, record)
    end
  end

  nil
end

#each_column_in_index_by_name(table_name, index_name) ⇒ Object

Iterate through all columns in an index by table name and index name.



546
547
548
549
550
551
552
553
554
555
556
# File 'lib/innodb/data_dictionary.rb', line 546

def each_column_in_index_by_name(table_name, index_name)
  unless block_given?
    return enum_for(:each_column_in_index_by_name, table_name, index_name)
  end

  each_field_by_index_name(table_name, index_name) do |record|
    yield column_by_name(table_name, record["COL_NAME"])
  end

  nil
end

#each_column_not_in_index_by_name(table_name, index_name) ⇒ Object

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



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/innodb/data_dictionary.rb', line 560

def each_column_not_in_index_by_name(table_name, index_name)
  unless block_given?
    return enum_for(:each_column_not_in_index_by_name, table_name, index_name)
  end

  columns_in_index = {}
  each_column_in_index_by_name(table_name, index_name) do |record|
    columns_in_index[record["NAME"]] = 1
  end

  each_column_by_table_name(table_name) do |record|
    yield record unless columns_in_index.include?(record["NAME"])
  end

  nil
end

#each_data_dictionary_indexObject

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



303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/innodb/data_dictionary.rb', line 303

def each_data_dictionary_index
  unless block_given?
    return enum_for(:each_data_dictionary_index)
  end

  data_dictionary_indexes.each do |table_name, indexes|
    indexes.each do |index_name, root_page_number|
      yield table_name, index_name,
        data_dictionary_index(table_name, index_name)
    end
  end

  nil
end

#each_data_dictionary_index_root_page_numberObject

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



287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/innodb/data_dictionary.rb', line 287

def each_data_dictionary_index_root_page_number
  unless block_given?
    return enum_for(:each_data_dictionary_index_root_page_number)
  end

  data_dictionary_indexes.each do |table_name, indexes|
    indexes.each do |index_name, root_page_number|
      yield table_name, index_name, root_page_number
    end
  end

  nil
end

#each_fieldObject

Iterate through the records in the SYS_FIELDS data dictionary table.



372
373
374
375
376
377
378
379
380
381
382
# File 'lib/innodb/data_dictionary.rb', line 372

def each_field
  unless block_given?
    return enum_for(:each_field)
  end

  each_record_from_data_dictionary_index(:SYS_FIELDS, :PRIMARY) do |record|
    yield record.fields
  end

  nil
end

#each_field_by_index_id(index_id) ⇒ Object

Iterate through all fields in an index by index ID.



486
487
488
489
490
491
492
493
494
495
496
# File 'lib/innodb/data_dictionary.rb', line 486

def each_field_by_index_id(index_id)
  unless block_given?
    return enum_for(:each_field_by_index_id, index_id)
  end

  each_field do |record|
    yield record if record["INDEX_ID"] == index_id
  end

  nil
end

#each_field_by_index_name(table_name, index_name) ⇒ Object

Iterate through all fields in an index by index name.



499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/innodb/data_dictionary.rb', line 499

def each_field_by_index_name(table_name, index_name)
  unless block_given?
    return enum_for(:each_field_by_name, table_name, index_name)
  end

  unless index = index_by_name(table_name, index_name)
    raise "Index #{index_name} for table #{table_name} not found"
  end

  each_field_by_index_id(index["ID"]) do |record|
    yield record
  end

  nil
end

#each_indexObject

Iterate through the records in the SYS_INDEXES dictionary table.



359
360
361
362
363
364
365
366
367
368
369
# File 'lib/innodb/data_dictionary.rb', line 359

def each_index
  unless block_given?
    return enum_for(:each_index)
  end

  each_record_from_data_dictionary_index(:SYS_INDEXES, :PRIMARY) do |record|
    yield record.fields
  end

  nil
end

#each_index_by_space_id(space_id) ⇒ Object

Iterate through indexes by space ID.



443
444
445
446
447
448
449
450
451
452
453
# File 'lib/innodb/data_dictionary.rb', line 443

def each_index_by_space_id(space_id)
  unless block_given?
    return enum_for(:each_index_by_space_id, space_id)
  end

  each_index do |record|
    yield record if record["SPACE"] == space_id
  end

  nil
end

#each_index_by_table_id(table_id) ⇒ Object

Iterate through all indexes in a table by table ID.



456
457
458
459
460
461
462
463
464
465
466
# File 'lib/innodb/data_dictionary.rb', line 456

def each_index_by_table_id(table_id)
  unless block_given?
    return enum_for(:each_index_by_table_id, table_id)
  end

  each_index do |record|
    yield record if record["TABLE_ID"] == table_id
  end

  nil
end

#each_index_by_table_name(table_name) ⇒ Object

Iterate through all indexes in a table by table name.



469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/innodb/data_dictionary.rb', line 469

def each_index_by_table_name(table_name)
  unless block_given?
    return enum_for(:each_index_by_table_name, table_name)
  end

  unless table = table_by_name(table_name)
    raise "Table #{table_name} not found"
  end

  each_index_by_table_id(table["ID"]) do |record|
    yield record
  end

  nil
end

#each_record_from_data_dictionary_index(table, index) ⇒ Object

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



320
321
322
323
324
325
326
327
328
329
330
# File 'lib/innodb/data_dictionary.rb', line 320

def each_record_from_data_dictionary_index(table, index)
  unless block_given?
    return enum_for(:each_index, table, index)
  end

  data_dictionary_index(table, index).each_record do |record|
    yield record
  end

  nil
end

#each_tableObject

Iterate through the records in the SYS_TABLES data dictionary table.



333
334
335
336
337
338
339
340
341
342
343
# File 'lib/innodb/data_dictionary.rb', line 333

def each_table
  unless block_given?
    return enum_for(:each_table)
  end

  each_record_from_data_dictionary_index(:SYS_TABLES, :PRIMARY) do |record|
    yield record.fields
  end

  nil
end

#index_by_id(index_id) ⇒ Object

Lookup an index by index ID.



426
427
428
429
# File 'lib/innodb/data_dictionary.rb', line 426

def index_by_id(index_id)
  object_by_field(:each_index,
                  "ID", index_id)
end

#index_by_name(table_name, index_name) ⇒ Object

Lookup an index by table name and index name.



432
433
434
435
436
437
438
439
440
# File 'lib/innodb/data_dictionary.rb', line 432

def index_by_name(table_name, index_name)
  unless table = table_by_name(table_name)
    return nil
  end

  object_by_two_fields(:each_index,
                       "TABLE_ID", table["ID"],
                       "NAME", index_name)
end

#object_by_field(method, field, value) ⇒ Object

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



386
387
388
# File 'lib/innodb/data_dictionary.rb', line 386

def object_by_field(method, field, value)
  send(method).select { |o| o[field] == value }.first
end

#object_by_two_fields(method, f1, v1, f2, v2) ⇒ Object

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.



392
393
394
# File 'lib/innodb/data_dictionary.rb', line 392

def object_by_two_fields(method, f1, v1, f2, v2)
  send(method).select { |o| o[f1] == v1 && o[f2] == v2 }.first
end

#record_describer_by_index_id(index_id) ⇒ Object

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



673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# File 'lib/innodb/data_dictionary.rb', line 673

def record_describer_by_index_id(index_id)
  if dd_index = data_dictionary_index_ids[index_id]
    return data_dictionary_index_describer(dd_index[:table], dd_index[:index])
  end

  unless index = index_by_id(index_id)
    raise "Index #{index_id} not found"
  end

  unless table = table_by_id(index["TABLE_ID"])
    raise "Table #{INDEX["TABLE_ID"]} not found"
  end

  record_describer_by_index_name(table["NAME"], index["NAME"])
end

#record_describer_by_index_name(table_name, index_name) ⇒ Object

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



642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
# File 'lib/innodb/data_dictionary.rb', line 642

def record_describer_by_index_name(table_name, index_name)
  if data_dictionary_index?(table_name, index_name)
    return data_dictionary_index_describer(table_name, index_name)
  end

  unless index = index_by_name(table_name, index_name)
    raise "Index #{index_name} for table #{table_name} not found"
  end

  describer = Innodb::RecordDescriber.new

  if index["TYPE"] & INDEX_TYPE_FLAG[:CLUSTERED] != 0
    describer.type :clustered
  else
    describer.type :secondary
  end

  each_column_description_by_index_name(table_name, index_name) do |column|
    case column[:type]
    when :key
      describer.key column[:name], *column[:description]
    when :row
      describer.row column[:name], *column[:description]
    end
  end

  describer
end

#table_by_id(table_id) ⇒ Object

Lookup a table by table ID.



397
398
399
400
# File 'lib/innodb/data_dictionary.rb', line 397

def table_by_id(table_id)
  object_by_field(:each_table,
                  "ID", table_id)
end

#table_by_name(table_name) ⇒ Object

Lookup a table by table name.



403
404
405
406
# File 'lib/innodb/data_dictionary.rb', line 403

def table_by_name(table_name)
  object_by_field(:each_table,
                  "NAME", table_name)
end

#table_by_space_id(space_id) ⇒ Object

Lookup a table by space ID.



409
410
411
412
# File 'lib/innodb/data_dictionary.rb', line 409

def table_by_space_id(space_id)
  object_by_field(:each_table,
                  "SPACE", space_id)
end