innodb_ruby 0.9.11 → 0.9.12
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.
- data/README.md +2 -0
- data/bin/innodb_space +8 -4
- data/lib/innodb/page/fsp_hdr_xdes.rb +1 -1
- data/lib/innodb/space.rb +45 -17
- data/lib/innodb/system.rb +19 -5
- data/lib/innodb/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -13,7 +13,9 @@ Various parts of this library and the tools included may have wildly differing m
|
|
13
13
|
|
14
14
|
# Resources #
|
15
15
|
|
16
|
+
* The [innodb_ruby wiki](https://github.com/jeremycole/innodb_ruby/wiki) contains some additional references and documentation to help you get started.
|
16
17
|
* Visit the [innodb_ruby mailing list on Google Groups](https://groups.google.com/d/forum/innodb_ruby) or email [innodb_ruby@googlegroups.com](mailto:innodb_ruby@googlegroups.com) — If you have questions about `innodb_ruby` or its usage.
|
17
18
|
* See the [RubyGems page for innodb_ruby](http://rubygems.org/gems/innodb_ruby) — Gem packaged releases are published regularly to RubyGems.org, which also provides online documentation.
|
18
19
|
|
20
|
+
|
19
21
|
[](https://travis-ci.org/jeremycole/innodb_ruby)
|
data/bin/innodb_space
CHANGED
@@ -1100,8 +1100,12 @@ The following options are supported:
|
|
1100
1100
|
tracing (including reads during opening of the tablespace) which can
|
1101
1101
|
be quite noisy.
|
1102
1102
|
|
1103
|
-
--system-space-file, -s <
|
1104
|
-
Load the system tablespace file <file
|
1103
|
+
--system-space-file, -s <arg>
|
1104
|
+
Load the system tablespace file or files <arg>: Either a single file e.g.
|
1105
|
+
"ibdata1", a comma-delimited list of files e.g. "ibdata1,ibdata1", or a
|
1106
|
+
directory name. If a directory name is provided, it will be scanned for all
|
1107
|
+
files named "ibdata?" which will then be sorted alphabetically and used to
|
1108
|
+
load the system tablespace.
|
1105
1109
|
|
1106
1110
|
--table-name, -T <name>
|
1107
1111
|
Use the table name <name>.
|
@@ -1309,9 +1313,9 @@ getopt.each do |opt, arg|
|
|
1309
1313
|
when "--trace"
|
1310
1314
|
@options.trace += 1
|
1311
1315
|
when "--system-space-file"
|
1312
|
-
@options.system_space_file = arg
|
1316
|
+
@options.system_space_file = arg.split(",")
|
1313
1317
|
when "--space-file"
|
1314
|
-
@options.space_file = arg
|
1318
|
+
@options.space_file = arg.split(",")
|
1315
1319
|
when "--table-name"
|
1316
1320
|
@options.table_name = arg
|
1317
1321
|
when "--index-name"
|
@@ -52,7 +52,7 @@ class Innodb::Page::FspHdrXdes < Innodb::Page
|
|
52
52
|
:compressed => compressed_page_size ? false : true,
|
53
53
|
:page_size => compressed_page_size || system_page_size,
|
54
54
|
:post_antelope => read_bits_at_offset(flags, 1, 0) == 1,
|
55
|
-
:
|
55
|
+
:atomic_blobs => read_bits_at_offset(flags, 1, 5) == 1,
|
56
56
|
:data_directory => read_bits_at_offset(flags, 1, 10) == 1,
|
57
57
|
:value => flags,
|
58
58
|
}
|
data/lib/innodb/space.rb
CHANGED
@@ -20,11 +20,39 @@ class Innodb::Space
|
|
20
20
|
7 => :SYS,
|
21
21
|
}
|
22
22
|
|
23
|
+
class DataFile
|
24
|
+
attr_reader :file
|
25
|
+
attr_reader :size
|
26
|
+
attr_reader :offset
|
27
|
+
|
28
|
+
def initialize(filename, offset)
|
29
|
+
@file = File.open(filename)
|
30
|
+
@size = @file.stat.size
|
31
|
+
@offset = offset
|
32
|
+
end
|
33
|
+
|
34
|
+
def name
|
35
|
+
prefix = ""
|
36
|
+
if File.extname(file.path) == ".ibd"
|
37
|
+
prefix = File.basename(File.dirname(file.path)) + "/"
|
38
|
+
end
|
39
|
+
|
40
|
+
prefix + File.basename(file.path)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
23
44
|
# Open a space file, optionally providing the page size to use. Pages
|
24
45
|
# that aren't 16 KiB may not be supported well.
|
25
|
-
def initialize(
|
26
|
-
|
27
|
-
|
46
|
+
def initialize(filenames)
|
47
|
+
filenames = [filenames] unless filenames.is_a?(Array)
|
48
|
+
|
49
|
+
@data_files = []
|
50
|
+
@size = 0
|
51
|
+
filenames.each do |filename|
|
52
|
+
file = DataFile.new(filename, @size)
|
53
|
+
@size += file.size
|
54
|
+
@data_files << file
|
55
|
+
end
|
28
56
|
|
29
57
|
@system_page_size = fsp_flags[:system_page_size]
|
30
58
|
@page_size = fsp_flags[:page_size]
|
@@ -58,14 +86,7 @@ class Innodb::Space
|
|
58
86
|
# to do anything which could instantiate a BufferCursor so that we can use
|
59
87
|
# this method in cursor initialization.
|
60
88
|
def name
|
61
|
-
|
62
|
-
|
63
|
-
prefix = ""
|
64
|
-
if File.extname(@file.path) == ".ibd"
|
65
|
-
prefix = File.basename(File.dirname(@file.path)) + "/"
|
66
|
-
end
|
67
|
-
|
68
|
-
@name = prefix + File.basename(@file.path)
|
89
|
+
@name ||= @data_files.map { |f| f.name }.join(",")
|
69
90
|
end
|
70
91
|
|
71
92
|
def inspect
|
@@ -184,18 +205,25 @@ class Innodb::Space
|
|
184
205
|
xdes_array[xdes_entry_for_page(page_number)]
|
185
206
|
end
|
186
207
|
|
208
|
+
def data_file_for_offset(offset)
|
209
|
+
@data_files.each do |file|
|
210
|
+
return file if offset < file.size
|
211
|
+
offset -= file.size
|
212
|
+
end
|
213
|
+
nil
|
214
|
+
end
|
215
|
+
|
187
216
|
# Get the raw byte buffer of size bytes at offset in the file.
|
188
217
|
def read_at_offset(offset, size)
|
189
|
-
@
|
190
|
-
|
218
|
+
return nil unless offset < @size && (offset + size) <= @size
|
219
|
+
data_file = data_file_for_offset(offset)
|
220
|
+
data_file.file.seek(offset - data_file.offset)
|
221
|
+
data_file.file.read(size)
|
191
222
|
end
|
192
223
|
|
193
224
|
# Get the raw byte buffer for a specific page by page number.
|
194
225
|
def page_data(page_number)
|
195
|
-
|
196
|
-
return nil unless offset < @size
|
197
|
-
return nil unless (offset + page_size) <= @size
|
198
|
-
read_at_offset(offset, page_size)
|
226
|
+
read_at_offset(page_number * page_size, page_size)
|
199
227
|
end
|
200
228
|
|
201
229
|
# Get an Innodb::Page object for a specific page by page number.
|
data/lib/innodb/system.rb
CHANGED
@@ -18,14 +18,28 @@ class Innodb::System
|
|
18
18
|
# The space ID of the system space, always 0.
|
19
19
|
SYSTEM_SPACE_ID = 0
|
20
20
|
|
21
|
-
def initialize(
|
21
|
+
def initialize(arg)
|
22
|
+
if arg.is_a?(Array) && arg.size > 1
|
23
|
+
data_filenames = arg
|
24
|
+
else
|
25
|
+
arg = arg.first if arg.is_a?(Array)
|
26
|
+
if File.directory?(arg)
|
27
|
+
data_filenames = Dir.glob(arg + "/ibdata?").sort
|
28
|
+
if data_filenames.empty?
|
29
|
+
raise "Couldn't find any ibdata files in #{arg}"
|
30
|
+
end
|
31
|
+
else
|
32
|
+
data_filenames = [arg]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
@spaces = {}
|
23
37
|
@orphans = []
|
24
38
|
@config = {
|
25
|
-
:datadir => File.dirname(
|
39
|
+
:datadir => File.dirname(data_filenames.first),
|
26
40
|
}
|
27
41
|
|
28
|
-
add_space_file(
|
42
|
+
add_space_file(data_filenames)
|
29
43
|
|
30
44
|
@data_dictionary = Innodb::DataDictionary.new(system_space)
|
31
45
|
end
|
@@ -45,8 +59,8 @@ class Innodb::System
|
|
45
59
|
end
|
46
60
|
|
47
61
|
# Add a space by filename.
|
48
|
-
def add_space_file(
|
49
|
-
space = Innodb::Space.new(
|
62
|
+
def add_space_file(space_filenames)
|
63
|
+
space = Innodb::Space.new(space_filenames)
|
50
64
|
space.innodb_system = self
|
51
65
|
add_space(space)
|
52
66
|
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.9.
|
4
|
+
version: 0.9.12
|
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-10-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bindata
|