19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/mysql_replicator/binlogs/query_event_parser.rb', line 19
def self.parse(payload, checksum_enabled)
offset = 0
thread_id = MysqlReplicator::StringUtil.read_uint32(payload[offset, 4])
offset += 4
exec_time = MysqlReplicator::StringUtil.read_uint32(payload[offset, 4])
offset += 4
db_len = MysqlReplicator::StringUtil.read_uint8(payload[offset])
offset += 1
error_code = MysqlReplicator::StringUtil.read_uint16(payload[offset, 2])
offset += 2
status_vars_len = MysqlReplicator::StringUtil.read_uint16(payload[offset, 2])
offset += 2
if status_vars_len > 0
offset += status_vars_len
end
if db_len > 0
database = payload[offset, db_len]
offset += db_len
end
if offset < payload.length && payload[offset] == "\x00"
offset += 1
end
if offset < payload.length
sql_end = checksum_enabled ? -5 : -1
sql = payload[offset..sql_end]
end
{
thread_id: thread_id,
exec_time: exec_time,
error_code: error_code,
database: database,
sql: sql
}
end
|