innodb_ruby 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/innodb_space +103 -28
- data/lib/innodb/list.rb +5 -0
- data/lib/innodb/system.rb +3 -3
- data/lib/innodb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2dd793281e3b83403e55c8d4e9104898d5df6099af80dd4453795a524e3fb32
|
4
|
+
data.tar.gz: d6ac28ab11759a618f9a84af611a705644f5f47f9c1cd387360b628bac88f527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffb5ba4b9805d4cb78aaecaec92adb4e6064d73a9349fbeb43fcc938b958adeb14f140747dd540f76d31bbf9a38fbde259bd99f3a9cc64f32a1456efc2006997
|
7
|
+
data.tar.gz: 9e98bd61fe4448fdbb15be66975581fe65d97c342685c21f2309ead8b0ed1fc217b08baf2855c336d8ea426e22b7c0556e0926064722e6cc23a95312a6a63ca4
|
data/bin/innodb_space
CHANGED
@@ -6,6 +6,18 @@ require "ostruct"
|
|
6
6
|
require "histogram/array"
|
7
7
|
require "innodb"
|
8
8
|
|
9
|
+
class String
|
10
|
+
def squish!
|
11
|
+
gsub!(/[[:space:]]+/, " ")
|
12
|
+
strip!
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def squish
|
17
|
+
dup.squish!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
9
21
|
# Convert a floating point RGB array into an ANSI color number approximating it.
|
10
22
|
def rgb_to_ansi(rgb)
|
11
23
|
rgb_n = rgb.map { |c| (c * 5.0).round }
|
@@ -1045,6 +1057,8 @@ def record_dump(page, record_offset)
|
|
1045
1057
|
raise "Record at offset #{record_offset} not found" unless record
|
1046
1058
|
|
1047
1059
|
record.dump
|
1060
|
+
rescue IOError
|
1061
|
+
raise "Record could not be read at offset #{record_offset}; is it a valid record offset?"
|
1048
1062
|
end
|
1049
1063
|
|
1050
1064
|
def record_history(page, record_offset)
|
@@ -1243,14 +1257,15 @@ Usage: innodb_space <options> <mode>
|
|
1243
1257
|
|
1244
1258
|
Invocation examples:
|
1245
1259
|
|
1246
|
-
innodb_space -s ibdata1 [-T
|
1247
|
-
Use ibdata1 as the system tablespace and load the
|
1248
|
-
|
1249
|
-
tablespace data dictionary. This will automatically generate a
|
1250
|
-
describer for any indexes.
|
1260
|
+
innodb_space -s ibdata1 [-T table-name [-I index-name [-R record-offset]]] [options] <mode>
|
1261
|
+
Use ibdata1 as the system tablespace and load the table-name table (and
|
1262
|
+
the index-name index for modes that require it) from data located in the
|
1263
|
+
system tablespace data dictionary. This will automatically generate a
|
1264
|
+
record describer for any indexes using the data dictionary.
|
1251
1265
|
|
1252
|
-
innodb_space -f
|
1253
|
-
Use the
|
1266
|
+
innodb_space -f file-name.ibd [-r ./describer.rb -d DescriberClass] [options] <mode>
|
1267
|
+
Use the file-name.ibd tablespace file (and the DescriberClass describer
|
1268
|
+
where required) to read the tablespace structures or indexes.
|
1254
1269
|
|
1255
1270
|
The following options are supported:
|
1256
1271
|
|
@@ -1269,11 +1284,22 @@ The following options are supported:
|
|
1269
1284
|
files named 'ibdata?' which will then be sorted alphabetically and used to
|
1270
1285
|
load the system tablespace.
|
1271
1286
|
|
1272
|
-
--
|
1273
|
-
|
1287
|
+
If using the --system-space-file option, the following options may also
|
1288
|
+
be used:
|
1289
|
+
|
1290
|
+
--table-name, -T <name>
|
1291
|
+
Use the table name <name>.
|
1292
|
+
|
1293
|
+
--index-name, -I <name>
|
1294
|
+
Use the index name <name>.
|
1274
1295
|
|
1275
|
-
|
1276
|
-
|
1296
|
+
--system-space-tables, -x
|
1297
|
+
Allow opening tables from the system space to support system spaces with
|
1298
|
+
tables created without innodb-file-per-table enabled.
|
1299
|
+
|
1300
|
+
--data-directory, -D <directory>
|
1301
|
+
Open per-table tablespace files from <directory> rather than from the
|
1302
|
+
directory where the system-space-file is located.
|
1277
1303
|
|
1278
1304
|
--space-file, -f <file>
|
1279
1305
|
Load the tablespace file <file>.
|
@@ -1281,6 +1307,9 @@ The following options are supported:
|
|
1281
1307
|
--page, -p <page>
|
1282
1308
|
Operate on the page <page>.
|
1283
1309
|
|
1310
|
+
--record, -R <offset>
|
1311
|
+
Operate on the record located at <offset> within the index page.
|
1312
|
+
|
1284
1313
|
--level, -l <level>
|
1285
1314
|
Operate on the level <level>.
|
1286
1315
|
|
@@ -1451,12 +1480,15 @@ END_OF_USAGE
|
|
1451
1480
|
exit exit_code
|
1452
1481
|
end
|
1453
1482
|
|
1454
|
-
|
1455
|
-
Signal.trap(
|
1483
|
+
%w[INT PIPE].each do |name|
|
1484
|
+
Signal.trap(name) { exit } if Signal.list.include?(name)
|
1485
|
+
end
|
1456
1486
|
|
1457
1487
|
@options = OpenStruct.new
|
1458
1488
|
@options.trace = 0
|
1459
1489
|
@options.system_space_file = nil
|
1490
|
+
@options.system_space_tables = false
|
1491
|
+
@options.data_directory = nil
|
1460
1492
|
@options.space_file = nil
|
1461
1493
|
@options.table_name = nil
|
1462
1494
|
@options.index_name = nil
|
@@ -1474,6 +1506,8 @@ getopt_options = [
|
|
1474
1506
|
[ "--help", "-?", GetoptLong::NO_ARGUMENT ],
|
1475
1507
|
[ "--trace", "-t", GetoptLong::NO_ARGUMENT ],
|
1476
1508
|
[ "--system-space-file", "-s", GetoptLong::REQUIRED_ARGUMENT ],
|
1509
|
+
[ "--system-space-tables", "-x", GetoptLong::NO_ARGUMENT ],
|
1510
|
+
[ "--data-directory", "-D", GetoptLong::REQUIRED_ARGUMENT ],
|
1477
1511
|
[ "--space-file", "-f", GetoptLong::REQUIRED_ARGUMENT ],
|
1478
1512
|
[ "--table-name", "-T", GetoptLong::REQUIRED_ARGUMENT ],
|
1479
1513
|
[ "--index-name", "-I", GetoptLong::REQUIRED_ARGUMENT ],
|
@@ -1499,6 +1533,10 @@ getopt.each do |opt, arg|
|
|
1499
1533
|
@options.trace += 1
|
1500
1534
|
when "--system-space-file"
|
1501
1535
|
@options.system_space_file = arg.split(",")
|
1536
|
+
when "--system-space-tables"
|
1537
|
+
@options.system_space_tables = true
|
1538
|
+
when "--data-directory"
|
1539
|
+
@options.data_directory = arg
|
1502
1540
|
when "--space-file"
|
1503
1541
|
@options.space_file = arg.split(",")
|
1504
1542
|
when "--table-name"
|
@@ -1529,11 +1567,24 @@ end
|
|
1529
1567
|
# rubocop:disable Style/IfUnlessModifier
|
1530
1568
|
|
1531
1569
|
unless @options.system_space_file || @options.space_file
|
1532
|
-
usage
|
1570
|
+
usage(1, "Either the --system-space-file (-s) or --space-file (-f) must be specified")
|
1533
1571
|
end
|
1534
1572
|
|
1535
1573
|
if @options.system_space_file && @options.space_file
|
1536
|
-
usage
|
1574
|
+
usage(1, "Only one of --system-space-file (-s) or --space-file (-f) may be specified")
|
1575
|
+
end
|
1576
|
+
|
1577
|
+
system_space_options =
|
1578
|
+
@options.table_name || @options.index_name || @options.system_space_tables || @options.data_directory
|
1579
|
+
|
1580
|
+
if !@options.system_space_file && system_space_options
|
1581
|
+
usage(
|
1582
|
+
1,
|
1583
|
+
%{
|
1584
|
+
The --table-name (-T), --index-name (-I), --system-space-tables (-x), and --data-directory (-D)
|
1585
|
+
options can only be used with the --system-space-file (-s) option
|
1586
|
+
}.squish
|
1587
|
+
)
|
1537
1588
|
end
|
1538
1589
|
|
1539
1590
|
BufferCursor.trace! if @options.trace > 1
|
@@ -1545,12 +1596,18 @@ index = nil
|
|
1545
1596
|
page = nil
|
1546
1597
|
|
1547
1598
|
if @options.system_space_file
|
1548
|
-
innodb_system = Innodb::System.new(@options.system_space_file)
|
1599
|
+
innodb_system = Innodb::System.new(@options.system_space_file, data_directory: @options.data_directory)
|
1549
1600
|
end
|
1550
1601
|
|
1551
1602
|
if innodb_system && @options.table_name
|
1552
1603
|
table_tablespace = innodb_system.space_by_table_name(@options.table_name)
|
1553
|
-
|
1604
|
+
if table_tablespace
|
1605
|
+
space = table_tablespace
|
1606
|
+
elsif @options.system_space_tables
|
1607
|
+
space = innodb_system.system_space
|
1608
|
+
else
|
1609
|
+
raise "Tablespace file not found and --system-space-tables (-x) is not enabled"
|
1610
|
+
end
|
1554
1611
|
elsif @options.space_file
|
1555
1612
|
space = Innodb::Space.new(@options.space_file)
|
1556
1613
|
else
|
@@ -1580,39 +1637,57 @@ unless mode
|
|
1580
1637
|
end
|
1581
1638
|
|
1582
1639
|
if /^(system-|data-dictionary-)/.match(mode) && !innodb_system
|
1583
|
-
usage(1, "System tablespace must be specified using
|
1640
|
+
usage(1, "System tablespace must be specified using --system-space-file (-s)")
|
1584
1641
|
end
|
1585
1642
|
|
1586
1643
|
if /^space-/.match(mode) && !space
|
1587
1644
|
usage(
|
1588
1645
|
1,
|
1589
|
-
|
1590
|
-
|
1646
|
+
%{
|
1647
|
+
Tablespace must be specified using either --space-file (-f)
|
1648
|
+
or a combination of --system-space-file (-s) and --table (-T)
|
1649
|
+
}.squish
|
1591
1650
|
)
|
1592
1651
|
end
|
1593
1652
|
|
1594
1653
|
if /^index-/.match(mode) && !index
|
1595
1654
|
usage(
|
1596
1655
|
1,
|
1597
|
-
|
1598
|
-
|
1656
|
+
%{
|
1657
|
+
Index must be specified using a combination of either --space-file (-f) and --page (-p)
|
1658
|
+
or --system-space-file (-s), --table-name (-T), and --index-name (-I)
|
1659
|
+
}.squish
|
1599
1660
|
)
|
1600
1661
|
end
|
1601
1662
|
|
1602
1663
|
if /^page-/.match(mode) && !page
|
1603
|
-
usage(1, "Page number must be specified using -p
|
1664
|
+
usage(1, "Page number must be specified using --page (-p)")
|
1604
1665
|
end
|
1605
1666
|
|
1606
1667
|
if /^record-/.match(mode) && !@options.record
|
1607
|
-
usage(1, "Record offset must be specified using -R
|
1668
|
+
usage(1, "Record offset must be specified using --record (-R)")
|
1669
|
+
end
|
1670
|
+
|
1671
|
+
if /^record-/.match(mode) && !page
|
1672
|
+
usage(
|
1673
|
+
1,
|
1674
|
+
%{
|
1675
|
+
An index page must be available when using --record (-R); specify either
|
1676
|
+
--page (-p) or --table-name (-T) and --index-name (-I) for the index root page.
|
1677
|
+
}
|
1678
|
+
)
|
1679
|
+
end
|
1680
|
+
|
1681
|
+
if /^record-/.match(mode) && page.type != :INDEX
|
1682
|
+
usage(1, "Mode #{mode} may be used only with index pages")
|
1608
1683
|
end
|
1609
1684
|
|
1610
1685
|
if /-list-iterate$/.match(mode) && !@options.list
|
1611
|
-
usage(1, "List name must be specified using -L
|
1686
|
+
usage(1, "List name must be specified using --list (-L)")
|
1612
1687
|
end
|
1613
1688
|
|
1614
1689
|
if /-level-/.match(mode) && !@options.level
|
1615
|
-
usage(1, "Level must be specified using -l
|
1690
|
+
usage(1, "Level must be specified using --level (-l)")
|
1616
1691
|
end
|
1617
1692
|
|
1618
1693
|
if %w[
|
@@ -1621,13 +1696,13 @@ if %w[
|
|
1621
1696
|
index-digraph
|
1622
1697
|
index-level-summary
|
1623
1698
|
].include?(mode) && !index.record_describer
|
1624
|
-
usage(1, "Record describer must be specified using -d
|
1699
|
+
usage(1, "Record describer must be specified using --describer (-d)")
|
1625
1700
|
end
|
1626
1701
|
|
1627
1702
|
if %w[
|
1628
1703
|
space-index-fseg-pages-summary
|
1629
1704
|
].include?(mode) && !@options.fseg_id
|
1630
|
-
usage(1, "File segment id must be specified using
|
1705
|
+
usage(1, "File segment id must be specified using --fseg-id (-F)")
|
1631
1706
|
end
|
1632
1707
|
|
1633
1708
|
# rubocop:enable Style/IfUnlessModifier
|
data/lib/innodb/list.rb
CHANGED
data/lib/innodb/system.rb
CHANGED
@@ -19,7 +19,7 @@ module Innodb
|
|
19
19
|
# The space ID of the system space, always 0.
|
20
20
|
SYSTEM_SPACE_ID = 0
|
21
21
|
|
22
|
-
def initialize(arg)
|
22
|
+
def initialize(arg, data_directory: nil)
|
23
23
|
if arg.is_a?(Array) && arg.size > 1
|
24
24
|
data_filenames = arg
|
25
25
|
else
|
@@ -35,7 +35,7 @@ module Innodb
|
|
35
35
|
@spaces = {}
|
36
36
|
@orphans = []
|
37
37
|
@config = {
|
38
|
-
|
38
|
+
data_directory: data_directory || File.dirname(data_filenames.first),
|
39
39
|
}
|
40
40
|
|
41
41
|
add_space_file(data_filenames)
|
@@ -70,7 +70,7 @@ module Innodb
|
|
70
70
|
# Add a space by table name, constructing an appropriate filename
|
71
71
|
# from the provided table name.
|
72
72
|
def add_table(table_name)
|
73
|
-
space_file = "%s/%s.ibd" % [config[:
|
73
|
+
space_file = "%s/%s.ibd" % [config[:data_directory], table_name]
|
74
74
|
if File.exist?(space_file)
|
75
75
|
add_space_file(space_file)
|
76
76
|
else
|
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.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Cole
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bindata
|