@vlasky/zongji 0.5.9 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +16 -0
- package/.mcp.json +17 -0
- package/.tap/processinfo/84de694d-068b-4ac7-b4d8-f835c2122b2d.json +892 -0
- package/.tap/processinfo/a1e9627e-66eb-412c-aaa5-079a2eb9f385.json +891 -0
- package/.tap/processinfo/abc34c6f-f4aa-4405-8f9a-947048be1df2.json +892 -0
- package/.tap/processinfo/affe6c5b-a34d-41b9-bb73-4b14d35138de.json +891 -0
- package/.tap/processinfo/bf82449d-cdeb-478b-9506-b939a9506bf2.json +883 -0
- package/.tap/processinfo/dd98c508-7067-4342-bdf5-63664b630701.json +892 -0
- package/.tap/test-results/test_await_end.js.tap +19 -0
- package/.tap/test-results/test_await_end2.js.tap +27 -0
- package/.tap/test-results/test_debug_init.js.tap +23 -0
- package/.tap/test-results/test_debug_init2.js.tap +35 -0
- package/.tap/test-results/test_invalid_host.js.tap +34 -0
- package/.tap/test-results/test_minimal.js.tap +26 -0
- package/.tap/test-results/test_queryseq.js.tap +14 -0
- package/.tap/test-results/test_timing.js.tap +17 -0
- package/.tap/test-results/test_unref.js.tap +15 -0
- package/CHANGELOG.md +55 -0
- package/CLAUDE.md +99 -0
- package/GTID.md +54 -0
- package/README.md +44 -21
- package/TODO.md +43 -0
- package/docker-compose.yml +14 -13
- package/docker-test.sh +7 -7
- package/eslint.config.js +35 -0
- package/example.js +1 -1
- package/index.d.ts +314 -0
- package/index.js +444 -272
- package/jsconfig.json +15 -0
- package/lib/binlog_event.js +296 -217
- package/lib/code_map.js +7 -4
- package/lib/common.js +35 -22
- package/lib/datetime_decode.js +147 -34
- package/lib/json_decode.js +12 -6
- package/lib/packet/binlog.js +3 -3
- package/lib/packet/combinlog.js +22 -20
- package/lib/packet/index.js +50 -50
- package/lib/reader.js +215 -109
- package/lib/rows_event.js +98 -102
- package/lib/sequence/binlog.js +142 -39
- package/notes.md +77 -0
- package/package.json +15 -10
- package/scripts/start-mysql.sh +28 -0
- package/workerthreads.md +173 -0
- package/.eslintrc +0 -19
package/lib/reader.js
CHANGED
|
@@ -1,141 +1,247 @@
|
|
|
1
1
|
// Constants for variable length encoded binary
|
|
2
|
-
const NULL_COLUMN = 251;
|
|
3
|
-
const UNSIGNED_CHAR_COLUMN = 251;
|
|
4
|
-
const UNSIGNED_SHORT_COLUMN = 252;
|
|
5
|
-
const UNSIGNED_INT24_COLUMN = 253;
|
|
6
|
-
const UNSIGNED_INT64_COLUMN = 254;
|
|
7
|
-
|
|
8
|
-
function BufferReader(buffer) {
|
|
9
|
-
this.buffer = buffer;
|
|
10
|
-
this.position = 0;
|
|
11
|
-
}
|
|
2
|
+
export const NULL_COLUMN = 251;
|
|
3
|
+
export const UNSIGNED_CHAR_COLUMN = 251;
|
|
4
|
+
export const UNSIGNED_SHORT_COLUMN = 252;
|
|
5
|
+
export const UNSIGNED_INT24_COLUMN = 253;
|
|
6
|
+
export const UNSIGNED_INT64_COLUMN = 254;
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
8
|
+
const padWith = function(val, length) {
|
|
9
|
+
const bits = val.split('');
|
|
10
|
+
if (bits.length < length) {
|
|
11
|
+
const left = length - bits.length;
|
|
12
|
+
for (let j = left - 1; j >= 0; j--) {
|
|
13
|
+
bits.unshift('0');
|
|
14
|
+
}
|
|
15
|
+
val = bits.join('');
|
|
16
|
+
}
|
|
16
17
|
|
|
17
|
-
return
|
|
18
|
+
return val;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
BufferReader
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
class BufferReader {
|
|
22
|
+
constructor(buffer) {
|
|
23
|
+
this.buffer = buffer;
|
|
24
|
+
this.position = 0;
|
|
25
|
+
}
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
readUInt8() {
|
|
28
|
+
const pos = this.position;
|
|
29
|
+
this.position += 1;
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.position += 4;
|
|
31
|
+
return this.buffer.readUInt8(pos);
|
|
32
|
+
}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
readUInt16() {
|
|
35
|
+
const pos = this.position;
|
|
36
|
+
this.position += 2;
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const high = this.readUInt8();
|
|
37
|
-
return (high << 16) + low;
|
|
38
|
-
};
|
|
38
|
+
return this.buffer.readUInt16LE(pos);
|
|
39
|
+
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
readUInt32() {
|
|
42
|
+
const pos = this.position;
|
|
43
|
+
this.position += 4;
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
0x100000000 * this.buffer.readUInt32LE(pos + 4);
|
|
47
|
-
};
|
|
45
|
+
return this.buffer.readUInt32LE(pos);
|
|
46
|
+
}
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
readUInt24() {
|
|
49
|
+
const low = this.readUInt16();
|
|
50
|
+
const high = this.readUInt8();
|
|
51
|
+
return (high << 16) + low;
|
|
52
|
+
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
readUInt64() {
|
|
55
|
+
const pos = this.position;
|
|
56
|
+
this.position += 8;
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
// from http://stackoverflow.com/questions/17687307/convert-a-64bit-little-endian-integer-to-number
|
|
59
|
+
return this.buffer.readInt32LE(pos) +
|
|
60
|
+
0x100000000 * this.buffer.readUInt32LE(pos + 4);
|
|
61
|
+
}
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
readString() {
|
|
64
|
+
const strBuf = this.buffer.slice(this.position);
|
|
65
|
+
this.position = this.buffer.length;
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.position += length;
|
|
67
|
+
return strBuf.toString('ascii');
|
|
68
|
+
}
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
readStringInBytes(length) {
|
|
71
|
+
const strBuf = this.buffer.slice(this.position, this.position + length);
|
|
72
|
+
this.position += length;
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
const result = [];
|
|
72
|
-
const hexString = this.readHexInBytes(length);
|
|
73
|
-
for (let i = 0; i < hexString.length; i = i + 2) {
|
|
74
|
-
result.push(parseInt(hexString.substr(i, 2), 16));
|
|
74
|
+
return strBuf.toString('ascii');
|
|
75
75
|
}
|
|
76
|
-
return result;
|
|
77
|
-
};
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// integer values <= 250, or to encode the number of following bytes
|
|
83
|
-
// used to store the actual value, which can be 2, 3, or 8. It also
|
|
84
|
-
// includes support for SQL NULL as a special case.
|
|
85
|
-
BufferReader.prototype.readVariant = function() {
|
|
86
|
-
let result = null;
|
|
87
|
-
const firstByte = this.readUInt8();
|
|
88
|
-
|
|
89
|
-
if (firstByte < UNSIGNED_CHAR_COLUMN) {
|
|
90
|
-
result = firstByte;
|
|
91
|
-
} else if (firstByte === NULL_COLUMN) {
|
|
92
|
-
result = null;
|
|
93
|
-
} else if (firstByte === UNSIGNED_SHORT_COLUMN) {
|
|
94
|
-
result = this.readUInt16();
|
|
95
|
-
} else if (firstByte === UNSIGNED_INT24_COLUMN) {
|
|
96
|
-
result = this.readUInt24();
|
|
97
|
-
} else if (firstByte === UNSIGNED_INT64_COLUMN) {
|
|
98
|
-
result = this.readUInt64();
|
|
99
|
-
} else {
|
|
100
|
-
throw new Error('Invalid variable-length integer');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return result;
|
|
104
|
-
};
|
|
77
|
+
readHexInBytes(length) {
|
|
78
|
+
const buf = this.buffer.slice(this.position, this.position + length);
|
|
79
|
+
this.position += length;
|
|
105
80
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
81
|
+
return buf.toString('hex');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
readBytesArray(length) {
|
|
85
|
+
const result = [];
|
|
86
|
+
const hexString = this.readHexInBytes(length);
|
|
87
|
+
for (let i = 0; i < hexString.length; i = i + 2) {
|
|
88
|
+
result.push(parseInt(hexString.substr(i, 2), 16));
|
|
112
89
|
}
|
|
113
|
-
|
|
90
|
+
return result;
|
|
114
91
|
}
|
|
115
92
|
|
|
116
|
-
|
|
117
|
-
|
|
93
|
+
// Read a variable-length "Length Coded Binary" integer. This is derived
|
|
94
|
+
// from the MySQL protocol, and re-used in the binary log format. This
|
|
95
|
+
// format uses the first byte to alternately store the actual value for
|
|
96
|
+
// integer values <= 250, or to encode the number of following bytes
|
|
97
|
+
// used to store the actual value, which can be 2, 3, or 8. It also
|
|
98
|
+
// includes support for SQL NULL as a special case.
|
|
99
|
+
readVariant() {
|
|
100
|
+
let result = null;
|
|
101
|
+
const firstByte = this.readUInt8();
|
|
102
|
+
|
|
103
|
+
if (firstByte < UNSIGNED_CHAR_COLUMN) {
|
|
104
|
+
result = firstByte;
|
|
105
|
+
} else if (firstByte === NULL_COLUMN) {
|
|
106
|
+
result = null;
|
|
107
|
+
} else if (firstByte === UNSIGNED_SHORT_COLUMN) {
|
|
108
|
+
result = this.readUInt16();
|
|
109
|
+
} else if (firstByte === UNSIGNED_INT24_COLUMN) {
|
|
110
|
+
result = this.readUInt24();
|
|
111
|
+
} else if (firstByte === UNSIGNED_INT64_COLUMN) {
|
|
112
|
+
result = this.readUInt64();
|
|
113
|
+
} else {
|
|
114
|
+
throw new Error('Invalid variable-length integer');
|
|
115
|
+
}
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
BufferReader.prototype.readBitArray = function(length) {
|
|
122
|
-
const size = Math.floor((length + 7) / 8);
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
123
119
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
// Read an arbitrary-length bitmap, provided its length.
|
|
121
|
+
// Returns an array of true/false values.
|
|
122
|
+
readBitArray(length) {
|
|
123
|
+
const size = Math.floor((length + 7) / 8);
|
|
124
|
+
|
|
125
|
+
const bytes = [];
|
|
126
|
+
for (let i = size - 1; i >= 0; i--) {
|
|
127
|
+
bytes.unshift(this.readUInt8());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const bitmap = [];
|
|
131
|
+
const bitmapStr = bytes.map(function(aByte) {
|
|
132
|
+
return padWith(aByte.toString(2), 8);
|
|
133
|
+
}).join('');
|
|
134
|
+
|
|
135
|
+
for (let k = bitmapStr.length - 1; k >= 0; k--) {
|
|
136
|
+
bitmap.push(bitmapStr[k] === '1');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return bitmap.slice(0, length);
|
|
127
140
|
}
|
|
141
|
+
}
|
|
128
142
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
143
|
+
class Parser {
|
|
144
|
+
constructor(packet) {
|
|
145
|
+
this.packet = null;
|
|
146
|
+
this._buffer = null;
|
|
147
|
+
this._offsetValue = 0;
|
|
148
|
+
this._packetEndValue = 0;
|
|
133
149
|
|
|
134
|
-
|
|
135
|
-
|
|
150
|
+
if (packet) {
|
|
151
|
+
this.setPacket(packet);
|
|
152
|
+
}
|
|
136
153
|
}
|
|
137
154
|
|
|
138
|
-
|
|
139
|
-
|
|
155
|
+
get _offset() {
|
|
156
|
+
return this.packet ? this.packet.offset : this._offsetValue;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
set _offset(value) {
|
|
160
|
+
if (this.packet) {
|
|
161
|
+
this.packet.offset = value;
|
|
162
|
+
} else {
|
|
163
|
+
this._offsetValue = value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
get _packetEnd() {
|
|
168
|
+
return this.packet ? this.packet.end : this._packetEndValue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
set _packetEnd(value) {
|
|
172
|
+
if (this.packet) {
|
|
173
|
+
this.packet.end = value;
|
|
174
|
+
} else {
|
|
175
|
+
this._packetEndValue = value;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
setPacket(packet) {
|
|
180
|
+
this.packet = packet;
|
|
181
|
+
this._buffer = packet.buffer;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
append(buffer) {
|
|
185
|
+
this.packet = null;
|
|
186
|
+
this._buffer = buffer;
|
|
187
|
+
this._offsetValue = 0;
|
|
188
|
+
this._packetEndValue = buffer.length;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
parseUnsignedNumber(bytes) {
|
|
192
|
+
const offset = this._offset;
|
|
193
|
+
this._offset += bytes;
|
|
194
|
+
|
|
195
|
+
if (bytes <= 6) {
|
|
196
|
+
return this._buffer.readUIntLE(offset, bytes);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (bytes === 8) {
|
|
200
|
+
const low = this._buffer.readUInt32LE(offset);
|
|
201
|
+
const high = this._buffer.readUInt32LE(offset + 4);
|
|
202
|
+
return (high * 0x100000000) + low;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
throw new Error('Invalid unsigned integer size: ' + bytes);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
parseLengthCodedNumber() {
|
|
209
|
+
const first = this.parseUnsignedNumber(1);
|
|
210
|
+
if (first < 251) return first;
|
|
211
|
+
if (first === 251) return null;
|
|
212
|
+
if (first === 252) return this.parseUnsignedNumber(2);
|
|
213
|
+
if (first === 253) return this.parseUnsignedNumber(3);
|
|
214
|
+
if (first === 254) return this.parseUnsignedNumber(8);
|
|
215
|
+
throw new Error('Invalid length coded number');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
parseBuffer(length) {
|
|
219
|
+
if (length === undefined) {
|
|
220
|
+
length = this._packetEnd - this._offset;
|
|
221
|
+
}
|
|
222
|
+
const start = this._offset;
|
|
223
|
+
this._offset += length;
|
|
224
|
+
return this._buffer.slice(start, start + length);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
parseString(length) {
|
|
228
|
+
const buffer = this.parseBuffer(length);
|
|
229
|
+
return buffer.toString('utf8');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
parsePacketTerminatedString() {
|
|
233
|
+
return this.parseString(this._packetEnd - this._offset);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
parseLengthCodedString() {
|
|
237
|
+
const length = this.parseLengthCodedNumber();
|
|
238
|
+
if (length === null) return null;
|
|
239
|
+
return this.parseString(length);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
reachedPacketEnd() {
|
|
243
|
+
return this._offset >= this._packetEnd;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
140
246
|
|
|
141
|
-
|
|
247
|
+
export { BufferReader, Parser };
|
package/lib/rows_event.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const Common = require('./common');
|
|
1
|
+
import { BinlogEvent } from './binlog_event.js';
|
|
2
|
+
import * as Common from './common.js';
|
|
4
3
|
|
|
5
4
|
const Version2Events = [
|
|
6
5
|
0x1e, // WRITE_ROWS_EVENT_V2,
|
|
@@ -39,79 +38,80 @@ const BIT_COUNT_MAP_IN_ONE_BYTE = [
|
|
|
39
38
|
* zongji: ZongJi instance
|
|
40
39
|
**/
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// Body
|
|
57
|
-
this.numberOfColumns = parser.parseLengthCodedNumber();
|
|
58
|
-
|
|
59
|
-
this.tableMap = zongji.tableMap;
|
|
60
|
-
|
|
61
|
-
const tableData = this.tableMap[this.tableId];
|
|
62
|
-
if (tableData === undefined) {
|
|
63
|
-
// TableMap event was filtered
|
|
64
|
-
parser._offset = parser._packetEnd;
|
|
65
|
-
this._filtered = true;
|
|
66
|
-
} else {
|
|
67
|
-
const columnsPresentBitmapSize = Math.floor((this.numberOfColumns + 7) / 8);
|
|
68
|
-
this.columns_present_bitmap = parser.parseBuffer(columnsPresentBitmapSize);
|
|
69
|
-
if (this._hasTwoRows) {
|
|
70
|
-
// UpdateRows event slightly different, has new and old rows represented
|
|
71
|
-
this.columns_present_bitmap2 = parser.parseBuffer(columnsPresentBitmapSize);
|
|
41
|
+
class RowsEvent extends BinlogEvent {
|
|
42
|
+
constructor(parser, options, zongji, hasTwoRows = false) {
|
|
43
|
+
super(parser, options);
|
|
44
|
+
this._zongji = zongji;
|
|
45
|
+
this._hasTwoRows = hasTwoRows;
|
|
46
|
+
this._readTableId(parser);
|
|
47
|
+
this.flags = parser.parseUnsignedNumber(2);
|
|
48
|
+
this.useChecksum = zongji.useChecksum;
|
|
49
|
+
|
|
50
|
+
// Version 2 Events
|
|
51
|
+
if (Version2Events.indexOf(options.eventType) !== -1) {
|
|
52
|
+
this.extraDataLength = parser.parseUnsignedNumber(2);
|
|
53
|
+
// skip extra data
|
|
54
|
+
parser.parseBuffer(this.extraDataLength - 2);
|
|
72
55
|
}
|
|
73
56
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
parser._packetEnd -= CHECKSUM_SIZE;
|
|
77
|
-
}
|
|
57
|
+
// Body
|
|
58
|
+
this.numberOfColumns = parser.parseLengthCodedNumber();
|
|
78
59
|
|
|
79
|
-
this.
|
|
80
|
-
while (!parser.reachedPacketEnd()) {
|
|
81
|
-
this.rows.push(this._fetchOneRow(parser));
|
|
82
|
-
}
|
|
60
|
+
this.tableMap = zongji.tableMap;
|
|
83
61
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
parser._offset
|
|
62
|
+
const tableData = this.tableMap[this.tableId];
|
|
63
|
+
if (tableData === undefined) {
|
|
64
|
+
// TableMap event was filtered
|
|
65
|
+
parser._offset = parser._packetEnd;
|
|
66
|
+
this._filtered = true;
|
|
67
|
+
} else {
|
|
68
|
+
const columnsPresentBitmapSize = Math.floor((this.numberOfColumns + 7) / 8);
|
|
69
|
+
this.columns_present_bitmap = parser.parseBuffer(columnsPresentBitmapSize);
|
|
70
|
+
if (this._hasTwoRows) {
|
|
71
|
+
// UpdateRows event slightly different, has new and old rows represented
|
|
72
|
+
this.columns_present_bitmap2 = parser.parseBuffer(columnsPresentBitmapSize);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (this.useChecksum) {
|
|
76
|
+
// Ignore the checksum at the end of this packet
|
|
77
|
+
parser._packetEnd -= CHECKSUM_SIZE;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.rows = [];
|
|
81
|
+
while (!parser.reachedPacketEnd()) {
|
|
82
|
+
this.rows.push(this._fetchOneRow(parser));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (this.useChecksum) {
|
|
86
|
+
// Skip past the checksum at the end of the packet
|
|
87
|
+
parser._packetEnd += CHECKSUM_SIZE;
|
|
88
|
+
parser._offset += CHECKSUM_SIZE;
|
|
89
|
+
}
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
util.inherits(RowsEvent, BinlogEvent);
|
|
93
92
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
93
|
+
setTableMap(tableMap) {
|
|
94
|
+
this.tableMap = tableMap;
|
|
95
|
+
}
|
|
97
96
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
97
|
+
dump() {
|
|
98
|
+
super.dump();
|
|
99
|
+
console.log('Affected columns:', this.numberOfColumns);
|
|
100
|
+
console.log('Changed rows:', this.rows.length);
|
|
101
|
+
console.log('Values:');
|
|
102
|
+
this.rows.forEach(function(row) {
|
|
103
|
+
console.log('--');
|
|
104
|
+
Object.keys(row).forEach(function(name) {
|
|
105
|
+
console.log('Column: %s, Value: %s', name, row[name]);
|
|
106
|
+
});
|
|
107
107
|
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
108
|
+
}
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
110
|
+
_fetchOneRow(parser) {
|
|
111
|
+
const tablemap = this.tableMap[this.tableId];
|
|
112
|
+
return readRow(parser, tablemap, this.columns_present_bitmap, this._zongji);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
115
|
|
|
116
116
|
const countBits = function(buff) {
|
|
117
117
|
let bits = 0;
|
|
@@ -154,47 +154,43 @@ const readRow = function(parser, tablemap, bitmap, zongji) {
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
// Subclasses
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
util.inherits(WriteRows, RowsEvent);
|
|
162
|
-
|
|
163
|
-
// eslint
|
|
164
|
-
function DeleteRows(parser, options) { // eslint-disable-line
|
|
165
|
-
RowsEvent.apply(this, arguments);
|
|
157
|
+
class WriteRows extends RowsEvent {
|
|
158
|
+
constructor(parser, options, zongji) {
|
|
159
|
+
super(parser, options, zongji);
|
|
160
|
+
}
|
|
166
161
|
}
|
|
167
162
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
RowsEvent.apply(this, arguments);
|
|
163
|
+
class DeleteRows extends RowsEvent {
|
|
164
|
+
constructor(parser, options, zongji) {
|
|
165
|
+
super(parser, options, zongji);
|
|
166
|
+
}
|
|
173
167
|
}
|
|
174
168
|
|
|
175
|
-
|
|
169
|
+
class UpdateRows extends RowsEvent {
|
|
170
|
+
constructor(parser, options, zongji) {
|
|
171
|
+
super(parser, options, zongji, true);
|
|
172
|
+
}
|
|
176
173
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
174
|
+
_fetchOneRow(parser) {
|
|
175
|
+
const tablemap = this.tableMap[this.tableId];
|
|
176
|
+
return {
|
|
177
|
+
before: readRow(parser, tablemap, this.columns_present_bitmap, this._zongji),
|
|
178
|
+
after: readRow(parser, tablemap, this.columns_present_bitmap2, this._zongji),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
184
181
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
182
|
+
dump() {
|
|
183
|
+
BinlogEvent.prototype.dump.call(this);
|
|
184
|
+
console.log('Affected columns:', this.numberOfColumns);
|
|
185
|
+
console.log('Changed rows:', this.rows.length);
|
|
186
|
+
console.log('Values:');
|
|
187
|
+
this.rows.forEach(function(row) {
|
|
188
|
+
console.log('--');
|
|
189
|
+
Object.keys(row.before).forEach(function(name) {
|
|
190
|
+
console.log('Column: %s, Value: %s => %s', name, row.before[name], row.after[name]);
|
|
191
|
+
});
|
|
194
192
|
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
197
195
|
|
|
198
|
-
|
|
199
|
-
exports.DeleteRows = DeleteRows;
|
|
200
|
-
exports.UpdateRows = UpdateRows;
|
|
196
|
+
export { WriteRows, DeleteRows, UpdateRows };
|