-
Notifications
You must be signed in to change notification settings - Fork 78
/
开源库所做的修改.txt
131 lines (107 loc) · 4.09 KB
/
开源库所做的修改.txt
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
binlog_inspector所使用的两个开源库所做的改动
1)增加两个可导出的函数ParseHeader与ParseEvent
github.com\siddontang\go-mysql\replication\parser.go
// added by danny
func (p *BinlogParser) ParseHeader(data []byte) (*EventHeader, error) {
return p.parseHeader(data)
}
func (p *BinlogParser) parseHeader(data []byte) (*EventHeader, error) {
h := new(EventHeader)
err := h.Decode(data)
if err != nil {
return nil, err
}
return h, nil
}
// added by danny
func (p *BinlogParser) ParseEvent(h *EventHeader, data []byte, rawData []byte) (Event, error) {
return p.parseEvent(h, data, rawData)
}
func (p *BinlogParser) parseEvent(h *EventHeader, data []byte, rawData []byte) (Event, error) {
var e Event
2)修改让database名与table名可选是否加在前缀
github.com\dropbox\godropbox\database\sqlbuilder\column.go
func (c *baseColumn) SerializeSqlForColumnList(out *bytes.Buffer) error {
// danny modified. we don't need prefixing table name
/*
if c.table != "" {
_ = out.WriteByte('`')
_, _ = out.WriteString(c.table)
_, _ = out.WriteString("`.")
}
*/
_, _ = out.WriteString("`")
_, _ = out.WriteString(c.name)
_ = out.WriteByte('`')
return nil
}
github.com\dropbox\godropbox\database\sqlbuilder\statement.go:
func (s *insertStatementImpl) String(database string) (sql string, err error) {
// danny modified. if database empty, not validate it
if database != "" && !validIdentifierName(database) {
return "", errors.New("Invalid database name specified")
}
buf := new(bytes.Buffer)
_, _ = buf.WriteString("INSERT ")
if s.ignore {
_, _ = buf.WriteString("IGNORE ")
}
func (u *updateStatementImpl) String(database string) (sql string, err error) {
// danny modify. we need to optionally set database name
if database != "" && !validIdentifierName(database) {
return "", errors.New("Invalid database name specified")
}
buf := new(bytes.Buffer)
_, _ = buf.WriteString("UPDATE ")
func (d *deleteStatementImpl) String(database string) (sql string, err error) {
// danny modify. we need to optionally set database name
if database != "" && !validIdentifierName(database) {
return "", errors.New("Invalid database name specified")
}
buf := new(bytes.Buffer)
_, _ = buf.WriteString("DELETE FROM ")
D:\danny\src\go\src\binlog_inspector\vendor\github.com\dropbox\godropbox\database\sqlbuilder\table.go:
func (t *Table) SerializeSql(database string, out *bytes.Buffer) error {
//danny modified. if database empty, not write
if database != "" {
_, _ = out.WriteString("`")
_, _ = out.WriteString(database)
_, _ = out.WriteString("`.")
}
_, _ = out.WriteString("`")
_, _ = out.WriteString(t.Name())
D:\danny\src\go\src\binlog_inspector\vendor\github.com\dropbox\godropbox\database\sqltypes\sqltypes.go:
func BuildValue(goval interface{}) (v Value, err error) {
switch bindVal := goval.(type) {
case nil:
// no op
case bool:
val := 0
if bindVal {
val = 1
}
v = Value{Numeric(strconv.AppendInt(nil, int64(val), 10))}
//danny added
case int8:
v = Value{Numeric(strconv.AppendInt(nil, int64(bindVal), 10))}
//danny added
case int16:
v = Value{Numeric(strconv.AppendInt(nil, int64(bindVal), 10))}
case int:
v = Value{Numeric(strconv.AppendInt(nil, int64(bindVal), 10))}
case int32:
v = Value{Numeric(strconv.AppendInt(nil, int64(bindVal), 10))}
case int64:
v = Value{Numeric(strconv.AppendInt(nil, int64(bindVal), 10))}
case uint:
v = Value{Numeric(strconv.AppendUint(nil, uint64(bindVal), 10))}
case uint8:
v = Value{Numeric(strconv.AppendUint(nil, uint64(bindVal), 10))}
case uint32:
v = Value{Numeric(strconv.AppendUint(nil, uint64(bindVal), 10))}
case uint64:
v = Value{Numeric(strconv.AppendUint(nil, uint64(bindVal), 10))}
//danny added
case float32:
v = Value{Fractional(strconv.AppendFloat(nil, float64(bindVal), 'f', -1, 64))}
case float64: