24
24
--checksum, -c
25
25
Enable CRC32 checksums.
26
26
27
+ --position, -j
28
+ Start the first file at a particular position.
29
+
27
30
--debug, -d
28
31
Debug reading from the binary log, showing calls into the reader and the
29
32
data bytes read. This is useful for debugging the mysql_binlog library
47
50
@options = OpenStruct . new
48
51
@options . file = nil
49
52
@options . checksum = nil
53
+ @options . position = nil
50
54
@options . debug = false
51
55
@options . tail = false
52
56
@options . rotate = false
@@ -56,6 +60,7 @@ getopt_options = [
56
60
[ "--help" , "-?" , GetoptLong ::NO_ARGUMENT ] ,
57
61
[ "--file" , "-f" , GetoptLong ::REQUIRED_ARGUMENT ] ,
58
62
[ "--checksum" , "-c" , GetoptLong ::NO_ARGUMENT ] ,
63
+ [ "--position" , "-j" , GetoptLong ::REQUIRED_ARGUMENT ] ,
59
64
[ "--debug" , "-d" , GetoptLong ::NO_ARGUMENT ] ,
60
65
[ "--tail" , "-t" , GetoptLong ::NO_ARGUMENT ] ,
61
66
[ "--rotate" , "-r" , GetoptLong ::NO_ARGUMENT ] ,
@@ -71,6 +76,8 @@ getopt.each do |opt, arg|
71
76
@options . filenames << arg
72
77
when "--checksum"
73
78
@options . checksum = :crc32
79
+ when "--position"
80
+ @options . position = arg . to_i
74
81
when "--debug"
75
82
@options . debug = true
76
83
when "--tail"
@@ -86,7 +93,7 @@ if @options.filenames.empty?
86
93
usage 1 , "One or more filenames must be provided"
87
94
end
88
95
89
- @options . filenames . each do |filename |
96
+ @options . filenames . each_with_index do |filename , i |
90
97
reader = MysqlBinlog ::BinlogFileReader . new ( filename )
91
98
if @options . debug
92
99
reader = MysqlBinlog ::DebuggingReader . new ( reader , :data => true , :calls => true )
97
104
reader . tail = @options . tail
98
105
binlog . ignore_rotate = !@options . rotate
99
106
107
+ binlog . seek ( @options . position ) if @options . position && i . zero?
108
+
100
109
binlog . each_event do |event |
101
110
pp event
102
111
puts
0 commit comments