@@ -26,6 +26,16 @@ type canalTestSuite struct {
26
26
27
27
var _ = Suite (& canalTestSuite {})
28
28
29
+ const (
30
+ miA = 0
31
+ miB = - 1
32
+ miC = 1
33
+
34
+ umiA = 0
35
+ umiB = 1
36
+ umiC = 16777215
37
+ )
38
+
29
39
func (s * canalTestSuite ) SetUpSuite (c * C ) {
30
40
cfg := NewDefaultConfig ()
31
41
cfg .Addr = fmt .Sprintf ("%s:3306" , * testHost )
@@ -62,7 +72,11 @@ func (s *canalTestSuite) SetUpSuite(c *C) {
62
72
s .execute (c , sql )
63
73
64
74
s .execute (c , "DELETE FROM test.canal_test" )
65
- s .execute (c , "INSERT INTO test.canal_test (content, name, mi, umi) VALUES (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?)" , "1" , "a" , 0 , 0 , `\0\ndsfasdf` , "b" , 1 , 16777215 , "" , "c" , - 1 , 1 )
75
+ s .execute (c , "INSERT INTO test.canal_test (content, name, mi, umi) VALUES (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?)" ,
76
+ "1" , "a" , miA , umiA ,
77
+ `\0\ndsfasdf` , "b" , miC , umiC ,
78
+ "" , "c" , miB , umiB ,
79
+ )
66
80
67
81
s .execute (c , "SET GLOBAL binlog_format = 'ROW'" )
68
82
@@ -99,7 +113,7 @@ type testEventHandler struct {
99
113
func (h * testEventHandler ) OnRow (e * RowsEvent ) error {
100
114
log .Infof ("OnRow %s %v\n " , e .Action , e .Rows )
101
115
umi , ok := e .Rows [0 ][4 ].(uint32 ) // 4th col is umi. mysqldump gives uint64 instead of uint32
102
- if ok && (umi != 0 && umi != 1 && umi != 16777215 ) {
116
+ if ok && (umi != umiA && umi != umiB && umi != umiC ) {
103
117
return fmt .Errorf ("invalid unsigned medium int %d" , umi )
104
118
}
105
119
return nil
@@ -119,7 +133,11 @@ func (s *canalTestSuite) TestCanal(c *C) {
119
133
for i := 1 ; i < 10 ; i ++ {
120
134
s .execute (c , "INSERT INTO test.canal_test (name) VALUES (?)" , fmt .Sprintf ("%d" , i ))
121
135
}
122
- s .execute (c , "INSERT INTO test.canal_test (mi,umi) VALUES (?,?), (?,?), (?,?)" , 0 , 0 , - 1 , 16777215 , 1 , 1 )
136
+ s .execute (c , "INSERT INTO test.canal_test (mi,umi) VALUES (?,?), (?,?), (?,?)" ,
137
+ miA , umiA ,
138
+ miC , umiC ,
139
+ miB , umiB ,
140
+ )
123
141
s .execute (c , "ALTER TABLE test.canal_test ADD `age` INT(5) NOT NULL AFTER `name`" )
124
142
s .execute (c , "INSERT INTO test.canal_test (name,age) VALUES (?,?)" , "d" , "18" )
125
143
0 commit comments