innodb_ruby 0.9.10 → 0.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1031,11 +1031,44 @@ def index_level_summary(index, level)
1031
1031
  page.record_space,
1032
1032
  page.free_space,
1033
1033
  page.records,
1034
- page.first_record.key_string,
1034
+ page.min_record.key_string,
1035
1035
  ]
1036
1036
  end
1037
1037
  end
1038
1038
 
1039
+ def undo_history_summary(innodb_system)
1040
+ history = innodb_system.history.each_history_list
1041
+ history_list = history.select { |history| history.list.length > 0 }
1042
+
1043
+ puts "%-8s%-8s%-14s%-20s%s" % [
1044
+ "Page",
1045
+ "Offset",
1046
+ "Transaction",
1047
+ "Type",
1048
+ "Table",
1049
+ ]
1050
+
1051
+ history_list.each do |history|
1052
+ history.each_undo_record do |undo|
1053
+ table_name = innodb_system.table_name_by_id(undo.table_id)
1054
+ puts "%-8s%-8s%-14s%-20s%s" % [
1055
+ undo.page,
1056
+ undo.offset,
1057
+ undo.trx_id,
1058
+ undo.type,
1059
+ table_name,
1060
+ ]
1061
+ end
1062
+ end
1063
+ end
1064
+
1065
+ def undo_record_dump(innodb_system, page, record_offset)
1066
+ undo_record = Innodb::UndoRecord.new(page, record_offset)
1067
+ index = innodb_system.clustered_index_by_table_id(undo_record.table_id)
1068
+ undo_record.index_page = index.root
1069
+ undo_record.new_subordinate(page, record_offset).dump
1070
+ end
1071
+
1039
1072
  def usage(exit_code, message = nil)
1040
1073
  if message
1041
1074
  puts "Error: #{message}; see --help for usage information\n\n"
@@ -1225,6 +1258,13 @@ The following modes are supported:
1225
1258
  Summarize the history (undo logs) for a record. A record offset must be
1226
1259
  provided with -R/--record.
1227
1260
 
1261
+ undo-history-summary
1262
+ Summarize all records in the history list (undo logs).
1263
+
1264
+ undo-record-dump
1265
+ Dump a detailed description of an undo record and the data it contains.
1266
+ A record offset must be provided with -R/--record.
1267
+
1228
1268
  END_OF_USAGE
1229
1269
 
1230
1270
  exit exit_code
@@ -1375,6 +1415,10 @@ if /-list-iterate$/.match(mode) and !@options.list
1375
1415
  usage 1, "List name must be specified using -L/--list"
1376
1416
  end
1377
1417
 
1418
+ if /-level-/.match(mode) and !@options.level
1419
+ usage 1, "Level must be specified using -l/--level"
1420
+ end
1421
+
1378
1422
  if [
1379
1423
  "index-recurse",
1380
1424
  "index-record-offsets",
@@ -1460,6 +1504,10 @@ when "record-dump"
1460
1504
  record_dump(page, @options.record)
1461
1505
  when "record-history"
1462
1506
  record_history(page, @options.record)
1507
+ when "undo-history-summary"
1508
+ undo_history_summary(innodb_system)
1509
+ when "undo-record-dump"
1510
+ undo_record_dump(innodb_system, page, @options.record)
1463
1511
  else
1464
1512
  usage 1, "Unknown mode: #{mode}"
1465
1513
  end
@@ -175,6 +175,11 @@ class Innodb::System
175
175
  end
176
176
  end
177
177
 
178
+ # Return the clustered index name given a table name.
179
+ def clustered_index_by_table_name(table_name)
180
+ data_dictionary.clustered_index_name_by_table_name(table_name)
181
+ end
182
+
178
183
  # Return an array of the table name and index name given an index ID.
179
184
  def table_and_index_name_by_id(index_id)
180
185
  if dd_index = data_dictionary.data_dictionary_index_ids[index_id]
@@ -198,6 +203,13 @@ class Innodb::System
198
203
  index
199
204
  end
200
205
 
206
+ # Return the clustered index given a table ID.
207
+ def clustered_index_by_table_id(table_id)
208
+ if table_name = table_name_by_id(table_id)
209
+ index_by_name(table_name, clustered_index_by_table_name(table_name))
210
+ end
211
+ end
212
+
201
213
  def history
202
214
  Innodb::History.new(self)
203
215
  end
@@ -205,6 +205,14 @@ class Innodb::UndoRecord
205
205
  undo_record[:key]
206
206
  end
207
207
 
208
+ def page
209
+ undo_record[:page]
210
+ end
211
+
212
+ def offset
213
+ undo_record[:offset]
214
+ end
215
+
208
216
  def key_string
209
217
  key && key.map { |r| "%s=%s" % [r[:name], r[:value].inspect] }.join(", ")
210
218
  end
@@ -256,4 +264,44 @@ class Innodb::UndoRecord
256
264
  older_undo_record
257
265
  end
258
266
 
267
+ def dump
268
+ puts "Undo record at offset %i" % offset
269
+ puts
270
+
271
+ puts "Header:"
272
+ puts " %-25s: %i" % ["Previous record offset", header[:prev]]
273
+ puts " %-25s: %i" % ["Next record offset", header[:next]]
274
+ puts " %-25s: %s" % ["Type", header[:type]]
275
+ puts
276
+
277
+ puts "System fields:"
278
+ puts " Transaction ID: %s" % trx_id
279
+ puts " Roll Pointer:"
280
+ puts " Undo Log: page %i, offset %i" % [
281
+ roll_ptr[:undo_log][:page],
282
+ roll_ptr[:undo_log][:offset],
283
+ ]
284
+ puts " Rollback Segment ID: %i" % roll_ptr[:rseg_id]
285
+ puts
286
+
287
+ puts "Key fields:"
288
+ key.each do |field|
289
+ puts " %s: %s" % [
290
+ field[:name],
291
+ field[:value].inspect,
292
+ ]
293
+ end
294
+ puts
295
+
296
+ puts "Non-key fields:"
297
+ row.each do |field|
298
+ next if !field
299
+ puts " %s: %s" % [
300
+ field[:name],
301
+ field[:value].inspect,
302
+ ]
303
+ end
304
+ puts
305
+ end
306
+
259
307
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module Innodb
4
- VERSION = "0.9.10"
4
+ VERSION = "0.9.11"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: innodb_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.9.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-09-26 00:00:00.000000000 Z
13
+ date: 2014-09-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bindata