/
binlog.proto
85 lines (64 loc) · 2.92 KB
/
binlog.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
syntax = "proto2";
package binlog;
import "gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
enum MutationType {
Insert = 0;
Update = 1;
DeleteID = 2; // Obsolete field.
DeletePK = 3; // Obsolete field.
DeleteRow = 4;
}
// TableMutation contains mutations in a table.
message TableMutation {
optional int64 table_id = 1 [(gogoproto.nullable) = false];
// The inserted row contains all column values.
repeated bytes inserted_rows = 2;
// The updated row contains old values and new values of the row.
repeated bytes updated_rows = 3;
// Obsolete field.
repeated int64 deleted_ids = 4;
// Obsolete field.
repeated bytes deleted_pks = 5;
// The row value of the deleted row.
repeated bytes deleted_rows = 6;
// Used to apply table mutations in original sequence.
repeated MutationType sequence = 7;
}
message PrewriteValue {
optional int64 schema_version = 1 [(gogoproto.nullable) = false];
repeated TableMutation mutations = 2 [(gogoproto.nullable) = false];
}
enum BinlogType {
Prewrite = 0; // has start_ts, prewrite_key, prewrite_value.
Commit = 1; // has start_ts, commit_ts.
Rollback = 2; // has start_ts.
PreDDL = 3; // Obsolete field.
PostDDL = 4; // Obsolete field.
}
// Binlog contains all the changes in a transaction, which can be used to reconstruct SQL statement, then export to
// other systems.
message Binlog {
optional BinlogType tp = 1 [(gogoproto.nullable) = false];
// start_ts is used in Prewrite, Commit and Rollback binlog Type.
// It is used for pairing prewrite log to commit log or rollback log.
optional int64 start_ts = 2 [(gogoproto.nullable) = false];
// commit_ts is used only in binlog type Commit.
optional int64 commit_ts = 3 [(gogoproto.nullable) = false];
// prewrite key is used only in Prewrite binlog type.
// It is the primary key of the transaction, is used to check that the transaction is
// commited or not if it failed to pair to commit log or rollback log within a time window.
optional bytes prewrite_key = 4;
// prewrite_data is marshalled from PrewriteData type,
// we do not need to unmarshal prewrite data before the binlog have been successfully paired.
optional bytes prewrite_value = 5;
// ddl_query is the original DDL statement query.
optional bytes ddl_query = 6;
// ddl_job_id is used for DDL Binlog.
// If ddl_job_id is setted, this is a DDL Binlog and ddl_query contains the DDL query, we can query the informations about this job from TiKV.
optional int64 ddl_job_id = 7 [(gogoproto.nullable) = false];
// ddl_schema_state is used for DDL Binlog.
optional int32 ddl_schema_state = 8 [(gogoproto.nullable) = false];
}