innodb_ruby 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/innodb_log +39 -23
- data/lib/innodb/inode.rb +1 -1
- data/lib/innodb/system.rb +30 -0
- data/lib/innodb/version.rb +1 -1
- metadata +2 -2
data/bin/innodb_log
CHANGED
@@ -5,12 +5,37 @@ require "ostruct"
|
|
5
5
|
require "set"
|
6
6
|
require "innodb"
|
7
7
|
|
8
|
+
def log_summary(log, space_ids)
|
9
|
+
puts "%-10s%-30s%-10s%-10s" % [
|
10
|
+
"block",
|
11
|
+
"type",
|
12
|
+
"space",
|
13
|
+
"page",
|
14
|
+
]
|
15
|
+
log.each_block do |block_number, block|
|
16
|
+
if block.record
|
17
|
+
space_id = block.record[:space]
|
18
|
+
if @options.space_ids.empty? or @options.space_ids.include?(space_id)
|
19
|
+
puts "%-10i%-30s%-10i%-10i" % [
|
20
|
+
block_number,
|
21
|
+
block.record[:type],
|
22
|
+
space_id,
|
23
|
+
block.record[:page_number],
|
24
|
+
]
|
25
|
+
if @options.dump
|
26
|
+
block.dump
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
8
33
|
def usage(exit_code, message = nil)
|
9
34
|
print "Error: #{message}\n" unless message.nil?
|
10
35
|
|
11
36
|
print <<'END_OF_USAGE'
|
12
37
|
|
13
|
-
Usage: innodb_log [-d] [-s] <file> [
|
38
|
+
Usage: innodb_log [-d] [-s] <file> [<mode>]
|
14
39
|
|
15
40
|
--help, -?
|
16
41
|
Print this usage text.
|
@@ -21,6 +46,11 @@ Usage: innodb_log [-d] [-s] <file> [block-number]
|
|
21
46
|
--space-id, -s
|
22
47
|
Print only given space id (may provide multiple times).
|
23
48
|
|
49
|
+
The following modes are supported:
|
50
|
+
|
51
|
+
log-summary (default)
|
52
|
+
A summary of all blocks within log that contain at least one record.
|
53
|
+
|
24
54
|
END_OF_USAGE
|
25
55
|
|
26
56
|
exit exit_code
|
@@ -49,32 +79,18 @@ getopt.each do |opt, arg|
|
|
49
79
|
end
|
50
80
|
end
|
51
81
|
|
52
|
-
filename,
|
82
|
+
filename, mode = ARGV.shift(2)
|
53
83
|
if filename.nil?
|
54
84
|
usage 1
|
55
85
|
end
|
56
86
|
|
57
87
|
log = Innodb::Log.new(filename)
|
58
88
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
if block.record
|
67
|
-
space_id = block.record[:space]
|
68
|
-
if @options.space_ids.empty? or @options.space_ids.include?(space_id)
|
69
|
-
puts "%-10i%-30s%-10i%-10i" % [
|
70
|
-
block_number,
|
71
|
-
block.record[:type],
|
72
|
-
space_id,
|
73
|
-
block.record[:page_number],
|
74
|
-
]
|
75
|
-
if @options.dump
|
76
|
-
block.dump
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
89
|
+
mode ||= "log-summary"
|
90
|
+
|
91
|
+
case mode
|
92
|
+
when "log-summary"
|
93
|
+
log_summary(log, @options.space_ids)
|
94
|
+
else
|
95
|
+
usage 1, "Unknown mode: #{mode}"
|
80
96
|
end
|
data/lib/innodb/inode.rb
CHANGED
data/lib/innodb/system.rb
CHANGED
@@ -48,6 +48,36 @@ class Innodb::System
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
def object_by_field(method, field, value)
|
52
|
+
send(method).select { |o| o[field] == value }.first
|
53
|
+
end
|
54
|
+
|
55
|
+
def object_by_two_fields(method, f1, v1, f2, v2)
|
56
|
+
send(method).select { |o| o[f1] == v1 && o[f2] == v2 }.first
|
57
|
+
end
|
58
|
+
|
59
|
+
def table_by_id(value)
|
60
|
+
object_by_field(:each_table, "ID", value)
|
61
|
+
end
|
62
|
+
|
63
|
+
def table_by_name(value)
|
64
|
+
object_by_field(:each_table, "NAME", value)
|
65
|
+
end
|
66
|
+
|
67
|
+
def index_by_id(value)
|
68
|
+
object_by_field(:each_index, "ID", value)
|
69
|
+
end
|
70
|
+
|
71
|
+
def index_by_name(table_name, index_name)
|
72
|
+
unless table = table_by_name(table_name)
|
73
|
+
return nil
|
74
|
+
end
|
75
|
+
|
76
|
+
object_by_two_fields(:each_index,
|
77
|
+
"TABLE_ID", table["ID"],
|
78
|
+
"NAME", index_name)
|
79
|
+
end
|
80
|
+
|
51
81
|
def add_space(space)
|
52
82
|
@spaces[space.space_id] = space
|
53
83
|
end
|
data/lib/innodb/version.rb
CHANGED
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.8.
|
4
|
+
version: 0.8.6
|
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-
|
13
|
+
date: 2014-02-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bindata
|